Using the same data structure in multiple nodes
I am designing a system which consists of multiple nodes. Among others there is a "gui" node for visualization and a "controls" node for controlling the whole application. During runtime I need to keep and update the information about a so called camera_unit for which I created a class CameraUnit (.h + .cpp files). The thing is I need to use this class both in "gui" and "controls" node, as the gui uses the info for visualization and the controls for other computations, but I do not want to duplicate the code. What are my options? I have thought of these:
1. Duplicate the code (Probably the worst option as I would have to always copy .h and .cpp file between nodes when editing them)
2. Make the static library out of the CameraUnit class which would be linked to both "controls" and "gui" node (That seems possible but I still feel there is a more elegant option)
3. Merge "gui" and "controls" nodes to one node and make the gui run in a separate thread (I would like to prevent this option as it would change my architecture)
Thank you for any advice!
Why don't you just include your CameraUnit.h in both nodes? #include <your_package cameraunit.h="">
That would work but it would mean referencing the code from the different package and I thought this would not be really clean either. Or do you consider such an approach alright?