BDE 4.39.x Production Release
Loading...
Searching...
No Matches
ball::AttributeCollectorRegistry Class Reference

#include <ball_attributecollectorregistry.h>

Detailed Description

This component maintains a registry of named functors ("collectors") that are used to transform opaque user data into a set of ball::Attribute objects.

See ball_attributecollectorregistry

Public Types

typedef bsl::function< void(const ball::Attribute &)> Visitor
 
typedef bsl::function< void(const Visitor &)> Collector
 
typedef bsl::allocator< char > allocator_type
 

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (AttributeCollectorRegistry, bslma::UsesBslmaAllocator)
 
 AttributeCollectorRegistry ()
 
 AttributeCollectorRegistry (const allocator_type &allocator)
 
int addCollector (const Collector &collector, const bsl::string_view &name)
 
void removeAll ()
 
int removeCollector (const bsl::string_view &name)
 
void collect (const Visitor &visitor) const
 
allocator_type get_allocator () const
 
bool hasCollector (const bsl::string_view &name) const
 
int numCollectors () const
 

Member Typedef Documentation

◆ allocator_type

This typedef is an alias for the allocator used by this object.

◆ Collector

Collector is the type of a user-supplied attribute collector functor.

◆ Visitor

Visitor is the type of a user-supplied visit functor.

Constructor & Destructor Documentation

◆ AttributeCollectorRegistry() [1/2]

ball::AttributeCollectorRegistry::AttributeCollectorRegistry ( )
inline

Create a registry having no registered collectors. Optionally specify an allocator (e.g., the address of a bslma::Allocator object) to supply memory; otherwise, the default allocator is used.

◆ AttributeCollectorRegistry() [2/2]

ball::AttributeCollectorRegistry::AttributeCollectorRegistry ( const allocator_type allocator)
inlineexplicit

Member Function Documentation

◆ addCollector()

int ball::AttributeCollectorRegistry::addCollector ( const Collector collector,
const bsl::string_view name 
)

Add the specified collector with the specified name to this registry. Return 0 if collector was successfully registered, and a non-zero value (with no effect) otherwise.

Note
Note that this method will fail if a collector having name is already registered.

◆ BSLMF_NESTED_TRAIT_DECLARATION()

ball::AttributeCollectorRegistry::BSLMF_NESTED_TRAIT_DECLARATION ( AttributeCollectorRegistry  ,
bslma::UsesBslmaAllocator   
)

◆ collect()

void ball::AttributeCollectorRegistry::collect ( const Visitor visitor) const

Invoke all registered collectors with the specified visitor functor.

Note
Note that collectors are invoked in the order in which collectors are registered.

◆ get_allocator()

AttributeCollectorRegistry::allocator_type ball::AttributeCollectorRegistry::get_allocator ( ) const
inline

Return the allocator used by this object to supply memory.

Note
Note that if no allocator was supplied at construction the default allocator in effect at construction is used.

◆ hasCollector()

bool ball::AttributeCollectorRegistry::hasCollector ( const bsl::string_view name) const

Return true if a collector having the specified name is in the registry maintained by this object, and false otherwise.

Note
Note that this method is provided primarily for debugging purposes (i.e., its return value can be invalidated from another thread).

◆ numCollectors()

int ball::AttributeCollectorRegistry::numCollectors ( ) const

Return the number of collectors registered with this object.

Note
Note that this method is provided primarily for debugging purposes (i.e., its return value can be invalidated from another thread).

◆ removeAll()

void ball::AttributeCollectorRegistry::removeAll ( )

Remove all collectors from this registry.

◆ removeCollector()

int ball::AttributeCollectorRegistry::removeCollector ( const bsl::string_view name)

Remove the collector having the specified name from this registry. Return 0 if the collector with name was successfully removed, and a non-zero value (with no effect) otherwise.


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