Quick Links:

bal | bbl | bdl | bsl

Classes | Public Member Functions | Friends

bdlcc::ObjectCatalog< TYPE > Class Template Reference

#include <bdlcc_objectcatalog.h>

List of all members.

Classes

struct  Node

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (ObjectCatalog, bslma::UsesBslmaAllocator)
 ObjectCatalog (bslma::Allocator *allocator=0)
 ~ObjectCatalog ()
int add (TYPE const &object)
int add (bslmf::MovableRef< TYPE > object)
int remove (int handle, TYPE *valueBuffer=0)
void removeAll ()
void removeAll (bsl::vector< TYPE > *buffer)
void removeAll (std::vector< TYPE > *buffer)
int replace (int handle, const TYPE &newObject)
int replace (int handle, bslmf::MovableRef< TYPE > newObject)
bslma::Allocatorallocator () const
int find (int handle) const
int find (int handle, TYPE *valueBuffer) const
bool isMember (const TYPE &object) const
int length () const
const TYPE & value (int handle) const
void verifyState () const

Friends

class ObjectCatalog_AutoCleanup< TYPE >
class ObjectCatalogIter< TYPE >

Detailed Description

template<class TYPE>
class bdlcc::ObjectCatalog< TYPE >

This class defines an efficient indexed object catalog of TYPE objects. This container is exception neutral with no guarantee of rollback: if an exception is thrown during the invocation of a method on a pre-existing instance, the object is left in a valid but undefined state. In no event is memory leaked or a mutex left in a locked state.

See Component bdlcc_objectcatalog


Constructor & Destructor Documentation

template<class TYPE>
bdlcc::ObjectCatalog< TYPE >::ObjectCatalog ( bslma::Allocator allocator = 0  )  [explicit]

Create an empty object catalog, using the optionally specified allocator to supply any memory.

template<class TYPE>
bdlcc::ObjectCatalog< TYPE >::~ObjectCatalog (  ) 

Destroy this object catalog.


Member Function Documentation

template<class TYPE>
bdlcc::ObjectCatalog< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION ( ObjectCatalog< TYPE >  ,
bslma::UsesBslmaAllocator   
)
template<class TYPE>
int bdlcc::ObjectCatalog< TYPE >::add ( TYPE const &  object  ) 

Add the value of the specified object to this catalog and return a non-zero integer handle that may be used to refer to the object in future calls to this catalog. The behavior is undefined if the catalog was full.

template<class TYPE>
int bdlcc::ObjectCatalog< TYPE >::add ( bslmf::MovableRef< TYPE >  object  ) 

Add the value of the specified object to this catalog and return a non-zero integer handle that may be used to refer to the object in future calls to this catalog, leaving object in an unspecified but valid state. The behavior is undefined if the catalog was full.

template<class TYPE>
int bdlcc::ObjectCatalog< TYPE >::remove ( int  handle,
TYPE *  valueBuffer = 0 
)

Optionally load into the optionally specified valueBuffer the value of the object having the specified handle and remove it from this catalog. Return zero on success, and a non-zero value if the handle is not contained in this catalog. Note that valueBuffer is assigned into, and thus must point to a valid TYPE instance.

template<class TYPE>
void bdlcc::ObjectCatalog< TYPE >::removeAll (  ) 
template<class TYPE>
void bdlcc::ObjectCatalog< TYPE >::removeAll ( bsl::vector< TYPE > *  buffer  ) 
template<class TYPE>
void bdlcc::ObjectCatalog< TYPE >::removeAll ( std::vector< TYPE > *  buffer  ) 

Remove all objects that are currently held in this catalog and optionally load into the optionally specified buffer the removed objects.

template<class TYPE>
int bdlcc::ObjectCatalog< TYPE >::replace ( int  handle,
const TYPE &  newObject 
)

Replace the object having the specified handle with the specified newObject. Return 0 on success, and a non-zero value if the handle is not contained in this catalog.

template<class TYPE>
int bdlcc::ObjectCatalog< TYPE >::replace ( int  handle,
bslmf::MovableRef< TYPE >  newObject 
)

Replace the object having the specified handle with the specified newObject, leaving newObject in an unspecified but valid state. Return 0 on success, and a non-zero value if the handle is not contained in this catalog.

template<class TYPE>
bslma::Allocator* bdlcc::ObjectCatalog< TYPE >::allocator (  )  const

Return the allocator used by this object.

template<class TYPE>
int bdlcc::ObjectCatalog< TYPE >::find ( int  handle  )  const
template<class TYPE>
int bdlcc::ObjectCatalog< TYPE >::find ( int  handle,
TYPE *  valueBuffer 
) const

Locate the object having the specified handle and optionally load its value into the optionally specified valueBuffer. Return zero on success, and a non-zero value if the handle is not contained in this catalog. Note that valueBuffer is assigned into, and thus must point to a valid TYPE instance. Note that the overload with valueBuffer passed is not supported unless TYPE has a copy constructor.

template<class TYPE>
bool bdlcc::ObjectCatalog< TYPE >::isMember ( const TYPE &  object  )  const

Return true if the catalog contains an item that compares equal to the specified object and false otherwise.

template<class TYPE>
int bdlcc::ObjectCatalog< TYPE >::length (  )  const

Return a "snapshot" of the number of items currently contained in this catalog.

template<class TYPE>
const TYPE& bdlcc::ObjectCatalog< TYPE >::value ( int  handle  )  const

Return a const reference to the object having the specified handle. The behavior is undefined unless handle is contained in this catalog.

template<class TYPE>
void bdlcc::ObjectCatalog< TYPE >::verifyState (  )  const

Verify that this catalog is in a consistent state. This function is introduced for testing purposes only.


Friends And Related Function Documentation

template<class TYPE>
friend class ObjectCatalog_AutoCleanup< TYPE > [friend]
template<class TYPE>
friend class ObjectCatalogIter< TYPE > [friend]

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