source: trash/old-modules/transport/omnet/AribaOmnetMessage_m.cc@ 12766

Last change on this file since 12766 was 5641, checked in by Christoph Mayer, 15 years ago
File size: 10.8 KB
RevLine 
[5641]1//
2// Generated file, do not edit! Created by opp_msgc 3.4 from ./AribaOmnetMessage.msg.
3//
4
5// Disable warnings about unused variables, empty switch stmts, etc:
6#ifdef _MSC_VER
7# pragma warning(disable:4101)
8# pragma warning(disable:4065)
9#endif
10
11#include <iostream>
12#include <sstream>
13#include "./AribaOmnetMessage_m.h"
14
15// Template rule which fires if a struct or class doesn't have operator<<
16template<typename T>
17std::ostream& operator<<(std::ostream& out,const T&) {return out;}
18
19// Another default rule (prevents compiler from choosing base class' doPacking())
20template<typename T>
21void doPacking(cCommBuffer *, T& t) {
22 throw new cRuntimeError("Parsim error: no doPacking() function for type %s or its base class (check .msg and _m.cc/h files!)",opp_typename(typeid(t)));
23}
24template<typename T>
25void doUnpacking(cCommBuffer *, T& t) {
26 throw new cRuntimeError("Parsim error: no doUnpacking() function for type %s or its base class (check .msg and _m.cc/h files!)",opp_typename(typeid(t)));
27}
28
29// Automatically supply array (un)packing functions
30template<typename T>
31void doPacking(cCommBuffer *b, T *t, int n) {
32 for (int i=0; i<n; i++)
33 doPacking(b,t[i]);
34}
35template<typename T>
36void doUnpacking(cCommBuffer *b, T *t, int n) {
37 for (int i=0; i<n; i++)
38 doUnpacking(b,t[i]);
39}
40inline void doPacking(cCommBuffer *, cPolymorphic&) {}
41inline void doUnpacking(cCommBuffer *, cPolymorphic&) {}
42
43#define DOPACKING(T,R) \
44 inline void doPacking(cCommBuffer *b, T R a) {b->pack(a);} \
45 inline void doPacking(cCommBuffer *b, T *a, int n) {b->pack(a,n);} \
46 inline void doUnpacking(cCommBuffer *b, T& a) {b->unpack(a);} \
47 inline void doUnpacking(cCommBuffer *b, T *a, int n) {b->unpack(a,n);}
48#define _
49DOPACKING(char,_)
50DOPACKING(unsigned char,_)
51DOPACKING(bool,_)
52DOPACKING(short,_)
53DOPACKING(unsigned short,_)
54DOPACKING(int,_)
55DOPACKING(unsigned int,_)
56DOPACKING(long,_)
57DOPACKING(unsigned long,_)
58DOPACKING(float,_)
59DOPACKING(double,_)
60DOPACKING(long double,_)
61DOPACKING(char *,_)
62DOPACKING(const char *,_)
63DOPACKING(opp_string,&)
64//DOPACKING(std::string,&)
65#undef _
66#undef DOPACKING
67
68
69Register_Class(AribaOmnetMessage);
70
71AribaOmnetMessage::AribaOmnetMessage(const char *name, int kind) : cMessage(name,kind)
72{
73 unsigned int i;
74 this->port_var = 0;
75 data_arraysize = 0;
76 this->data_var = 0;
77}
78
79AribaOmnetMessage::AribaOmnetMessage(const AribaOmnetMessage& other) : cMessage()
80{
81 unsigned int i;
82 setName(other.name());
83 data_arraysize = 0;
84 this->data_var = 0;
85 operator=(other);
86}
87
88AribaOmnetMessage::~AribaOmnetMessage()
89{
90 unsigned int i;
91 delete [] data_var;
92}
93
94AribaOmnetMessage& AribaOmnetMessage::operator=(const AribaOmnetMessage& other)
95{
96 if (this==&other) return *this;
97 unsigned int i;
98 cMessage::operator=(other);
99 this->port_var = other.port_var;
100 delete [] this->data_var;
101 this->data_var = (other.data_arraysize==0) ? NULL : new unsigned char[other.data_arraysize];
102 data_arraysize = other.data_arraysize;
103 for (i=0; i<data_arraysize; i++)
104 this->data_var[i] = other.data_var[i];
105 return *this;
106}
107
108void AribaOmnetMessage::netPack(cCommBuffer *b)
109{
110 cMessage::netPack(b);
111 doPacking(b,this->port_var);
112 b->pack(data_arraysize);
113 doPacking(b,this->data_var,data_arraysize);
114}
115
116void AribaOmnetMessage::netUnpack(cCommBuffer *b)
117{
118 cMessage::netUnpack(b);
119 doUnpacking(b,this->port_var);
120 delete [] this->data_var;
121 b->unpack(data_arraysize);
122 if (data_arraysize==0) {
123 this->data_var = 0;
124 } else {
125 this->data_var = new unsigned char[data_arraysize];
126 doUnpacking(b,this->data_var,data_arraysize);
127 }
128}
129
130unsigned int AribaOmnetMessage::getPort() const
131{
132 return port_var;
133}
134
135void AribaOmnetMessage::setPort(unsigned int port_var)
136{
137 this->port_var = port_var;
138}
139
140void AribaOmnetMessage::setDataArraySize(unsigned int size)
141{
142 unsigned char *data_var2 = (size==0) ? NULL : new unsigned char[size];
143 unsigned int sz = data_arraysize < size ? data_arraysize : size;
144 unsigned int i;
145 for (i=0; i<sz; i++)
146 data_var2[i] = this->data_var[i];
147 for (i=sz; i<size; i++)
148 data_var2[i] = 0;
149 data_arraysize = size;
150 delete [] this->data_var;
151 this->data_var = data_var2;
152}
153
154unsigned int AribaOmnetMessage::getDataArraySize() const
155{
156 return data_arraysize;
157}
158
159unsigned char AribaOmnetMessage::getData(unsigned int k) const
160{
161 if (k>=data_arraysize) throw new cRuntimeError("Array of size %d indexed by %d", data_arraysize, k);
162 return data_var[k];
163}
164
165void AribaOmnetMessage::setData(unsigned int k, unsigned char data_var)
166{
167 if (k>=data_arraysize) throw new cRuntimeError("Array of size %d indexed by %d", data_arraysize, k);
168 this->data_var[k]=data_var;
169}
170
171class AribaOmnetMessageDescriptor : public cClassDescriptor
172{
173 public:
174 AribaOmnetMessageDescriptor();
175 virtual ~AribaOmnetMessageDescriptor();
176
177 virtual bool doesSupport(cPolymorphic *obj);
178 virtual const char *getProperty(const char *propertyname);
179 virtual int getFieldCount(void *object);
180 virtual const char *getFieldName(void *object, int field);
181 virtual unsigned int getFieldTypeFlags(void *object, int field);
182 virtual const char *getFieldTypeString(void *object, int field);
183 virtual const char *getFieldProperty(void *object, int field, const char *propertyname);
184 virtual int getArraySize(void *object, int field);
185
186 virtual bool getFieldAsString(void *object, int field, int i, char *resultbuf, int bufsize);
187 virtual bool setFieldAsString(void *object, int field, int i, const char *value);
188
189 virtual const char *getFieldStructName(void *object, int field);
190 virtual void *getFieldStructPointer(void *object, int field, int i);
191};
192
193Register_ClassDescriptor(AribaOmnetMessageDescriptor);
194
195AribaOmnetMessageDescriptor::AribaOmnetMessageDescriptor() : cClassDescriptor("AribaOmnetMessage", "cMessage")
196{
197}
198
199AribaOmnetMessageDescriptor::~AribaOmnetMessageDescriptor()
200{
201}
202
203bool AribaOmnetMessageDescriptor::doesSupport(cPolymorphic *obj)
204{
205 return dynamic_cast<AribaOmnetMessage *>(obj)!=NULL;
206}
207
208const char *AribaOmnetMessageDescriptor::getProperty(const char *propertyname)
209{
210 cClassDescriptor *basedesc = getBaseClassDescriptor();
211 return basedesc ? basedesc->getProperty(propertyname) : NULL;
212}
213
214int AribaOmnetMessageDescriptor::getFieldCount(void *object)
215{
216 cClassDescriptor *basedesc = getBaseClassDescriptor();
217 return basedesc ? 2+basedesc->getFieldCount(object) : 2;
218}
219
220unsigned int AribaOmnetMessageDescriptor::getFieldTypeFlags(void *object, int field)
221{
222 cClassDescriptor *basedesc = getBaseClassDescriptor();
223 if (basedesc) {
224 if (field < basedesc->getFieldCount(object))
225 return basedesc->getFieldTypeFlags(object, field);
226 field -= basedesc->getFieldCount(object);
227 }
228 switch (field) {
229 case 0: return FD_ISEDITABLE;
230 case 1: return FD_ISARRAY | FD_ISEDITABLE;
231 default: return 0;
232 }
233}
234
235const char *AribaOmnetMessageDescriptor::getFieldName(void *object, int field)
236{
237 cClassDescriptor *basedesc = getBaseClassDescriptor();
238 if (basedesc) {
239 if (field < basedesc->getFieldCount(object))
240 return basedesc->getFieldName(object, field);
241 field -= basedesc->getFieldCount(object);
242 }
243 switch (field) {
244 case 0: return "port";
245 case 1: return "data";
246 default: return NULL;
247 }
248}
249
250const char *AribaOmnetMessageDescriptor::getFieldTypeString(void *object, int field)
251{
252 cClassDescriptor *basedesc = getBaseClassDescriptor();
253 if (basedesc) {
254 if (field < basedesc->getFieldCount(object))
255 return basedesc->getFieldTypeString(object, field);
256 field -= basedesc->getFieldCount(object);
257 }
258 switch (field) {
259 case 0: return "unsigned int";
260 case 1: return "unsigned char";
261 default: return NULL;
262 }
263}
264
265const char *AribaOmnetMessageDescriptor::getFieldProperty(void *object, int field, const char *propertyname)
266{
267 cClassDescriptor *basedesc = getBaseClassDescriptor();
268 if (basedesc) {
269 if (field < basedesc->getFieldCount(object))
270 return basedesc->getFieldProperty(object, field, propertyname);
271 field -= basedesc->getFieldCount(object);
272 }
273 switch (field) {
274 default: return NULL;
275 }
276}
277
278int AribaOmnetMessageDescriptor::getArraySize(void *object, int field)
279{
280 cClassDescriptor *basedesc = getBaseClassDescriptor();
281 if (basedesc) {
282 if (field < basedesc->getFieldCount(object))
283 return basedesc->getArraySize(object, field);
284 field -= basedesc->getFieldCount(object);
285 }
286 AribaOmnetMessage *pp _MAYBEUNUSED = (AribaOmnetMessage *)object;
287 switch (field) {
288 case 1: return pp->getDataArraySize();
289 default: return 0;
290 }
291}
292
293bool AribaOmnetMessageDescriptor::getFieldAsString(void *object, int field, int i, char *resultbuf, int bufsize)
294{
295 cClassDescriptor *basedesc = getBaseClassDescriptor();
296 if (basedesc) {
297 if (field < basedesc->getFieldCount(object))
298 return basedesc->getFieldAsString(object,field,i,resultbuf,bufsize);
299 field -= basedesc->getFieldCount(object);
300 }
301 AribaOmnetMessage *pp _MAYBEUNUSED = (AribaOmnetMessage *)object;
302 switch (field) {
303 case 0: long2string(pp->getPort(),resultbuf,bufsize); return true;
304 case 1: long2string(pp->getData(i),resultbuf,bufsize); return true;
305 default: return false;
306 }
307}
308
309bool AribaOmnetMessageDescriptor::setFieldAsString(void *object, int field, int i, const char *value)
310{
311 cClassDescriptor *basedesc = getBaseClassDescriptor();
312 if (basedesc) {
313 if (field < basedesc->getFieldCount(object))
314 return basedesc->setFieldAsString(object,field,i,value);
315 field -= basedesc->getFieldCount(object);
316 }
317 AribaOmnetMessage *pp _MAYBEUNUSED = (AribaOmnetMessage *)object;
318 switch (field) {
319 case 0: pp->setPort(string2long(value)); return true;
320 case 1: pp->setData(i,string2long(value)); return true;
321 default: return false;
322 }
323}
324
325const char *AribaOmnetMessageDescriptor::getFieldStructName(void *object, int field)
326{
327 cClassDescriptor *basedesc = getBaseClassDescriptor();
328 if (basedesc) {
329 if (field < basedesc->getFieldCount(object))
330 return basedesc->getFieldStructName(object, field);
331 field -= basedesc->getFieldCount(object);
332 }
333 switch (field) {
334 default: return NULL;
335 }
336}
337
338void *AribaOmnetMessageDescriptor::getFieldStructPointer(void *object, int field, int i)
339{
340 cClassDescriptor *basedesc = getBaseClassDescriptor();
341 if (basedesc) {
342 if (field < basedesc->getFieldCount(object))
343 return basedesc->getFieldStructPointer(object, field, i);
344 field -= basedesc->getFieldCount(object);
345 }
346 AribaOmnetMessage *pp _MAYBEUNUSED = (AribaOmnetMessage *)object;
347 switch (field) {
348 default: return NULL;
349 }
350}
351
Note: See TracBrowser for help on using the repository browser.