#ifndef __GenericHaltData_h_ #define __GenericHaltData_h_ #include "../misc_framework/DebugMessage.h" #include "../misc_framework/DataNodes.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. Halt data contains halt and resume messages along with a reason */ struct HaltData { time_t time; int64_t type; int64_t reason; double price; DataNode::Integer size; void clear(); TclList dump() const; }; class GenericHaltDataNode; typedef DataNodeLink *(*HaltImplementation)(DataNodeListener *listener, int msgId, GenericHaltDataNode *&node, std::string const &symbol); class GenericHaltDataNode : public DataNode { private: static HaltImplementation implementation; static Debugger *debugger; const std::string _symbol; protected: HaltData _last; GenericHaltDataNode(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: HaltData const &getLast() const { return _last; } std::string const &symbol() const { return _symbol; } static DataNodeLink *find(DataNodeListener *listener, int msgId, GenericHaltDataNode *&node, std::string const &symbol); static DataNodeLink *find(GenericHaltDataNode *&node, std::string const &symbol) { return find(NULL, 0, node, symbol); } static void registerImplementation(HaltImplementation newImplementation); static void registerDebugger(DataNodeManager *manager); // Might return NULL. static Debugger *getDebugger() { return debugger; } }; #endif