RTBKit  0.9
Open-source framework to create real-time ad bidding systems.
common/augmentation.h
00001 
00009 #ifndef __rtb__augmentation_h__
00010 #define __rtb__augmentation_h__
00011 
00012 #include "rtbkit/common/account_key.h"
00013 #include "soa/jsoncpp/value.h"
00014 
00015 #include <set>
00016 #include <string>
00017 
00018 namespace RTBKIT {
00019 
00020 /******************************************************************************/
00021 /* AUGMENTATION                                                               */
00022 /******************************************************************************/
00023 
00027 struct Augmentation
00028 {
00029     Augmentation() {}
00030 
00031     Augmentation(
00032             const std::set<std::string>& tags,
00033             const Json::Value& data = Json::Value()) :
00034         tags(tags), data(data)
00035     {}
00036 
00037     Augmentation(const Json::Value& data) : tags(), data(data) {}
00038 
00039     std::set<std::string> tags;
00040     Json::Value data;
00041 
00042     void mergeWith(const Augmentation& other);
00043 
00044     Json::Value toJson() const;
00045     static Augmentation fromJson(const Json::Value& json);
00046 };
00047 
00051 typedef std::map<std::string, std::string> AgentAugmentations;
00052 
00053 
00054 /******************************************************************************/
00055 /* AUGMENTATION LIST                                                          */
00056 /******************************************************************************/
00057 
00058 // \todo may want to change this to unordered_map.
00059 typedef std::map<AccountKey, Augmentation> AugmentationListBase;
00060 
00062 struct AugmentationList : public AugmentationListBase
00063 {
00064 
00065     void insertGlobal(const Augmentation& aug)
00066     {
00067         insert(std::make_pair(AccountKey(), aug));
00068     }
00069 
00071     void mergeWith(const AugmentationList& other);
00072 
00073 
00075     Augmentation filterForAccount(AccountKey account) const;
00076 
00077 
00082     std::vector<std::string> tagsForAccount(AccountKey account) const;
00083 
00084 
00085     Json::Value toJson() const;
00086     static AugmentationList fromJson(const Json::Value& json);
00087 };
00088 
00089 
00090 } // namespace RTBKIT
00091 
00092 #endif // __rtb__augmentation_h__
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator