Use of functions when working with messages

16 views
Skip to first unread message

Milica Milojevic

unread,
Apr 13, 2014, 6:26:46 PM4/13/14
to omn...@googlegroups.com
Hi all,

I am using Veins and I declared several variables of vector type in WaveShortMessage.msg. When I compile the message the cc and h files are created successfully. However I would like to use some vector functions such as clear() and push_back() and I cannot figure out how to use them. Can anybody advise me about this? When working with messages, in situations when I create fields different from basic types (int, double,..) like vector type, am I limited to use only functions that are generated in cc and h files?

Many thanks for the help.

Milica

Christoph Sommer

unread,
Apr 14, 2014, 3:37:43 AM4/14/14
to omn...@googlegroups.com
Dear Milica,

Milica Milojevic wrote:
> I declared several variables of vector type in WaveShortMessage.msg.
> When I compile the message the cc and h files are created successfully.
> However I would like to use some vector functions such as clear() and
> push_back() and I cannot figure out how to use them. Can anybody advise
> me about this?

This might be a bit tricky. The OMNeT++ User Manual section 6.2
(Messages and Packets) [1] should have all the necessary information.

If you want to use OMNeT++ wrapper functions for accessing vectors,
you'll find that in sections 6.2.5 (Fixed-Size Arrays) and 6.2.6
(Variable-Size Arrays).

If you want to use STL classes, you'll find that in section 6.6 (Using
C++ Types). This seems to be what you want.

Best,

Christoph



[1] http://www.omnetpp.org/doc/omnetpp/manual/usman.html#sec227

--
Dr. Christoph Sommer
Distributed Embedded Systems Group
University of Paderborn, Germany
http://www.ccs-labs.org/~sommer/
Reply all
Reply to author
Forward
0 new messages