|
BDE 4.39.x Production Release
|
#include <bdlcc_objectcatalog.h>
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.
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::Allocator * | allocator () const |
| 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 > |
|
inlineexplicit |
Create an empty object catalog, using the optionally specified allocator to supply any memory.
|
inline |
Destroy this object catalog.
| 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.
| 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.
|
inline |
Return the allocator used by this object.
| bdlcc::ObjectCatalog< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION | ( | ObjectCatalog< TYPE > | , |
| bslma::UsesBslmaAllocator | |||
| ) |
| 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.
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.
|
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.
valueBuffer is assigned into, and thus must point to a valid TYPE instance. valueBuffer passed is not supported unless TYPE has a copy constructor.
|
inline |
| 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.
|
inline |
Return a "snapshot" of the number of items currently contained in this catalog.
|
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.
valueBuffer is assigned into, and thus must point to a valid TYPE instance.
|
inline |
Remove all objects that are currently held in this catalog and optionally load into the optionally specified buffer the removed objects.
|
inline |
|
inline |
| 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.
| 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.
| void bdlcc::ObjectCatalog< TYPE >::verifyState | ( | ) | const |
Verify that this catalog is in a consistent state. This function is introduced for testing purposes only.
|
friend |
|
friend |