diff options
Diffstat (limited to 'indra/llcommon/llinstancetracker.h')
-rw-r--r-- | indra/llcommon/llinstancetracker.h | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index 1eab270e3c..0f952f56ac 100644 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -38,6 +38,33 @@ #include <boost/iterator/transform_iterator.hpp> #include <boost/iterator/indirect_iterator.hpp> +enum InstanceTrackType +{ + InstanceTrackType_LLEventAPI, + InstanceTrackType_LLEventTimer, + InstanceTrackType_NamedTimer, + InstanceTrackType_DeclareTimer, + InstanceTrackType_LLLeap, + InstanceTrackType_LLGLNamePool, + InstanceTrackType_LLConsole, + InstanceTrackType_LLFloater, + InstanceTrackType_LLFloaterWebContent, + InstanceTrackType_LLLayoutStack, + InstanceTrackType_LLNotificationContext, + InstanceTrackType_LLWindow, + InstanceTrackType_LLControlGroup, + InstanceTrackType_LLControlCache, + InstanceTrackType_LLMediaCtrl, + InstanceTrackType_LLNameListCtrl, + InstanceTrackType_LLToast, + InstanceTrackType_Keyed, // for integ tests + InstanceTrackType_Unkeyed, // for integ tests + kInstanceTrackTypeCount +}; + +#define INSTANCE_TRACKER(T) LLInstanceTracker< T, InstanceTrackType_##T > +#define INSTANCE_TRACKER_KEYED(T,K) LLInstanceTracker< T, InstanceTrackType_##T, K > + /** * Base class manages "class-static" data that must actually have singleton * semantics: one instance per process, rather than one instance per module as @@ -47,14 +74,15 @@ class LL_COMMON_API LLInstanceTrackerBase { protected: /// Get a process-unique void* pointer slot for the specified type_info - static void * & getInstances(std::type_info const & info); + //static void * & getInstances(std::type_info const & info); + static void * & getInstances(InstanceTrackType t); /// Find or create a STATICDATA instance for the specified TRACKED class. /// STATICDATA must be default-constructible. - template<typename STATICDATA, class TRACKED> + template<typename STATICDATA, class TRACKED, class INST, InstanceTrackType TRACKEDTYPE> static STATICDATA& getStatic() { - void *& instances = getInstances(typeid(TRACKED)); + void *& instances = getInstances(TRACKEDTYPE); if (! instances) { instances = new STATICDATA; @@ -78,16 +106,16 @@ protected: /// The (optional) key associates a value of type KEY with a given instance of T, for quick lookup /// If KEY is not provided, then instances are stored in a simple set /// @NOTE: see explicit specialization below for default KEY==T* case -template<typename T, typename KEY = T*> +template<typename T, enum InstanceTrackType TRACKED, typename KEY = T*> class LLInstanceTracker : public LLInstanceTrackerBase { - typedef LLInstanceTracker<T, KEY> MyT; + typedef LLInstanceTracker<T, TRACKED, KEY> MyT; typedef typename std::map<KEY, T*> InstanceMap; struct StaticData: public StaticBase { InstanceMap sMap; }; - static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic<StaticData, MyT>(); } + static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic<StaticData, MyT, T, TRACKED>(); } static InstanceMap& getMap_() { return getStatic().sMap; } public: @@ -229,16 +257,16 @@ private: /// explicit specialization for default case where KEY is T* /// use a simple std::set<T*> -template<typename T> -class LLInstanceTracker<T, T*> : public LLInstanceTrackerBase +template<typename T, enum InstanceTrackType TRACKED> +class LLInstanceTracker<T, TRACKED, T*> : public LLInstanceTrackerBase { - typedef LLInstanceTracker<T, T*> MyT; + typedef LLInstanceTracker<T, TRACKED, T*> MyT; typedef typename std::set<T*> InstanceSet; struct StaticData: public StaticBase { InstanceSet sSet; }; - static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic<StaticData, MyT>(); } + static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic<StaticData, MyT, T, TRACKED>(); } static InstanceSet& getSet_() { return getStatic().sSet; } public: |