Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

CdbBdbSCollectionP Class Reference

Persistent collection class. More...

Inheritance diagram for CdbBdbSCollectionP:

BdbPersObj CdbBdbSOriginCollectionP CdbBdbSViewCollectionP List of all members.

Public Types

typedef CdbItr< const char * > IteratorOfNames
 Type definitions for the collection's iterators.

typedef CdbItr< d_UShort > IteratorOfIdentifiers
typedef CdbBdbSCollectionBte BTreeEntry
 B-tree and its entries types definition.

typedef CdbBdbSBtreeP< BTreeEntryBTreeP

Public Member Functions

 CdbBdbSCollectionP (bool useIdFlag=true, bool useNameFlag=true)
 Default & normal constructor.

virtual ~CdbBdbSCollectionP ()
 Destructor.

bool useId () const
 Check if elements identifiers are used to sort elements in the collection.

bool useName () const
 Check if elements names are used to sort elements in the collection.

d_ULong elements () const
 get the number of elements

virtual CdbStatus insert (const BdbRef(CdbBdbSCollectionElementP)&theRef)
 Insert an element.

virtual CdbStatus find (const char *theName, BdbRef(CdbBdbSCollectionElementP)&theRef) const
 Find an object by its name.

virtual CdbStatus find (d_UShort theId, BdbRef(CdbBdbSCollectionElementP)&theRef) const
 Find an object by its identifier.

virtual CdbStatus remove (const char *theName)
 Remove an element by its name.

virtual CdbStatus remove (d_UShort theId)
 Remove an element by its name.

IteratorOfNames iterator_names () const
 Get an instance of an iterator for names.

IteratorOfIdentifiers iterator_identifiers () const
 Get an instance of an iterator for identifiers.

virtual void dump (std::ostream &o) const
 Dump the contents of the collection.


Detailed Description

Persistent collection class.

This class represents persistent "collection" of objects each having an identifier and/or a name in the scope of the collection.

Elements stored in the collection must be of the "CdbBdbSCollectionElementP" class or derive from it.

This collection is "unique" in respect to the values of the keys (names and identifiers) of stored elements.

The constructor allows to decide of either or both keys (name and identifier) of the stored elements are used. At least one key is expected.

Definition at line 37 of file CdbBdbSCollectionP.ddl.


Member Typedef Documentation

typedef CdbBdbSCollectionBte CdbBdbSCollectionP::BTreeEntry
 

B-tree and its entries types definition.

The only reason to have this definition is to avoid DDL compilation problem for the following definitions:

ooRef( template_class< another_template_class< ... > > )

NOTE: That each specialization of the B-tree has to be explicitly instantiated by a user of this class for concrete values of of the d_UShort.

Definition at line 61 of file CdbBdbSCollectionP.ddl.

Referenced by find(), and remove().

typedef CdbBdbSBtreeP< BTreeEntry > CdbBdbSCollectionP::BTreeP
 

Definition at line 62 of file CdbBdbSCollectionP.ddl.

Referenced by CdbBdbSCollectionP().

typedef CdbItr< d_UShort > CdbBdbSCollectionP::IteratorOfIdentifiers
 

Definition at line 48 of file CdbBdbSCollectionP.ddl.

Referenced by CdbBdbSSlaveRegistryP::create(), CdbBdbSOriginCollectionP::insert(), iterator_identifiers(), main(), CdbBdbSDatabase::physicalConditionIterator(), and CdbBdbSRegistryP::updateMainView().

typedef CdbItr< const char* > CdbBdbSCollectionP::IteratorOfNames
 

Type definitions for the collection's iterators.

These types are being introduced here to facilitate more flexible type parametrisation of the collection's clients (including its direct and indirect subclasses).

Definition at line 47 of file CdbBdbSCollectionP.ddl.

Referenced by iterator_names().


Constructor & Destructor Documentation

CdbBdbSCollectionP::CdbBdbSCollectionP bool    useIdFlag = true,
bool    useNameFlag = true
 

Default & normal constructor.

Initializes an empty collection. It's _REQUIRED_ that at least one of the flags passed as parameters must be true.

Parameters:
useIdFlag  tells the collection to use elements identifiers
useNameFlag  tells the collection to use elements names

Definition at line 22 of file CdbBdbSCollectionP.cc.

References BTreeP.

CdbBdbSCollectionP::~CdbBdbSCollectionP   [virtual]
 

Destructor.

Will also destroy all the elements.

Definition at line 35 of file CdbBdbSCollectionP.cc.

References BdbRef(), CdbItr< T >::next(), and CdbItr< T >::value().


Member Function Documentation

void CdbBdbSCollectionP::dump std::ostream &    o const [virtual]
 

Dump the contents of the collection.

Definition at line 366 of file CdbBdbSCollectionP.cc.

