#ifndef NODE_H#define NODE_H#include "signal.h"class World;/**Base abstract 'Node' framework classThis class is the class inherited by each node.Node's are different part's of the application,and can be thought of as little clients.Signals are recieved and sent as strings.*/class Node{ public: /**update class pointer to parent*/ Node(World *par); /***/ ~Node(); /**Recieve and Interpret a signal RecieveSignal should be overriden, by all derived node classes*/ virtual void RecieveSignal(const string &id , Signal &sig); protected: /**Send a signal to parent to broadcast Broadcast should not be overriden as it is used to communicate with the other nodes, via the parent*/ void Broadcast(const string &id , Signal &sig); /**Send a signal to parent to relay SendSignal should not be overriden as it is used to communicate with the other nodes, via the parent*/ void SendSignal(const string &name , const string &id , Signal &sig); private: World *parent; ///< Node's Parent};#endif
All the different nodes, are created, and registered with the app. Different nodes need to communicate, and parameters need to be passed around.
As for a new data type for each different type of signal... well the reciever and sender BOTH need to know the signal type (so reciever can cast back to type to read data), and since there are potentially lots of signals, and a broadcast...
ProPuke's solution is the simplest, and my favorite... but what happens with lots of data types, use pointers? I might as well cast everything to ints, and anything else read the pointer and cast as an int.
boost::any is exactly what i need (especially type checking)... but i need to link against boost, and its a bit OTT for whats needed. What would be better :D lmao, would be if anyone could tell me how its is able to accept any type, and how it internally stores the typeinfo.
If it helps, the system im (trying) to design is more like Qt's mechanism.
Thank you for your time.