RTBKit  0.9
Open-source framework to create real-time ad bidding systems.
core/banker/null_banker.h
00001 /* null_banker.h                                                   -*- C++ -*-
00002    Jeremy Barens, 11 October 2012
00003    Copyright (c) 2012 Datacratic Inc.  All rights reserved.
00004 
00005    Banker class that either authorizes all bids or rejects all bids.
00006 */
00007 
00008 #ifndef __banker__null_banker_h__
00009 #define __banker__null_banker_h__
00010 
00011 #include "banker.h"
00012 
00013 namespace RTBKIT {
00014 
00015 /*****************************************************************************/
00016 /* NULL BUDGET CONTROLLER                                                    */
00017 /*****************************************************************************/
00018 
00021 struct NullBudgetController: public BudgetController {
00022 
00023     virtual void addAccountSync(const AccountKey & account);
00024     
00025     virtual void topupTransferSync(const AccountKey & account,
00026                                              CurrencyPool amount);
00027     
00028     virtual void setBudgetSync(const std::string & topLevelAccount,
00029                                CurrencyPool amount);
00030     
00031     virtual void addBudgetSync(const std::string & topLevelAccount,
00032                                CurrencyPool amount);
00033     
00034 };
00035 
00036 
00037 /*****************************************************************************/
00038 /* NULL BANKER                                                               */
00039 /*****************************************************************************/
00040 
00045 class NullBanker: public Banker {
00046 public:
00047     NullBanker(bool authorize = false);
00048 
00049     virtual bool authorizeBid(const AccountKey & account,
00050                               const std::string & item,
00051                               Amount amount);
00052 
00056     virtual void commitBid(const AccountKey & account,
00057                            const std::string & item,
00058                            Amount amountPaid,
00059                            const LineItems & lineItems);
00060 
00061     virtual void forceWinBid(const AccountKey & account,
00062                              Amount amountPaid,
00063                              const LineItems & lineItems);
00064     
00065     virtual void attachBid(const AccountKey & account,
00066                            const std::string & item,
00067                            Amount amountAuthorized)
00068     {
00069     }
00070 
00071     virtual Amount detachBid(const AccountKey & account,
00072                              const std::string & item)
00073     {
00074         return Amount();
00075     }
00076 
00077     virtual ShadowAccount
00078     addSpendAccountSync(const AccountKey & account,
00079                         CurrencyPool accountFloat = CurrencyPool())
00080     {
00081         return ShadowAccount();
00082     }
00083 
00084 
00085 #if 0
00086     std::string getCampaignStatusStr(const std::string & campaign,
00087                                      const std::string &strategy) const;
00088     Json::Value getCampaignStatusJson(const std::string & campaign,
00089                                       const std::string &strategy) const;
00090     
00091     Json::Value dumpAllCampaignsJson() const;
00092 #endif    
00093 
00094 #if 0
00095     void forEachOutstanding(const ForEachCallback & cb, Date latestDate);
00096     
00097     virtual OutstandingStats
00098     totalOutstandingStats(const std::string & campaign = "*",
00099                           const std::string & strategy = "*") const;
00100 #endif
00101 
00102 protected:
00103     virtual void sanityCheck(const std::string &campaign) const {};
00104 
00105     friend class Datacratic::JS::NullBankerJS;
00106     bool authorize_;
00107 };
00108 
00109 
00110 struct NullAccountant: public Accountant {
00111     virtual AccountSummary
00112     getAccountSummarySync(const AccountKey & account,
00113                          int depth)
00114     {
00115         return AccountSummary();
00116     }
00117 
00118     virtual std::vector<AccountKey>
00119     getAccountListSync(const AccountKey & account,
00120                        int depth)
00121     {
00122         return std::vector<AccountKey>();
00123     }
00124 };
00125 
00126 } // namespace RTBKIT
00127 
00128 #endif /* __banker__null_banker_h__ */
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator