Added new template class.
git-svn-id: http://yate.null.ro/svn/yate/trunk@836 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
98bc9fd0a9
commit
c2fe403160
67
yateclass.h
67
yateclass.h
|
@ -770,6 +770,73 @@ public:
|
|||
{ return *pointer(); }
|
||||
};
|
||||
|
||||
/**
|
||||
* @short Templated pointer that can be inserted in a list
|
||||
*/
|
||||
template <class Obj = GenObject> class YATE_API GenPointer : public GenObject
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The stored pointer
|
||||
*/
|
||||
Obj* m_pointer;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Default constructor - creates a null pointer
|
||||
*/
|
||||
inline GenPointer()
|
||||
: m_pointer(0)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Copy constructor
|
||||
* @param value Original GenPointer
|
||||
*/
|
||||
inline GenPointer(const GenPointer<Obj>& value)
|
||||
: m_pointer(value)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Constructs an initialized pointer
|
||||
* @param object Pointer to object
|
||||
*/
|
||||
inline GenPointer(Obj* object)
|
||||
: m_pointer(object)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Assignment from another GenPointer
|
||||
*/
|
||||
inline GenPointer<Obj>& operator=(const GenPointer<Obj>& value)
|
||||
{ m_pointer = value; return *this; }
|
||||
|
||||
/**
|
||||
* Assignment from regular pointer
|
||||
*/
|
||||
inline GenPointer<Obj>& operator=(Obj* object)
|
||||
{ m_pointer = object; return *this; }
|
||||
|
||||
/**
|
||||
* Conversion to regular pointer operator
|
||||
* @return The stored pointer
|
||||
*/
|
||||
inline operator Obj*() const
|
||||
{ return m_pointer; }
|
||||
|
||||
/**
|
||||
* Member access operator
|
||||
*/
|
||||
inline Obj* operator->() const
|
||||
{ return m_pointer; }
|
||||
|
||||
/**
|
||||
* Dereferencing operator
|
||||
*/
|
||||
inline Obj& operator*() const
|
||||
{ return *m_pointer; }
|
||||
};
|
||||
|
||||
/**
|
||||
* A simple single-linked object list handling class
|
||||
* @short An object list class
|
||||
|
|
Loading…
Reference in New Issue