summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorSteven Bennetts <steve@lindenlab.com>2008-02-19 21:42:32 +0000
committerSteven Bennetts <steve@lindenlab.com>2008-02-19 21:42:32 +0000
commit2e32d44e7165775936beae5d9ef636ff9d3f2bd2 (patch)
tree8153bc399994aabf6e1c41c2d8332e4e8c4ddb78 /indra/llcommon
parentdb0f5847ea8b96b3c1ac08e7aeb43d83daacb8e4 (diff)
merge svn+ssh://svn.lindenlab.com/svn/linden/qa/combo-merge-ui-2008-02-13 -r 79986 : 80178 -> release.
QAR-290 = QAR-271 + QAR-191
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/linden_common.h6
-rw-r--r--indra/llcommon/llmemory.h50
2 files changed, 38 insertions, 18 deletions
diff --git a/indra/llcommon/linden_common.h b/indra/llcommon/linden_common.h
index 39ee014241..504552a9d2 100644
--- a/indra/llcommon/linden_common.h
+++ b/indra/llcommon/linden_common.h
@@ -58,6 +58,12 @@
#ifdef LL_WINDOWS
#pragma warning (3 : 4702) // we like level 3, not 4
+// level 4 warnings that we need to disable:
+#pragma warning (disable : 4100) // unreferenced formal parameter
+#pragma warning (disable : 4127) // conditional expression is constant (e.g. while(1) )
+#pragma warning (disable : 4244) // possible loss of data on conversions
+#pragma warning (disable : 4512) // assignment operator could not be generated
+#pragma warning (disable : 4706) // assignment within conditional (even if((x = y)) )
#endif // LL_WINDOWS
// Linden only libs in alpha-order other than stdtypes.h
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index b72046c104..b0a47b6820 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -243,25 +243,25 @@ protected:
// Expands LLPointer to return a pointer to a special instance of class Type instead of NULL.
// This is useful in instances where operations on NULL pointers are semantically safe and/or
// when error checking occurs at a different granularity or in a different part of the code
-// than when referencing an object via a LLHandle.
+// than when referencing an object via a LLSafeHandle.
//
template <class Type>
-class LLHandle
+class LLSafeHandle
{
public:
- LLHandle() :
+ LLSafeHandle() :
mPointer(NULL)
{
}
- LLHandle(Type* ptr) :
+ LLSafeHandle(Type* ptr) :
mPointer(NULL)
{
assign(ptr);
}
- LLHandle(const LLHandle<Type>& ptr) :
+ LLSafeHandle(const LLSafeHandle<Type>& ptr) :
mPointer(NULL)
{
assign(ptr.mPointer);
@@ -269,13 +269,13 @@ public:
// support conversion up the type hierarchy. See Item 45 in Effective C++, 3rd Ed.
template<typename Subclass>
- LLHandle(const LLHandle<Subclass>& ptr) :
+ LLSafeHandle(const LLSafeHandle<Subclass>& ptr) :
mPointer(NULL)
{
assign(ptr.get());
}
- ~LLHandle()
+ ~LLSafeHandle()
{
unref();
}
@@ -300,17 +300,17 @@ public:
operator const Type*() const { return mPointer; }
bool operator !=(Type* ptr) const { return (mPointer != ptr); }
bool operator ==(Type* ptr) const { return (mPointer == ptr); }
- bool operator ==(const LLHandle<Type>& ptr) const { return (mPointer == ptr.mPointer); }
- bool operator < (const LLHandle<Type>& ptr) const { return (mPointer < ptr.mPointer); }
- bool operator > (const LLHandle<Type>& ptr) const { return (mPointer > ptr.mPointer); }
+ bool operator ==(const LLSafeHandle<Type>& ptr) const { return (mPointer == ptr.mPointer); }
+ bool operator < (const LLSafeHandle<Type>& ptr) const { return (mPointer < ptr.mPointer); }
+ bool operator > (const LLSafeHandle<Type>& ptr) const { return (mPointer > ptr.mPointer); }
- LLHandle<Type>& operator =(Type* ptr)
+ LLSafeHandle<Type>& operator =(Type* ptr)
{
assign(ptr);
return *this;
}
- LLHandle<Type>& operator =(const LLHandle<Type>& ptr)
+ LLSafeHandle<Type>& operator =(const LLSafeHandle<Type>& ptr)
{
assign(ptr.mPointer);
return *this;
@@ -318,7 +318,7 @@ public:
// support assignment up the type hierarchy. See Item 45 in Effective C++, 3rd Ed.
template<typename Subclass>
- LLHandle<Type>& operator =(const LLHandle<Subclass>& ptr)
+ LLSafeHandle<Type>& operator =(const LLSafeHandle<Subclass>& ptr)
{
assign(ptr.get());
return *this;
@@ -399,11 +399,25 @@ protected:
//----------------------------------------------------------------------------
-// LLSingleton implements the getInstance() method part of the Singleton pattern. It can't make
-// the derived class constructors protected, though, so you have to do that yourself.
-// The proper way to use LLSingleton is to inherit from it while using the typename that you'd
-// like to be static as the template parameter, like so:
-// class FooBar: public LLSingleton<FooBar>
+// LLSingleton implements the getInstance() method part of the Singleton
+// pattern. It can't make the derived class constructors protected, though, so
+// you have to do that yourself.
+//
+// There are two ways to use LLSingleton. The first way is to inherit from it
+// while using the typename that you'd like to be static as the template
+// parameter, like so:
+//
+// class Foo: public LLSingleton<Foo>{};
+//
+// Foo* instance = Foo::getInstance();
+//
+// The second way is to define a seperate class that exposes the singleton
+// interface:
+//
+// class FooSingleton: public LLSingleton<Foo>{};
+//
+// Foo* instance = FooSingleton::getInstance();
+//
// As currently written, it is not thread-safe.
template <typename T>
class LLSingleton