![]() |
AppEasy Core SDK
1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
|
00001 // 00002 // 00003 // AppEasy SDK - Cross Platform Multi-purpose Game and App Engine 00004 // 00005 // Developed by Matthew Hopwood of Pocketeers Limited - www.pocketeers.co.uk 00006 // 00007 // For updates, tutorials and more details check out www.appeasymobile.com 00008 // 00009 // This code is provided free of charge and without any warranty whatsoever. You must ensure that this whole notice is present in all files and derivatives, so the reader knows its origin. 00010 // If you use this SDK in your product then please ensure that you credit AppEasy's usage appropriately. Please see www.appeasymobile.com for licensing details and support 00011 // 00012 // 00013 00014 #if !defined(_CZ_ADS_MEDIATOR_H_) 00015 #define _CZ_ADS_MEDIATOR_H_ 00016 00017 #include "CzUtil.h" 00018 #include "CzAds.h" 00019 00020 // 00021 // 00022 // CzAdParty - The CzAdParty structure represents a single ad mediation party which can request ads 00023 // 00024 // 00025 struct CzAdsParty 00026 { 00027 CzAds::eAdProvider Provider; // Ad provider 00028 CzString ApplicationID; // ID of the application thats making the request (you will need to be assigned this from inner-active) 00029 CzString OtherID; // Extra ID information 00030 CzString ExtraInfo; // Pass in any extra pareneters as name vakue pairs, e.g. &city=london&ad_unit=1 (optional) 00031 00032 CzAdsParty() {} 00033 virtual ~CzAdsParty() 00034 { 00035 } 00036 }; 00037 00038 // 00039 // 00040 // CzAdsMediator - The CzAdsMediator class is responsible for mediating ad requests between different ad providers to help impriove fill rates and monetisation 00041 // 00042 // 00043 class CzAdsMediator 00044 { 00045 public: 00046 // Public access for scene iteration 00047 typedef CzVector<CzAdsParty*>::iterator _Iterator; 00048 _Iterator begin() { return AdParties.begin(); } 00049 _Iterator end() { return AdParties.end(); } 00050 00051 // Properties 00052 protected: 00053 CzVector<CzAdsParty*> AdParties; 00054 int NextAdParty; 00055 00056 public: 00057 void addAdParty(CzAdsParty* party) 00058 { 00059 AdParties.push_back(party); 00060 } 00061 void removeAdParty(CzAdsParty* party) 00062 { 00063 for (_Iterator it = AdParties.begin(); it != AdParties.end(); ++it) 00064 { 00065 if ((*it) == party) 00066 { 00067 delete *it; 00068 AdParties.erase(it); 00069 break; 00070 } 00071 } 00072 } 00073 void clearParties() 00074 { 00075 for (_Iterator it = AdParties.begin(); it != AdParties.end(); ++it) 00076 delete *it; 00077 AdParties.clear(); 00078 } 00079 CzAdsParty* getNextAdParty() 00080 { 00081 int max = AdParties.size(); 00082 if (max == 0) 00083 return NULL; 00084 00085 // If we ran out of ad partys then start again from first 00086 if (NextAdParty >= max) 00087 NextAdParty = 0; 00088 00089 return AdParties[NextAdParty++]; 00090 } 00091 void reset() 00092 { 00093 NextAdParty = 0; 00094 } 00095 00096 // Properties end 00097 00098 protected: 00099 00100 00101 public: 00102 CzAdsMediator() : NextAdParty(0) {} 00103 virtual ~CzAdsMediator() 00104 { 00105 clearParties(); 00106 } 00107 00108 }; 00109 00110 00111 #endif // _CZ_ADS_MEDIATOR_H_