#ifndef __GenericTosData_h_ #define __GenericTosData_h_ #include "../misc_framework/DebugMessage.h" #include "../misc_framework/DataNodes.h" #include "TosData.h" /* This unit is intended as a firewall between the producers and consumers of this data. We could change data providers with very little impact on a number of consumers. We can add new consumers without any changes to the low level implementation. TosData contains pretty much all real-time data which changes at the same time as there is a print. See GenericL1Data for the remaining data. */ class GenericTosDataNode; typedef DataNodeLink *(*TosImplementation)(DataNodeListener *listener, int msgId, GenericTosDataNode *&node, std::string const &symbol); class GenericTosDataNode : public DataNode { private: static TosImplementation implementation; static Debugger *debugger; const std::string _symbol; protected: // We force this implementation because it seems reasonable, and because it // makes the call to extract data very inexpensive. Making getValid() a // virtual function would be more generic, but it seems wasteful. bool _valid; TosData _last; GenericTosDataNode(DataNodeArgument const &args); friend class DataNode; enum { bmDebug, // Used for DebugMessage bmAvailable }; // First id available for a subclass void onBroadcast(BroadcastMessage &message, int msgId); public: bool getValid() const { return _valid; } TosData const &getLast() const { return _last; } std::string const &symbol() const { return _symbol; } static DataNodeLink *find(DataNodeListener *listener, int msgId, GenericTosDataNode *&node, std::string const &symbol); static DataNodeLink *find(GenericTosDataNode *&node, std::string const &symbol) { return find(NULL, 0, node, symbol); } static void registerImplementation(TosImplementation newImplementation); static void registerDebugger(DataNodeManager *manager); // Might return NULL. static Debugger *getDebugger() { return debugger; } }; #endif