#include <KeyedObject.h>
Inheritance diagram for KeyedObject< KEY >:
Public Types | |
typedef KEY | key_type |
Definition of the key-type to access object. | |
Public Member Functions | |
KeyedObject () | |
Standard Constructor. The object key is preset to the invalid value. | |
KeyedObject (const key_type &kval) | |
Standard Constructor accepting the object's key. | |
virtual | ~KeyedObject () |
Standard destructor. | |
const key_type & | key () const |
Retrieve Key of the object. | |
bool | hasKey () const |
Check if the object has a key assigned or not. | |
virtual long | index () const |
Distance in the parent container. | |
virtual StreamBuffer & | serialize (StreamBuffer &s) const |
Serialize the object for writing. | |
virtual StreamBuffer & | serialize (StreamBuffer &s) |
Serialize the object for reading. | |
virtual const CLID & | clID () const |
Retrieve pointer to class identifier. | |
const ObjectContainerBase * | parent () const |
Access to parent object. | |
void | setParent (ObjectContainerBase *value) |
Update parent member. | |
virtual std::ostream & | fillStream (std::ostream &s) const |
Fill the output stream (ASCII). | |
Static Public Member Functions | |
static const CLID & | classID () |
Protected Types | |
typedef Containers::key_traits< key_type > | traits |
definition of the container key traits to be made friend | |
Protected Member Functions | |
unsigned long | addRef () |
Add reference to object (Increase reference counter). | |
unsigned long | release () |
Release reference. If the reference count is ZERO, delete the object. | |
void | setKey (const key_type &key) |
Set object key. | |
Protected Attributes | |
key_type | m_key |
Object Key; It's initial value is not determined. | |
long | m_refCount |
Reference counter. | |
bool | m_hasKey |
Boolean to indicate wether a key was already assigned. | |
Private Member Functions | |
KeyedObject (const KeyedObject ©) | |
NOBODY may copy these objects. | |
Friends | |
struct | GaudiDict::KeyedObjectDict< KEY > |
struct | Containers::key_traits< key_type > |
Allow the container traits to access full object properties. | |
std::ostream & | operator<< (std::ostream &s, const ContainedObject &obj) |
Output operator (ASCII). |
This object, which is of the basic containedObject type allows to be identified by key.
This implementation uses a reference count mechanism for insertion into multiple containers; Once the reference count is NULL, the object will automatically be deleted.
Definition at line 29 of file KeyedObject.h.
typedef KEY KeyedObject< KEY >::key_type |
typedef Containers::key_traits<key_type> KeyedObject< KEY >::traits [protected] |
definition of the container key traits to be made friend
Definition at line 37 of file KeyedObject.h.
KeyedObject< KEY >::KeyedObject | ( | ) | [inline] |
Standard Constructor. The object key is preset to the invalid value.
Definition at line 62 of file KeyedObject.h.
00062 : m_refCount(0), m_hasKey(false) { }
KeyedObject< KEY >::KeyedObject | ( | const key_type & | kval | ) | [inline] |
Standard Constructor accepting the object's key.
The key must be valid and cannot be changed later.
Definition at line 66 of file KeyedObject.h.
00066 :m_key(kval),m_refCount(0),m_hasKey(true) { }
KeyedObject< KEY >::~KeyedObject | ( | ) | [inline, virtual] |
Standard destructor.
Definition at line 92 of file KeyedObject.h.
00093 { 00094 ObjectContainerBase* p = const_cast<ObjectContainerBase*>(parent()); 00095 if ( p ) { 00096 setParent(0); 00097 p->remove(this); 00098 } 00099 }
KeyedObject< KEY >::KeyedObject | ( | const KeyedObject< KEY > & | copy | ) | [inline, private] |
NOBODY may copy these objects.
Definition at line 80 of file KeyedObject.h.
00080 : ContainedObject(copy) { }
unsigned long KeyedObject< KEY >::addRef | ( | ) | [inline, protected] |
Add reference to object (Increase reference counter).
Definition at line 103 of file KeyedObject.h.
00103 { 00104 return ++m_refCount; 00105 }
unsigned long KeyedObject< KEY >::release | ( | ) | [inline, protected] |
Release reference. If the reference count is ZERO, delete the object.
Definition at line 109 of file KeyedObject.h.
00109 { 00110 long cnt = --m_refCount; 00111 if ( cnt <= 0 ) { 00112 delete this; 00113 } 00114 return cnt; 00115 }
void KeyedObject< KEY >::setKey | ( | const key_type & | key | ) | [inline, protected] |
Set object key.
The key for consistency reasons can be set only once for the object. Any attempt to redefine the key results in an exception.
Definition at line 122 of file KeyedObject.h.
00122 { 00123 if ( !m_hasKey ) { 00124 m_key = key; 00125 m_hasKey = true; 00126 return; 00127 } 00128 Containers::cannotAssignObjectKey(); 00129 }
const key_type& KeyedObject< KEY >::key | ( | ) | const [inline] |
bool KeyedObject< KEY >::hasKey | ( | ) | const [inline] |
Check if the object has a key assigned or not.
Definition at line 72 of file KeyedObject.h.
00072 { return m_hasKey; }
virtual long KeyedObject< KEY >::index | ( | ) | const [inline, virtual] |
Distance in the parent container.
Reimplemented from ContainedObject.
Definition at line 73 of file KeyedObject.h.
00073 { return traits::identifier(m_key); }
StreamBuffer & KeyedObject< KEY >::serialize | ( | StreamBuffer & | s | ) | const [inline, virtual] |
Serialize the object for writing.
Reimplemented from ContainedObject.
Definition at line 133 of file KeyedObject.h.
00133 { 00134 return ContainedObject::serialize(s) << traits::identifier(m_key); 00135 }
StreamBuffer & KeyedObject< KEY >::serialize | ( | StreamBuffer & | s | ) | [inline, virtual] |
Serialize the object for reading.
Reimplemented from ContainedObject.
Definition at line 139 of file KeyedObject.h.
00139 { 00140 long k; 00141 ContainedObject::serialize(s) >> k; 00142 m_key = traits::makeKey(k); 00143 m_hasKey = true; 00144 return s; 00145 }
virtual const CLID& ContainedObject::clID | ( | ) | const [inline, virtual, inherited] |
Retrieve pointer to class identifier.
Definition at line 46 of file ContainedObject.h.
00046 { return ContainedObject::classID(); }
static const CLID& ContainedObject::classID | ( | ) | [inline, static, inherited] |
const ObjectContainerBase* ContainedObject::parent | ( | ) | const [inline, inherited] |
void ContainedObject::setParent | ( | ObjectContainerBase * | value | ) | [inline, inherited] |
virtual std::ostream& ContainedObject::fillStream | ( | std::ostream & | s | ) | const [inline, virtual, inherited] |
friend struct GaudiDict::KeyedObjectDict< KEY > [friend] |
Definition at line 30 of file KeyedObject.h.
friend struct Containers::key_traits< key_type > [friend] |
Allow the container traits to access full object properties.
Definition at line 42 of file KeyedObject.h.
std::ostream& operator<< | ( | std::ostream & | s, | |
const ContainedObject & | obj | |||
) | [friend, inherited] |
Output operator (ASCII).
Definition at line 66 of file ContainedObject.h.
00066 { 00067 return obj.fillStream(s); 00068 }
key_type KeyedObject< KEY >::m_key [protected] |
long KeyedObject< KEY >::m_refCount [protected] |
bool KeyedObject< KEY >::m_hasKey [protected] |