Convert message const ptr to non-const ptr
What is the PROPER way to convert the ConstPtr that I receive in a message callback to a non-const ptr so that I can modify the data? What I want to do is to store a buffer of the messages my node receives and then do some additional manipulation.
I know I can manually allocate a copy the message information and store it locally, but this removes the whole point of using classes and becomes a pain when a class has member data which is another class. The autogenerated messages do not have a specific copy constructor and I could not find any good way of adding one (I don't wanna do it manually in the generated header as it will disappear if I change the message). Using the default C++ copy constructor will get me in trouble as it makes only shallow copies of complex data structures which are part of the member data of the message class and when the shared_ptr count for the message goes to 0 I will get a segfault.