Gaudi Framework, version v23r5

Home   Generated: Wed Nov 28 2012
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
KeyedObject< KEY > Class Template Reference

Definition of the templated KeyedObject class. More...

#include <KeyedObject.h>

Inheritance diagram for KeyedObject< KEY >:
Inheritance graph
[legend]
Collaboration diagram for KeyedObject< KEY >:
Collaboration graph
[legend]

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_typekey () 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 StreamBufferserialize (StreamBuffer &s) const
 Serialize the object for writing.
 
virtual StreamBufferserialize (StreamBuffer &s)
 Serialize the object for reading.
 
- Public Member Functions inherited from ContainedObject
virtual const CLIDclID () const
 Retrieve pointer to class identifier.
 
const ObjectContainerBaseparent () const
 Access to parent object.
 
void setParent (ObjectContainerBase *value)
 Update parent member.
 
virtual std::ostreamfillStream (std::ostream &s) const
 Fill the output stream (ASCII)
 

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 Member Functions inherited from ContainedObject
 ContainedObject ()
 Constructors.
 
 ContainedObject (const ContainedObject &)
 Copy constructor.
 
virtual ~ContainedObject ()
 Destructor.
 

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 &copy)
 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.
 

Additional Inherited Members

- Static Public Member Functions inherited from ContainedObject
static const CLIDclassID ()
 

Detailed Description

template<class KEY>
class KeyedObject< KEY >

Definition of the templated KeyedObject class.

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.

Author
M.Frank CERN/LHCb
Version
1.0

Definition at line 28 of file KeyedObject.h.

Member Typedef Documentation

template<class KEY >
typedef KEY KeyedObject< KEY >::key_type

Definition of the key-type to access object.

Definition at line 32 of file KeyedObject.h.

template<class KEY >
typedef Containers::key_traits<key_type> KeyedObject< KEY >::traits
protected

definition of the container key traits to be made friend

Definition at line 36 of file KeyedObject.h.

Constructor & Destructor Documentation

template<class KEY >
KeyedObject< KEY >::KeyedObject ( )
inline

Standard Constructor. The object key is preset to the invalid value.

Definition at line 61 of file KeyedObject.h.

: m_key(), m_refCount(0), m_hasKey(false) { }
template<class KEY >
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 65 of file KeyedObject.h.

:m_key(kval),m_refCount(0),m_hasKey(true) { }
template<class KEY >
KeyedObject< KEY >::~KeyedObject ( )
inlinevirtual

Standard destructor.

Definition at line 91 of file KeyedObject.h.

{
if ( p ) {
p->remove(this);
}
}
template<class KEY >
KeyedObject< KEY >::KeyedObject ( const KeyedObject< KEY > &  copy)
inlineprivate

NOBODY may copy these objects.

Definition at line 79 of file KeyedObject.h.

: ContainedObject(copy) { }

Member Function Documentation

template<class KEY >
unsigned long KeyedObject< KEY >::addRef ( )
inlineprotected

Add reference to object (Increase reference counter).

Definition at line 102 of file KeyedObject.h.

{
return ++m_refCount;
}
template<class KEY >
bool KeyedObject< KEY >::hasKey ( ) const
inline

Check if the object has a key assigned or not.

Definition at line 71 of file KeyedObject.h.

{ return m_hasKey; }
template<class KEY >
virtual long KeyedObject< KEY >::index ( ) const
inlinevirtual

Distance in the parent container.

Reimplemented from ContainedObject.

Definition at line 72 of file KeyedObject.h.

template<class KEY >
const key_type& KeyedObject< KEY >::key ( ) const
inline

Retrieve Key of the object.

Definition at line 69 of file KeyedObject.h.

{ return m_key; }
template<class KEY >
unsigned long KeyedObject< KEY >::release ( )
inlineprotected

Release reference. If the reference count is ZERO, delete the object.

Definition at line 108 of file KeyedObject.h.

{
long cnt = --m_refCount;
if ( cnt <= 0 ) {
delete this;
}
return cnt;
}
template<class KEY >
StreamBuffer & KeyedObject< KEY >::serialize ( StreamBuffer s) const
inlinevirtual

Serialize the object for writing.

Reimplemented from ContainedObject.

Definition at line 132 of file KeyedObject.h.

template<class KEY >
StreamBuffer & KeyedObject< KEY >::serialize ( StreamBuffer s)
inlinevirtual

Serialize the object for reading.

Reimplemented from ContainedObject.

Definition at line 138 of file KeyedObject.h.

{
long k;
m_hasKey = true;
return s;
}
template<class KEY >
void KeyedObject< KEY >::setKey ( const key_type key)
inlineprotected

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 121 of file KeyedObject.h.

{
if ( !m_hasKey ) {
m_hasKey = true;
return;
}
}

Friends And Related Function Documentation

template<class KEY >
friend struct Containers::key_traits< key_type >
friend

Allow the container traits to access full object properties.

Definition at line 41 of file KeyedObject.h.

template<class KEY >
friend struct GaudiDict::KeyedObjectDict< KEY >
friend

Definition at line 29 of file KeyedObject.h.

Member Data Documentation

template<class KEY >
bool KeyedObject< KEY >::m_hasKey
protected

Boolean to indicate wether a key was already assigned.

Definition at line 49 of file KeyedObject.h.

template<class KEY >
key_type KeyedObject< KEY >::m_key
protected

Object Key; It's initial value is not determined.

Definition at line 45 of file KeyedObject.h.

template<class KEY >
long KeyedObject< KEY >::m_refCount
protected

Reference counter.

Definition at line 47 of file KeyedObject.h.


The documentation for this class was generated from the following file:

Generated at Wed Nov 28 2012 12:17:31 for Gaudi Framework, version v23r5 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004