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

CdbBdbSRallocatorP< RT, RT_OPERATIONS_POLICY > Class Template Reference

Generic resource allocator class. More...

Inheritance diagram for CdbBdbSRallocatorP< RT, RT_OPERATIONS_POLICY >:

BdbPersObj List of all members.

Public Member Functions

 CdbBdbSRallocatorP ()
 Default constructor.

virtual ~CdbBdbSRallocatorP ()
 Destructor.

virtual CdbStatus isAllocated (const RT &theResource) const
 Check allocation of specified resource.

virtual CdbStatus force (const RT &theResource)
 Force allocation of specified resource.

virtual CdbStatus allocate (RT &theResource)
 Allocate a resource.

virtual CdbStatus release (const RT &theResource)
 Release specified resource.

virtual CdbItr< RT > iterator () const
 Get an instance of an iterator for allocated resources.

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


Detailed Description

template<class RT, class RT_OPERATIONS_POLICY = CdbBdbSRaDefaultPolicy<RT>>
class CdbBdbSRallocatorP< RT, RT_OPERATIONS_POLICY >

Generic resource allocator class.

This persistent class represents "resource allocator", whose primary focus (although not limited to) is at various sorts of identifiers. This facility is capable of managing individual values (not ranges) of resources.

The class has the following template parameters:

RT: the type of the managed resource. This class is expected to provide the following public interface:

Basically, it's the same interface, which is required to put objects of the RT type into a B-tree.

RT_OPERATIONS_POLICY: an optional policy for the RT type. The role of this policy is to supply an appropriate abstraction for the following operations:

IMPORTANT: It's assumed that when the iterated value will reach its maximum available state then the iterator will switch back to the minimum state as defined above.

IMPORTANT: The "Resource Allocator" neither assumes an existence nor relies at any internal state the RT_OPERATIONS_POLICY class may have. It means that the methods of a concrete policy classs supplied through this template parameter can be invoked at any sequence and they will always provide repeatable results for the same values of their input parameters.

See the interface of the default RT_OPERATIONS_POLICY class as a specification for the interface of user-defined policy classes.

This class also provides default version of the RT_OPERATIONS_POLICY class, which is sufficient enough for most primitive ("countable") data types like: d_ULong, d_UShort, etc. The default implementation of the RT_OPERATIONS_POLICY relies on the following:

The abstract user defined types require proper policy class to be supplied along with RT type to override the default policy unless the RT type has sufficient (both formally and semantically) public interface meeting the requirements of the default implementation for OPERATIONS.

Definition at line 98 of file CdbBdbSRallocatorP.ddl.


Constructor & Destructor Documentation

template<class RT, class RT_OPERATIONS_POLICY>
CdbBdbSRallocatorP< RT, RT_OPERATIONS_POLICY >::CdbBdbSRallocatorP  
 

Default constructor.

Initializes an empty collectiuon

Definition at line 21 of file CdbBdbSRallocatorP.cc.

template<class RT, class RT_OPERATIONS_POLICY>
CdbBdbSRallocatorP< RT, RT_OPERATIONS_POLICY >::~CdbBdbSRallocatorP   [virtual]
 

Destructor.

Will also destroy all the elements.

Definition at line 35 of file CdbBdbSRallocatorP.cc.


Member Function Documentation

template<class RT, class RT_OPERATIONS_POLICY>
CdbStatus CdbBdbSRallocatorP< RT, RT_OPERATIONS_POLICY >::allocate RT &    theResource [virtual]
 

Allocate a resource.

The method will return:

  • "Success" if a resource has been allocated
  • "NotFound" if a resource could not be allocated

Definition at line 55 of file CdbBdbSRallocatorP.cc.

References CdbItr< T >::next(), CdbStatus::NotFound, CdbStatus::Success, and CdbItr< T >::value().

template<class RT, class RT_OPERATIONS_POLICY>
void CdbBdbSRallocatorP< RT, RT_OPERATIONS_POLICY >::dump std::ostream &    o const [virtual]
 

Dump the contents of the object.

Definition at line 155 of file CdbBdbSRallocatorP.cc.

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

template<class RT, class RT_OPERATIONS_POLICY>
CdbStatus CdbBdbSRallocatorP< RT, RT_OPERATIONS_POLICY >::force const RT &    theResource [virtual]
 

Force allocation of specified resource.

The method makes sure that specified resource, whose value passed to the procedure gets allocated. The passed resource can already be allocated.

The method will return:

  • "Success" if specified resource already was or just has been allocated
  • "Error" if specified resource is not "valid" (see RT_OPERATIONS_POLICY::valid() method for the explanation) or in case of any other internal problem

Definition at line 97 of file CdbBdbSRallocatorP.cc.

References CdbBdbSRallocatorP< RT, RT_OPERATIONS_POLICY >::isAllocated(), CdbStatus::NotFound, and CdbStatus::Success.

template<class RT, class RT_OPERATIONS_POLICY>
CdbStatus CdbBdbSRallocatorP< RT, RT_OPERATIONS_POLICY >::isAllocated const RT &    theResource const [virtual]
 

Check allocation of specified resource.

The method will return:

  • "Success" if specified resource is allocated
  • "NotFound" if specified resource is not allocated
  • "Error" if specified resource is not "valid" (see RT_OPERATIONS_POLICY::valid() method for the explanation) or in case of any other internal problem

Definition at line 44 of file CdbBdbSRallocatorP.cc.

References CdbStatus::Error, CdbStatus::NotFound, and CdbStatus::Success.

Referenced by CdbBdbSRallocatorP< RT, RT_OPERATIONS_POLICY >::force(), and CdbBdbSRallocatorP< RT, RT_OPERATIONS_POLICY >::release().

template<class RT, class RT_OPERATIONS_POLICY>
CdbItr< RT > CdbBdbSRallocatorP< RT, RT_OPERATIONS_POLICY >::iterator   const [virtual]
 

Get an instance of an iterator for allocated resources.

This kind of iterator provides "non-sorted" access to the values of allocated resources.

Definition at line 147 of file CdbBdbSRallocatorP.cc.

template<class RT, class RT_OPERATIONS_POLICY>
CdbStatus CdbBdbSRallocatorP< RT, RT_OPERATIONS_POLICY >::release const RT &    theResource [virtual]
 

Release specified resource.

The method will return:

  • "Success" if specified resource was released
  • "NotFound" if specified resource was never allocated
  • "Error" if specified resource is not "valid" (see RT_OPERATIONS_POLICY::valid() method for the explanation) or in case of any other internal problem

Definition at line 132 of file CdbBdbSRallocatorP.cc.

References CdbBdbSRallocatorP< RT, RT_OPERATIONS_POLICY >::isAllocated(), and CdbStatus::Success.


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