#include "../../shared/ReplyToClient.h" #include "GenericL1Data.h" //////////////////////////////////////////////////////////////////// // GenericL1DataNode //////////////////////////////////////////////////////////////////// static const std::string debugPrefix = "GenericL1DataNode.debug."; GenericL1DataNode::GenericL1DataNode(DataNodeArgument const &args) : _symbol(args.getStringValue()), _valid(false) { _current.clear(); registerForBroadcast(debugPrefix + _symbol, bmDebug); } DataNodeLink *GenericL1DataNode::find(DataNodeListener *listener, int msgId, GenericL1DataNode *&node, std::string const &symbol) { if (implementation) { // Captured by a real data feed. return implementation(listener, msgId, node, symbol); } // Use the default, which only presents debug messages. return findHelper(listener, msgId, node, symbol); } void GenericL1DataNode::registerDebugger(DataNodeManager *manager) { // This class doesn't make any real attempt to deal with multiple calls to // this function. Presumably if you try to start this twice, the command // handler will complain about a duplicate command name being registered. // If it was important, we could get around that limitation by taking the // command name as an imput to this function. new Debugger("debug_l1", bmDebug, debugPrefix, manager); } void GenericL1DataNode::onBroadcast(BroadcastMessage &message, int msgId) { switch (msgId) { case bmDebug: { DebugMessage const &m = dynamic_cast< DebugMessage const & >(message); PropertyList const &p = m.getProperties(); const bool set = getPropertyDefault(p, "set") == "1"; if (set) { _valid = getPropertyDefault(p, "invalid") != "1"; if (_valid) { _current.bidPrice = strtodDefault(getPropertyDefault(p, "bid_price"), _current.bidPrice); _current.bidSize = strtollDefault(getPropertyDefault(p, "bid_size"), _current.bidSize); _current.bidExchange = getProperty(p, std::string("bid_exchange"), _current.bidExchange); _current.askPrice = strtodDefault(getPropertyDefault(p, "ask_price"), _current.askPrice); _current.askSize = strtollDefault(getPropertyDefault(p, "ask_size"), _current.askSize); _current.askExchange = getProperty(p, std::string("ask_exchange"), _current.askExchange); } else { // invalid _current.clear(); } } TclList msg; msg<<"GenericL1Data.C" <<"bmDebug" <<(_valid?"valid":"invalid") <<_current.dump() <