BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlcc::ObjectCatalog< TYPE > Class Template Reference

#include <bdlcc_objectcatalog.h>

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (ObjectCatalog, bslma::UsesBslmaAllocator)
 
 ObjectCatalog (bslma::Allocator *allocator=0)
 
 ~ObjectCatalog ()
 Destroy this object catalog.
 
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
 Return the allocator used by this object.
 
int find (int handle) const
 
int find (int handle, TYPE *valueBuffer) const
 
bool isMember (const TYPE &object) const
 
int length () const
 
 BSLS_DEPRECATE_FEATURE ("bde", "ObjectCataloog::value(handle)", "use 'ObjectCatalogIter::value()' instead") 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 bdlcc_objectcatalog

Constructor & Destructor Documentation

◆ ObjectCatalog()

template<class TYPE >
bdlcc::ObjectCatalog< TYPE >::ObjectCatalog ( bslma::Allocator allocator = 0)
inlineexplicit

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

◆ ~ObjectCatalog()

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

Member Function Documentation

◆ add() [1/2]

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.

◆ add() [2/2]

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.

◆ allocator()

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

◆ BSLMF_NESTED_TRAIT_DECLARATION()

template<class TYPE >
bdlcc::ObjectCatalog< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION ( ObjectCatalog< TYPE >  ,
bslma::UsesBslmaAllocator   
)

◆ BSLS_DEPRECATE_FEATURE()

template<class TYPE >
bdlcc::ObjectCatalog< TYPE >::BSLS_DEPRECATE_FEATURE ( "bde"  ,
"ObjectCataloog::value(handle)"  ,
"use 'ObjectCatalogIter::value()' instead"   
) const &

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

This method is DEPRECATED because it is not thread-safe. Use find, isMember, or access the object through an iterator.

◆ find() [1/2]

template<class TYPE >
int bdlcc::ObjectCatalog< TYPE >::find ( int  handle) const
inline

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.

◆ find() [2/2]

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

◆ isMember()

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.

◆ length()

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

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

◆ remove()

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

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.

◆ removeAll() [1/3]

template<class TYPE >
void bdlcc::ObjectCatalog< TYPE >::removeAll ( )
inline

◆ removeAll() [2/3]

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

◆ removeAll() [3/3]

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

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

◆ replace() [1/2]

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.

◆ replace() [2/2]

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.

◆ verifyState()

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 Symbol Documentation

◆ ObjectCatalog_AutoCleanup< TYPE >

template<class TYPE >
friend class ObjectCatalog_AutoCleanup< TYPE >
friend

◆ ObjectCatalogIter< TYPE >

template<class TYPE >
friend class ObjectCatalogIter< TYPE >
friend

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