|
Re: Deep copy of the passed message to the action code [message #1765121 is a reply to message #1765033] |
Tue, 06 June 2017 20:38 |
Ernesto Posse Messages: 438 Registered: March 2011 |
Senior Member |
|
|
There is no deep copy for the message (UMLRTMessage) itself. A message does contain a UMLRTSignal (which contains the payload), as well, which has a copy constructor, but this only increments the refcount for the signal, rather than a deep copy.
Keep in mind that these structures are very much internal. Yes, the action code gives you access to the UMLRTMessage, but the only functionality supported is defined by the UMLRTMessage public interface:
bool defer ( ) const;
void * getParam ( size_t index ) const;
UMLRTPriority getPriority ( ) const { return signal.getPriority(); }
int getSignalId ( ) const { return signal.getId(); }
const char * getSignalName ( ) const { return signal.getName(); }
const UMLRTObject_class * getType ( size_t index = 0 ) const { return signal.getType(index); }
bool isValid ( ) const { return !signal.isInvalid(); }
size_t sapIndex ( ) const { return sapIndex0_ + 1; }
size_t sapIndex0 ( ) const { return sapIndex0_; }
const UMLRTCommsPort * sap ( ) const { return destPort; }
It seems rather odd to want to deep-copy, or even shallow copy the message. What's your use case?
If you want to copy the actual message payload, that's another story.
By default there is support for copying data that comes with a message, but only a shallow copy. Originally deep-copy was supported, but requirements changed. When a message is received, the receiver gets a shallow copy of the payload. (Before it used to give you a deep copy).
If you want to do a deep copy of the data payload, it's up to you. You can send user-defined data-types in messages. If your data-type has a copy-constructor, that's going to be invoked when sending the data.
You can add the PassiveClassProperties stereotype on (data) classes, and set "generateCopyConstructor" to true (although that's the default). This will generate a default copy constructor which performs shallow copy on data. If you want a custom copy constructor, you can set" generateCopyConstructor to false, and set "publicDeclarations" to include a declaration of your copy constructor, and you can add the body of the copy constructor to "implementationEnding. See the attached model as an example. Class1 has the default copy constructor, while Class2 has a custom one.
|
|
|
|
Powered by
FUDForum. Page generated in 0.02617 seconds