RTBKit
0.9
Open-source framework to create real-time ad bidding systems.
|
00001 /* mock_banker_persistence.cc -*- C++ -*- 00002 Wolfgang Sourdeau, 14 December 2012 00003 Copyright (c) 2012 Datacratic. All rights reserved. 00004 00005 Mock banker persistence for testing classes that depend on persistence 00006 storage. 00007 */ 00008 00009 #ifndef MOCK_BANKER_PERSISTENCE_H 00010 #define MOCK_BANKER_PERSISTENCE_H 00011 00012 #include <deque> 00013 #include <memory> 00014 #include <string> 00015 00016 #include "rtbkit/core/banker/master_banker.h" 00017 00018 namespace RTBKIT { 00019 00020 struct MockBankerPersistence : public BankerPersistence { 00021 MockBankerPersistence(); 00022 00023 bool disableSaves; /* make "saveAll" void */ 00024 00025 std::deque<BankerPersistence::PersistenceCallbackStatus> statusQ; 00026 std::deque<std::string> infoQ; 00027 std::deque<std::shared_ptr<Accounts>> accountsQ; 00028 00029 void prepareLoad(std::shared_ptr<Accounts> accounts, 00030 BankerPersistence::PersistenceCallbackStatus status, 00031 std::string info); 00032 void prepareSave(BankerPersistence::PersistenceCallbackStatus status, 00033 std::string info); 00034 00035 void loadAll(const std::string & topLevelKey, OnLoadedCallback onLoaded); 00036 void saveAll(const Accounts & toSave, OnSavedCallback onSaved); 00037 00038 private: 00039 std::deque<int> opsQ; // 1 = save; 2 = load 00040 }; 00041 00042 } // namespace RTBKIT 00043 00044 #endif /* MOCK_BANKER_PERSISTENCE_H */