utilities: Remove ScopedArray implementation

It's now unused.
This commit is contained in:
Jonathan Li 2015-12-23 12:53:54 +00:00
parent e7ca031d1e
commit 3c7e45ccc8
1 changed files with 0 additions and 115 deletions

View File

@ -140,121 +140,6 @@ public:
}
};
// --------------------------------------------------------------------------------------
// ScopedArray - same as ScopedPtr but uses delete[], and has operator[]
// --------------------------------------------------------------------------------------
template< typename T >
class ScopedArray
{
DeclareNoncopyableObject(ScopedArray);
protected:
T* m_array;
uint m_valid_range;
public:
typedef T element_type;
wxEXPLICIT ScopedArray(T * ptr = NULL)
{
m_array = ptr;
m_valid_range = 0xffffffff;
}
wxEXPLICIT ScopedArray( size_t size )
{
m_array = new T[size];
m_valid_range = size;
}
~ScopedArray() throw()
{ Delete(); }
ScopedArray& Reassign(T * ptr = NULL)
{
if( ptr != m_array )
{
Delete();
m_array = ptr;
m_valid_range = 0xffffffff;
}
return *this;
}
ScopedArray& Delete() throw()
{
// Thread-safe deletion: Set the pointer to NULL first, and then issue
// the deletion. This allows pending Application messages that might be
// dependent on the current object to nullify their actions.
T* deleteme = m_array;
m_array = NULL;
delete[] deleteme;
return *this;
}
// Removes the pointer from scoped management, but does not delete!
T *DetachPtr()
{
T *ptr = m_array;
m_array = NULL;
return ptr;
}
// Returns the managed pointer. Can return NULL as a valid result if the ScopedPtr
// has no object in management.
T* GetPtr() const
{
return m_array;
}
void SwapPtr(ScopedArray& other)
{
T * const tmp = other.m_array;
other.m_array = m_array;
m_array = tmp;
}
// ----------------------------------------------------------------------------
// ScopedPtr Operators
// ----------------------------------------------------------------------------
// I've decided to use the ATL's approach to pointer validity tests, opposed to
// the wx/boost approach (which uses some bizarre member method pointer crap, and can't
// allow the T* implicit casting.
bool operator!() const throw()
{
return m_array == NULL;
}
// Equality
bool operator==(T* pT) const throw()
{
return m_array == pT;
}
// Inequality
bool operator!=(T* pT) const throw()
{
return !operator==(pT);
}
// Convenient assignment operator. ScopedPtr = NULL will issue an automatic deletion
// of the managed pointer.
ScopedArray& operator=( T* src )
{
return Reassign( src );
}
T& operator[]( uint idx ) const
{
pxAssertDev( idx < m_valid_range, "Array index out of bounds on ScopedArray." );
return m_array[idx];
}
};
// --------------------------------------------------------------------------------------
// pxObjPtr -- fancified version of wxScopedPtr
// --------------------------------------------------------------------------------------