#ifndef __DailyCandles_h_ #define __DailyCandles_h_ #include "../shared/ThreadSafeRefCount.h" #include "../shared/SWTLocker.h" #include "CandleDataNode.h" class DailyCandles : public CandleDataNode { private: static std::string timeTToMysqlDate(time_t time); GenericTosDataNode *_tosData; const std::string _symbol; // These are protected by the mutex. You can read these if you are in the // data node thread OR you are holding the mutex. You can change these if // you are in the data node thread AND you are holding the mutex. struct FromRealTime { SingleCandle currentState; time_t candleStartTime; EpochCounter epochCounter; FromRealTime() : candleStartTime(0) { } }; SWTLocker< FromRealTime > _fromRealtime; // Read write access in the data node thread, no access in other threads. time_t _resetTime; static CachedCandles getCacheFromDatabase(std::string const &symbol); static std::string const &getCacheSize(); static bool cacheDisabled() { return getCacheSize().empty(); } CachedCandlesHolder _databaseCache; void onWakeup(int msgId); void onBroadcast(BroadcastMessage &message, int msgId); DailyCandles(std::string const &key, std::string const &symbol); public: virtual void threadSafeGet(AllRowTimes const &requests, SingleCandle::ByStartTime &destination); virtual time_t threadSafeRestartAt(EpochCounter::Epoch epoch); virtual time_t oldestFastTime(); virtual StartTimeList startTimeList(time_t startBefore); virtual StartTimeList startTimeList(StartTimeList const &previous); virtual TclList debugDump() const; static DailyCandles *find(std::string const &symbol); }; #endif