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<<
|
---|
16 | template<typename T>
|
---|
17 | std::ostream& operator<<(std::ostream& out,const T&) {return out;}
|
---|
18 |
|
---|
19 | // Another default rule (prevents compiler from choosing base class' doPacking())
|
---|
20 | template<typename T>
|
---|
21 | void 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 | }
|
---|
24 | template<typename T>
|
---|
25 | void 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
|
---|
30 | template<typename T>
|
---|
31 | void doPacking(cCommBuffer *b, T *t, int n) {
|
---|
32 | for (int i=0; i<n; i++)
|
---|
33 | doPacking(b,t[i]);
|
---|
34 | }
|
---|
35 | template<typename T>
|
---|
36 | void doUnpacking(cCommBuffer *b, T *t, int n) {
|
---|
37 | for (int i=0; i<n; i++)
|
---|
38 | doUnpacking(b,t[i]);
|
---|
39 | }
|
---|
40 | inline void doPacking(cCommBuffer *, cPolymorphic&) {}
|
---|
41 | inline 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 _
|
---|
49 | DOPACKING(char,_)
|
---|
50 | DOPACKING(unsigned char,_)
|
---|
51 | DOPACKING(bool,_)
|
---|
52 | DOPACKING(short,_)
|
---|
53 | DOPACKING(unsigned short,_)
|
---|
54 | DOPACKING(int,_)
|
---|
55 | DOPACKING(unsigned int,_)
|
---|
56 | DOPACKING(long,_)
|
---|
57 | DOPACKING(unsigned long,_)
|
---|
58 | DOPACKING(float,_)
|
---|
59 | DOPACKING(double,_)
|
---|
60 | DOPACKING(long double,_)
|
---|
61 | DOPACKING(char *,_)
|
---|
62 | DOPACKING(const char *,_)
|
---|
63 | DOPACKING(opp_string,&)
|
---|
64 | //DOPACKING(std::string,&)
|
---|
65 | #undef _
|
---|
66 | #undef DOPACKING
|
---|
67 |
|
---|
68 |
|
---|
69 | Register_Class(AribaOmnetMessage);
|
---|
70 |
|
---|
71 | AribaOmnetMessage::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 |
|
---|
79 | AribaOmnetMessage::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 |
|
---|
88 | AribaOmnetMessage::~AribaOmnetMessage()
|
---|
89 | {
|
---|
90 | unsigned int i;
|
---|
91 | delete [] data_var;
|
---|
92 | }
|
---|
93 |
|
---|
94 | AribaOmnetMessage& 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 |
|
---|
108 | void 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 |
|
---|
116 | void 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 |
|
---|
130 | unsigned int AribaOmnetMessage::getPort() const
|
---|
131 | {
|
---|
132 | return port_var;
|
---|
133 | }
|
---|
134 |
|
---|
135 | void AribaOmnetMessage::setPort(unsigned int port_var)
|
---|
136 | {
|
---|
137 | this->port_var = port_var;
|
---|
138 | }
|
---|
139 |
|
---|
140 | void 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 |
|
---|
154 | unsigned int AribaOmnetMessage::getDataArraySize() const
|
---|
155 | {
|
---|
156 | return data_arraysize;
|
---|
157 | }
|
---|
158 |
|
---|
159 | unsigned 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 |
|
---|
165 | void 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 |
|
---|
171 | class 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 |
|
---|
193 | Register_ClassDescriptor(AribaOmnetMessageDescriptor);
|
---|
194 |
|
---|
195 | AribaOmnetMessageDescriptor::AribaOmnetMessageDescriptor() : cClassDescriptor("AribaOmnetMessage", "cMessage")
|
---|
196 | {
|
---|
197 | }
|
---|
198 |
|
---|
199 | AribaOmnetMessageDescriptor::~AribaOmnetMessageDescriptor()
|
---|
200 | {
|
---|
201 | }
|
---|
202 |
|
---|
203 | bool AribaOmnetMessageDescriptor::doesSupport(cPolymorphic *obj)
|
---|
204 | {
|
---|
205 | return dynamic_cast<AribaOmnetMessage *>(obj)!=NULL;
|
---|
206 | }
|
---|
207 |
|
---|
208 | const char *AribaOmnetMessageDescriptor::getProperty(const char *propertyname)
|
---|
209 | {
|
---|
210 | cClassDescriptor *basedesc = getBaseClassDescriptor();
|
---|
211 | return basedesc ? basedesc->getProperty(propertyname) : NULL;
|
---|
212 | }
|
---|
213 |
|
---|
214 | int AribaOmnetMessageDescriptor::getFieldCount(void *object)
|
---|
215 | {
|
---|
216 | cClassDescriptor *basedesc = getBaseClassDescriptor();
|
---|
217 | return basedesc ? 2+basedesc->getFieldCount(object) : 2;
|
---|
218 | }
|
---|
219 |
|
---|
220 | unsigned 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 |
|
---|
235 | const 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 |
|
---|
250 | const 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 |
|
---|
265 | const 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 |
|
---|
278 | int 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 |
|
---|
293 | bool 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 |
|
---|
309 | bool 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 |
|
---|
325 | const 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 |
|
---|
338 | void *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 |
|
---|