References BdbRef(), elements(), find(), iterator_identifiers(), iterator_names(), CdbItr< d_UShort >::next(), CdbItr< const char * >::next(), CdbStatus::Success, useId(), useName(), CdbItr< d_UShort >::value(), and CdbItr< const char * >::value().

d_ULong CdbBdbSCollectionP::elements   const
 

get the number of elements

Definition at line 82 of file CdbBdbSCollectionP.cc.

Referenced by dump().

CdbStatus CdbBdbSCollectionP::find d_UShort    theId,
BdbRef(CdbBdbSCollectionElementP)&    theRef
const [virtual]
 

Find an object by its identifier.

The method will return CdbStatus::NotFound if the condition was not found in the folder. Other possible completion statuses are as usual.

Parameters:
theId  the object's identifier
theRef  the reference to be initialized upon successfull completion

Definition at line 220 of file CdbBdbSCollectionP.cc.

References BdbRef(), BTreeEntry, CdbStatus::Error, CdbStatus::NotFound, CdbStatus::Success, and useId().

CdbStatus CdbBdbSCollectionP::find const char *    theName,
BdbRef(CdbBdbSCollectionElementP)&    theRef
const [virtual]
 

Find an object by its name.

This method does not return the element's ownership

The method will return CdbStatus::NotFound if the object was not found in the folder. Other possible completion statuses are as usual.

Parameters:
theName  the object's name in the collection's scope
theRef  the reference to be initialized upon successfull completion

Definition at line 159 of file CdbBdbSCollectionP.cc.

References BdbRef(), CdbStatus::Error, CdbStatus::NotFound, CdbStatus::Success, and useName().

Referenced by dump(), CdbBdbSOriginCollectionP::insert(), and remove().

CdbStatus CdbBdbSCollectionP::insert const BdbRef(CdbBdbSCollectionElementP)&    theRef [virtual]
 

Insert an element.

Both the element's name and its identifier are obtained from the element. They both must be unique in the collection's scope.

The collections taks over the ownership of the stored elements.

Parameters:
theRef  the object to insert

Reimplemented in CdbBdbSOriginCollectionP, and CdbBdbSViewCollectionP.

Definition at line 88 of file CdbBdbSCollectionP.cc.

References CdbStatus::Error, CdbBdbSCollectionElementP::id(), CdbBdbSCollectionBte::key, CdbStatus::Success, useId(), and useName().

Referenced by CdbBdbSViewCollectionP::insert(), and CdbBdbSOriginCollectionP::insert().

CdbBdbSCollectionP::IteratorOfIdentifiers CdbBdbSCollectionP::iterator_identifiers   const
 

Get an instance of an iterator for identifiers.

This kind of iterator provides "non-sorted" access to the keys.

Definition at line 349 of file CdbBdbSCollectionP.cc.

References IteratorOfIdentifiers, and useId().

Referenced by dump(), and CdbBdbSOriginCollectionP::insert().

CdbBdbSCollectionP::IteratorOfNames CdbBdbSCollectionP::iterator_names   const
 

Get an instance of an iterator for names.

This kind of iterator provides "non-sorted" access to the keys.

Definition at line 333 of file CdbBdbSCollectionP.cc.

References IteratorOfNames, and useName().

Referenced by dump().

CdbStatus CdbBdbSCollectionP::remove d_UShort    theId [virtual]
 

Remove an element by its name.

The found element will be also destroyed.

The method will return CdbStatus::NotFound if the object was not found in the folder. Other possible completion statuses are as usual.

Parameters:
theId  the object's identifier

Definition at line 303 of file CdbBdbSCollectionP.cc.

References BdbRef(), BTreeEntry, CdbStatus::Error, find(), CdbStatus::Success, useId(), and useName().

CdbStatus CdbBdbSCollectionP::remove const char *    theName [virtual]
 

Remove an element by its name.

The found element will be also destroyed.

The method will return CdbStatus::NotFound if the object was not found in the folder. Other possible completion statuses are as usual.

Parameters:
theName  the object's name in the collection's scope

Definition at line 273 of file CdbBdbSCollectionP.cc.

References BdbRef(), BTreeEntry, CdbStatus::Error, find(), CdbStatus::Success, useId(), and useName().

bool CdbBdbSCollectionP::useId   const
 

Check if elements identifiers are used to sort elements in the collection.

Definition at line 70 of file CdbBdbSCollectionP.cc.

Referenced by dump(), find(), insert(), iterator_identifiers(), and remove().

bool CdbBdbSCollectionP::useName   const
 

Check if elements names are used to sort elements in the collection.

Definition at line 76 of file CdbBdbSCollectionP.cc.

Referenced by dump(), find(), insert(), iterator_names(), and remove().


The documentation for this class was generated from the following files:
Generated on Mon Dec 5 18:22:19 2005 for CDB by doxygen1.3-rc3