#ifndef __GenericL1Data_h_ #define __GenericL1Data_h_ #include "../misc_framework/DebugMessage.h" #include "../misc_framework/DataNodes.h" #include "L1Data.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. */ class GenericL1DataNode; typedef DataNodeLink *(*L1Implementation)(DataNodeListener *listener, int msgId, GenericL1DataNode *&node, std::string const &symbol); class GenericL1DataNode : public DataNode { private: static L1Implementation implementation; 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; L1Data _current; GenericL1DataNode(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; } L1Data const &getCurrent() const { return _current; } std::string const &symbol() const { return _symbol; } static DataNodeLink *find(DataNodeListener *listener, int msgId, GenericL1DataNode *&node, std::string const &symbol); static DataNodeLink *find(GenericL1DataNode *&node, std::string const &symbol) { return find(NULL, 0, node, symbol); } static void registerImplementation(L1Implementation newImplementation); static void registerDebugger(DataNodeManager *manager); }; #endif