Modify LLInstanceTracker to avoid using a map of strings to find a map of foo to find some pointers
parent
2dcbbf04c9
commit
93eaccae6f
|
|
@ -750,6 +750,7 @@ Marine Kelley
|
|||
MartinRJ Fayray
|
||||
STORM-1844
|
||||
STORM-1845
|
||||
STORM-1934
|
||||
Matthew Anthony
|
||||
Matthew Dowd
|
||||
VWR-1344
|
||||
|
|
|
|||
|
|
@ -41,12 +41,13 @@
|
|||
* Deriving from LLInstanceTracker lets us enumerate instances.
|
||||
*/
|
||||
class LL_COMMON_API LLEventAPI: public LLDispatchListener,
|
||||
public LLInstanceTracker<LLEventAPI, std::string>
|
||||
public INSTANCE_TRACKER_KEYED(LLEventAPI, std::string)
|
||||
{
|
||||
typedef LLDispatchListener lbase;
|
||||
typedef LLInstanceTracker<LLEventAPI, std::string> ibase;
|
||||
typedef INSTANCE_TRACKER_KEYED(LLEventAPI, std::string) ibase;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @param name LLEventPump name on which this LLEventAPI will listen. This
|
||||
* also serves as the LLInstanceTracker instance key.
|
||||
|
|
|
|||
|
|
@ -33,9 +33,10 @@
|
|||
#include "lltimer.h"
|
||||
|
||||
// class for scheduling a function to be called at a given frequency (approximate, inprecise)
|
||||
class LL_COMMON_API LLEventTimer : public LLInstanceTracker<LLEventTimer>
|
||||
class LL_COMMON_API LLEventTimer : public INSTANCE_TRACKER(LLEventTimer)
|
||||
{
|
||||
public:
|
||||
|
||||
LLEventTimer(F32 period); // period is the amount of time between each call to tick() in seconds
|
||||
LLEventTimer(const LLDate& time);
|
||||
virtual ~LLEventTimer();
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public:
|
|||
|
||||
// stores a "named" timer instance to be reused via multiple LLFastTimer stack instances
|
||||
class LL_COMMON_API NamedTimer
|
||||
: public LLInstanceTracker<NamedTimer>
|
||||
: public LLInstanceTracker<NamedTimer, InstanceTrackType_NamedTimer >
|
||||
{
|
||||
friend class DeclareTimer;
|
||||
public:
|
||||
|
|
@ -137,10 +137,11 @@ public:
|
|||
|
||||
// used to statically declare a new named timer
|
||||
class LL_COMMON_API DeclareTimer
|
||||
: public LLInstanceTracker<DeclareTimer>
|
||||
: public LLInstanceTracker< DeclareTimer, InstanceTrackType_DeclareTimer >
|
||||
{
|
||||
friend class LLFastTimer;
|
||||
public:
|
||||
|
||||
DeclareTimer(const std::string& name, bool open);
|
||||
DeclareTimer(const std::string& name);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,18 +32,14 @@
|
|||
// external library headers
|
||||
// other Linden headers
|
||||
|
||||
//static
|
||||
void * & LLInstanceTrackerBase::getInstances(std::type_info const & info)
|
||||
{
|
||||
typedef std::map<std::string, void *> InstancesMap;
|
||||
static InstancesMap instances;
|
||||
static void* sInstanceTrackerData[ kInstanceTrackTypeCount ] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
void * & LLInstanceTrackerBase::getInstances(InstanceTrackType t)
|
||||
{
|
||||
// std::map::insert() is just what we want here. You attempt to insert a
|
||||
// (key, value) pair. If the specified key doesn't yet exist, it inserts
|
||||
// the pair and returns a std::pair of (iterator, true). If the specified
|
||||
// key DOES exist, insert() simply returns (iterator, false). One lookup
|
||||
// handles both cases.
|
||||
return instances.insert(InstancesMap::value_type(info.name(),
|
||||
InstancesMap::mapped_type()))
|
||||
.first->second;
|
||||
}
|
||||
return sInstanceTrackerData[t];
|
||||
}
|
||||
|
|
@ -38,6 +38,31 @@
|
|||
#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,
|
||||
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 +72,15 @@ class LL_COMMON_API LLInstanceTrackerBase : public boost::noncopyable
|
|||
{
|
||||
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 +104,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:
|
||||
|
|
@ -226,16 +252,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:
|
||||
|
|
|
|||
|
|
@ -29,9 +29,10 @@
|
|||
* LLLeap* pointer should be validated before use by
|
||||
* LLLeap::getInstance(LLLeap*) (see LLInstanceTracker).
|
||||
*/
|
||||
class LL_COMMON_API LLLeap: public LLInstanceTracker<LLLeap>
|
||||
class LL_COMMON_API LLLeap: public INSTANCE_TRACKER(LLLeap)
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Pass a brief string description, mostly for logging purposes. The desc
|
||||
* need not be unique, but obviously the clearer we can make it, the
|
||||
|
|
|
|||
|
|
@ -350,10 +350,10 @@ public:
|
|||
Generic pooling scheme for things which use GL names (used for occlusion queries and vertex buffer objects).
|
||||
Prevents thrashing of GL name caches by avoiding calls to glGenFoo and glDeleteFoo.
|
||||
*/
|
||||
class LLGLNamePool : public LLInstanceTracker<LLGLNamePool>
|
||||
class LLGLNamePool : public INSTANCE_TRACKER(LLGLNamePool)
|
||||
{
|
||||
public:
|
||||
typedef LLInstanceTracker<LLGLNamePool> tracker_t;
|
||||
typedef INSTANCE_TRACKER(LLGLNamePool) tracker_t;
|
||||
|
||||
struct NameEntry
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,9 +34,10 @@
|
|||
|
||||
class LLSD;
|
||||
|
||||
class LLConsole : public LLFixedBuffer, public LLUICtrl, public LLInstanceTracker<LLConsole>
|
||||
class LLConsole : public LLFixedBuffer, public LLUICtrl, public INSTANCE_TRACKER(LLConsole)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef enum e_font_size
|
||||
{
|
||||
MONOSPACE = -1,
|
||||
|
|
|
|||
|
|
@ -112,15 +112,18 @@ struct LLCoordFloater : LLCoord<LL_COORD_FLOATER>
|
|||
bool operator!=(const LLCoordFloater& other) const { return !(*this == other); }
|
||||
|
||||
void setFloater(LLFloater& floater);
|
||||
|
||||
|
||||
};
|
||||
|
||||
class LLFloater : public LLPanel, public LLInstanceTracker<LLFloater>
|
||||
class LLFloater : public LLPanel, public INSTANCE_TRACKER(LLFloater)
|
||||
{
|
||||
friend class LLFloaterView;
|
||||
friend class LLFloaterReg;
|
||||
friend class LLMultiFloater;
|
||||
|
||||
public:
|
||||
|
||||
struct KeyCompare
|
||||
{
|
||||
// static bool compare(const LLSD& a, const LLSD& b);
|
||||
|
|
|
|||
|
|
@ -34,9 +34,10 @@
|
|||
class LLLayoutPanel;
|
||||
|
||||
|
||||
class LLLayoutStack : public LLView, public LLInstanceTracker<LLLayoutStack>
|
||||
class LLLayoutStack : public LLView, public INSTANCE_TRACKER(LLLayoutStack)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef enum e_layout_orientation
|
||||
{
|
||||
HORIZONTAL,
|
||||
|
|
|
|||
|
|
@ -136,10 +136,11 @@ typedef LLFunctorRegistration<LLNotificationResponder> LLNotificationFunctorRegi
|
|||
|
||||
// context data that can be looked up via a notification's payload by the display logic
|
||||
// derive from this class to implement specific contexts
|
||||
class LLNotificationContext : public LLInstanceTracker<LLNotificationContext, LLUUID>
|
||||
class LLNotificationContext : public INSTANCE_TRACKER_KEYED(LLNotificationContext, LLUUID)
|
||||
{
|
||||
public:
|
||||
LLNotificationContext() : LLInstanceTracker<LLNotificationContext, LLUUID>(LLUUID::generateNewID())
|
||||
|
||||
LLNotificationContext() : INSTANCE_TRACKER_KEYED(LLNotificationContext, LLUUID)(LLUUID::generateNewID())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,9 +39,10 @@ class LLWindowCallbacks;
|
|||
|
||||
// Refer to llwindow_test in test/common/llwindow for usage example
|
||||
|
||||
class LLWindow : public LLInstanceTracker<LLWindow>
|
||||
class LLWindow : public INSTANCE_TRACKER(LLWindow)
|
||||
{
|
||||
public:
|
||||
|
||||
struct LLWindowResolution
|
||||
{
|
||||
S32 mWidth;
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ LLPointer<LLControlVariable> LLControlGroup::getControl(const std::string& name)
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LLControlGroup::LLControlGroup(const std::string& name)
|
||||
: LLInstanceTracker<LLControlGroup, std::string>(name)
|
||||
: INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name)
|
||||
{
|
||||
mTypeString[TYPE_U32] = "U32";
|
||||
mTypeString[TYPE_S32] = "S32";
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ T convert_from_llsd(const LLSD& sd, eControlType type, const std::string& contro
|
|||
}
|
||||
|
||||
//const U32 STRING_CACHE_SIZE = 10000;
|
||||
class LLControlGroup : public LLInstanceTracker<LLControlGroup, std::string>
|
||||
class LLControlGroup : public INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)
|
||||
{
|
||||
LOG_CLASS(LLControlGroup);
|
||||
|
||||
|
|
@ -197,7 +197,7 @@ public:
|
|||
~LLControlGroup();
|
||||
void cleanup();
|
||||
|
||||
typedef LLInstanceTracker<LLControlGroup, std::string>::instance_iter instance_iter;
|
||||
typedef INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)::instance_iter instance_iter;
|
||||
|
||||
LLControlVariablePtr getControl(const std::string& name);
|
||||
|
||||
|
|
@ -306,7 +306,7 @@ public:
|
|||
//! without have to manually create and bind a listener to a local
|
||||
//! object.
|
||||
template <class T>
|
||||
class LLControlCache : public LLRefCount, public LLInstanceTracker<LLControlCache<T>, std::string>
|
||||
class LLControlCache : public LLRefCount, public LLInstanceTracker<LLControlCache<T>, InstanceTrackType_LLControlCache, std::string>
|
||||
{
|
||||
public:
|
||||
// This constructor will declare a control if it doesn't exist in the contol group
|
||||
|
|
@ -314,7 +314,7 @@ public:
|
|||
const std::string& name,
|
||||
const T& default_value,
|
||||
const std::string& comment)
|
||||
: LLInstanceTracker<LLControlCache<T>, std::string >(name)
|
||||
: LLInstanceTracker<LLControlCache<T>, InstanceTrackType_LLControlCache, std::string >(name)
|
||||
{
|
||||
if(!group.controlExists(name))
|
||||
{
|
||||
|
|
@ -329,7 +329,7 @@ public:
|
|||
|
||||
LLControlCache(LLControlGroup& group,
|
||||
const std::string& name)
|
||||
: LLInstanceTracker<LLControlCache<T>, std::string >(name)
|
||||
: LLInstanceTracker<LLControlCache<T>, InstanceTrackType_LLControlCache, std::string >(name)
|
||||
{
|
||||
if(!group.controlExists(name))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -577,6 +577,12 @@ F32 LLDrawable::updateXform(BOOL undamped)
|
|||
mVObjp->dirtySpatialGroup();
|
||||
}
|
||||
}
|
||||
else if (!isRoot()
|
||||
&& ( dist_vec_squared(old_pos, target_pos) > 0.f
|
||||
|| (1.f - dot(old_rot, target_rot)) > 0.f))
|
||||
{ // update child prims moved from LSL
|
||||
gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE);
|
||||
}
|
||||
else if (!getVOVolume() && !isAvatar())
|
||||
{
|
||||
movePartition();
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ LLFloaterWebContent::_Params::_Params()
|
|||
|
||||
LLFloaterWebContent::LLFloaterWebContent( const Params& params )
|
||||
: LLFloater( params ),
|
||||
LLInstanceTracker<LLFloaterWebContent, std::string>(params.id()),
|
||||
INSTANCE_TRACKER_KEYED(LLFloaterWebContent, std::string)(params.id()),
|
||||
mWebBrowser(NULL),
|
||||
mAddressCombo(NULL),
|
||||
mSecureLockIcon(NULL),
|
||||
|
|
|
|||
|
|
@ -40,10 +40,11 @@ class LLIconCtrl;
|
|||
class LLFloaterWebContent :
|
||||
public LLFloater,
|
||||
public LLViewerMediaObserver,
|
||||
public LLInstanceTracker<LLFloaterWebContent, std::string>
|
||||
public INSTANCE_TRACKER_KEYED(LLFloaterWebContent, std::string)
|
||||
{
|
||||
public:
|
||||
typedef LLInstanceTracker<LLFloaterWebContent, std::string> instance_tracker_t;
|
||||
|
||||
typedef INSTANCE_TRACKER_KEYED(LLFloaterWebContent, std::string) instance_tracker_t;
|
||||
LOG_CLASS(LLFloaterWebContent);
|
||||
|
||||
struct _Params : public LLInitParam::Block<_Params>
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ LLMediaCtrl::Params::Params()
|
|||
|
||||
LLMediaCtrl::LLMediaCtrl( const Params& p) :
|
||||
LLPanel( p ),
|
||||
LLInstanceTracker<LLMediaCtrl, LLUUID>(LLUUID::generateNewID()),
|
||||
INSTANCE_TRACKER_KEYED(LLMediaCtrl, LLUUID)(LLUUID::generateNewID()),
|
||||
mTextureDepthBytes( 4 ),
|
||||
mBorder(NULL),
|
||||
mFrequentUpdates( true ),
|
||||
|
|
|
|||
|
|
@ -42,10 +42,11 @@ class LLMediaCtrl :
|
|||
public LLPanel,
|
||||
public LLViewerMediaObserver,
|
||||
public LLViewerMediaEventEmitter,
|
||||
public LLInstanceTracker<LLMediaCtrl, LLUUID>
|
||||
public INSTANCE_TRACKER_KEYED(LLMediaCtrl, LLUUID)
|
||||
{
|
||||
LOG_CLASS(LLMediaCtrl);
|
||||
public:
|
||||
|
||||
struct Params : public LLInitParam::Block<Params, LLPanel::Params>
|
||||
{
|
||||
Optional<std::string> start_url;
|
||||
|
|
|
|||
|
|
@ -64,9 +64,10 @@ private:
|
|||
|
||||
|
||||
class LLNameListCtrl
|
||||
: public LLScrollListCtrl, public LLInstanceTracker<LLNameListCtrl>
|
||||
: public LLScrollListCtrl, public INSTANCE_TRACKER(LLNameListCtrl)
|
||||
{
|
||||
public:
|
||||
|
||||
typedef enum e_name_type
|
||||
{
|
||||
INDIVIDUAL,
|
||||
|
|
|
|||
|
|
@ -572,7 +572,7 @@ S32 LLToast::notifyParent(const LLSD& info)
|
|||
//static
|
||||
void LLToast::updateClass()
|
||||
{
|
||||
for (LLInstanceTracker<LLToast>::instance_iter iter = LLInstanceTracker<LLToast>::beginInstances(); iter != LLInstanceTracker<LLToast>::endInstances(); )
|
||||
for (INSTANCE_TRACKER(LLToast)::instance_iter iter = INSTANCE_TRACKER(LLToast)::beginInstances(); iter != INSTANCE_TRACKER(LLToast)::endInstances(); )
|
||||
{
|
||||
LLToast& toast = *iter++;
|
||||
|
||||
|
|
|
|||
|
|
@ -69,10 +69,11 @@ private :
|
|||
* Represents toast pop-up.
|
||||
* This is a parent view for all toast panels.
|
||||
*/
|
||||
class LLToast : public LLModalDialog, public LLInstanceTracker<LLToast>
|
||||
class LLToast : public LLModalDialog, public INSTANCE_TRACKER(LLToast)
|
||||
{
|
||||
friend class LLToastLifeTimer;
|
||||
public:
|
||||
|
||||
typedef boost::function<void (LLToast* toast)> toast_callback_t;
|
||||
typedef boost::signals2::signal<void (LLToast* toast)> toast_signal_t;
|
||||
typedef boost::signals2::signal<void (LLToast* toast, bool mouse_enter)> toast_hover_check_signal_t;
|
||||
|
|
|
|||
Loading…
Reference in New Issue