Quick Links:

bal | bbl | bdl | bsl

Public Member Functions

ball::CategoryManager Class Reference

#include <ball_categorymanager.h>

List of all members.

Public Member Functions

 CategoryManager (bslma::Allocator *basicAllocator=0)
 ~CategoryManager ()
Categoryoperator[] (int index)
CategoryaddCategory (const char *categoryName, int recordLevel, int passLevel, int triggerLevel, int triggerAllLevel)
CategoryaddCategory (CategoryHolder *categoryHolder, const char *categoryName, int recordLevel, int passLevel, int triggerLevel, int triggerAllLevel)
CategorylookupCategory (const char *categoryName)
CategorylookupCategory (CategoryHolder *categoryHolder, const char *categoryName)
void resetCategoryHolders ()
CategorysetThresholdLevels (const char *categoryName, int recordLevel, int passLevel, int triggerLevel, int triggerAllLevel)
int addRule (const Rule &rule)
int addRules (const RuleSet &ruleSet)
int removeRule (const Rule &rule)
int removeRules (const RuleSet &ruleSet)
void removeAllRules ()
bslmt::MutexrulesetMutex ()
template<class t_CATEGORY_VISITOR >
void visitCategories (const t_CATEGORY_VISITOR &visitor)
const Categoryoperator[] (int index) const
int length () const
const CategorylookupCategory (const char *categoryName) const
const RuleSetruleSet () const
bsls::Types::Int64 ruleSetSequenceNumber () const
template<class t_CATEGORY_VISITOR >
void visitCategories (const t_CATEGORY_VISITOR &visitor) const

Detailed Description

This class manages a set (or "registry") of categories. Categories may be added to the registry, but they cannot be removed. However, the threshold levels of existing categories may be accessed and modified directly.

See Component ball_categorymanager


Constructor & Destructor Documentation

ball::CategoryManager::CategoryManager ( bslma::Allocator basicAllocator = 0  )  [explicit]

Create a category manager. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

ball::CategoryManager::~CategoryManager (  ) 

Destroy this category manager.


Member Function Documentation

Category& ball::CategoryManager::operator[] ( int  index  ) 

Return a non-'const' reference to the category at the specified index in the registry of this category manager. The behavior is undefined unless 0 <= index < length().

Category* ball::CategoryManager::addCategory ( const char *  categoryName,
int  recordLevel,
int  passLevel,
int  triggerLevel,
int  triggerAllLevel 
)

Add to the registry of this category manager a category having the specified categoryName and the specified recordLevel, passLevel, triggerLevel, and triggerAllLevel threshold values, respectively, if there is no category having categoryName and each of the specified threshold values is in the range [0 .. 255]. Return the address of the newly-created, modifiable category on success, and 0 otherwise. The behavior is undefined unless a lock is not held by this thread on the mutex returned by rulesetMutex. Note that if a category having categoryName already exists in the registry, 0 is returned.

Category* ball::CategoryManager::addCategory ( CategoryHolder categoryHolder,
const char *  categoryName,
int  recordLevel,
int  passLevel,
int  triggerLevel,
int  triggerAllLevel 
)

Add to the registry of this category manager a category having the specified categoryName and the specified recordLevel, passLevel, triggerLevel, and triggerAllLevel threshold values, respectively, if there is no category having categoryName and each of the specified threshold values is in the range [0 .. 255]. Return the address of the newly-created, modifiable category on success, and 0 otherwise. If a newly-created category is returned and the specified categoryHolder is non-null, then also load into categoryHolder the returned category and its maximum level and link categoryHolder to the category. The behavior is undefined unless a lock is not held by this thread on the mutex returned by rulesetMutex. Note that if a category having categoryName already exists in the registry, 0 is returned.

Category* ball::CategoryManager::lookupCategory ( const char *  categoryName  ) 

Return the address of the modifiable category having the specified categoryName in the registry of this category manager, or 0 if no such category exists.

Category* ball::CategoryManager::lookupCategory ( CategoryHolder categoryHolder,
const char *  categoryName 
)

Return the address of the modifiable category having the specified categoryName in the registry of this category manager, or 0 if no such category exists. If a category is returned and the specified categoryHolder is non-null, then also load into categoryHolder the returned category and its maximum level and link categoryHolder to the category if it has not yet been linked.

void ball::CategoryManager::resetCategoryHolders (  ) 

Reset the category holders to which all categories in the registry of this category manager are linked to their default value. See the function-level documentation of CategoryHolder::reset() for further information on the default value of category holders.

Category* ball::CategoryManager::setThresholdLevels ( const char *  categoryName,
int  recordLevel,
int  passLevel,
int  triggerLevel,
int  triggerAllLevel 
)

Set the threshold levels of the category having the specified categoryName in the registry of this category manager to the specified recordLevel, passLevel, triggerLevel, and triggerAllLevel values, respectively, if a category having categoryName exists and each of the specified threshold values is in the range [0 .. 255]. Otherwise, add to the registry a category having the specified categoryName and the specified recordLevel, passLevel, triggerLevel, and triggerAllLevel threshold values, respectively, if there is no category having categoryName and each of the specified threshold values is in the range [0 .. 255]. Return the address of the (possibly newly-created) modifiable category on success, and 0 otherwise (with no effect on any category). The behavior is undefined unless a lock is not held by this thread on the mutex returned by rulesetMutex.

int ball::CategoryManager::addRule ( const Rule rule  ) 

Add the specified rule to the set of (unique) rules maintained by this object. Return the number of rules added (i.e., 1 on success and 0 if a rule with the same value is already present). The behavior is undefined unless a lock is not held by this thread on the mutex returned by rulesetMutex.

int ball::CategoryManager::addRules ( const RuleSet ruleSet  ) 

Add each rule in the specified ruleSet to the set of (unique) rules maintained by this object. Return the number of rules added. The behavior is undefined unless a lock is not held by this thread on the mutex returned by rulesetMutex. Note that each rule having the same value as an existing rule will be ignored.

int ball::CategoryManager::removeRule ( const Rule rule  ) 

Remove the specified rule from the set of (unique) rules maintained by this object. Return the number of rules removed (i.e., 1 on success and 0 if no rule having the same value is found). The behavior is undefined unless a lock is not held by this thread on the mutex returned by rulesetMutex.

int ball::CategoryManager::removeRules ( const RuleSet ruleSet  ) 

Remove each rule in the specified ruleSet from the set of rules maintained by this object. Return the number of rules removed. The behavior is undefined unless a lock is not held by this thread on the mutex returned by rulesetMutex.

void ball::CategoryManager::removeAllRules (  ) 

Remove every rule from the set of rules maintained by this object. The behavior is undefined unless a lock is not held by this thread on the mutex returned by rulesetMutex.

bslmt::Mutex& ball::CategoryManager::rulesetMutex (  ) 

Return a non-'const' reference to the mutex that is used to guard against concurrent access to the rule set. A lock on the returned mutex should be acquired before accessing the properties of the rule set returned by ruleSet. The behavior is undefined unless a lock is acquired solely for the purpose of calling ruleSet.

template<class t_CATEGORY_VISITOR >
void ball::CategoryManager::visitCategories ( const t_CATEGORY_VISITOR &  visitor  ) 

Invoke the specified visitor functor on each category managed by this object, supplying that functor modifiable access to each category. visitor must be a functor that can be called as if it had the following signature:

          void operator()(Category *);
const Category& ball::CategoryManager::operator[] ( int  index  )  const

Return a const reference to the category at the specified index in the registry of this category manager. The behavior is undefined unless 0 <= index < length().

int ball::CategoryManager::length (  )  const

Return the number of categories in the registry of this category manager.

const Category* ball::CategoryManager::lookupCategory ( const char *  categoryName  )  const

Return the address of the non-modifiable category having the specified categoryName in the registry of this category manager, or 0 if no such category exists.

const RuleSet& ball::CategoryManager::ruleSet (  )  const

Return a const reference to the rule set maintained by this category manager. The mutex returned by rulesetMutex should be locked prior to accessing the rule set.

bsls::Types::Int64 ball::CategoryManager::ruleSetSequenceNumber (  )  const

Return the sequence number that tracks changes to the rule set maintained by this category manager. The value returned by this method is guaranteed to monotonically increase between calls before and after the rule set is changed, and is otherwise implementation defined.

template<class t_CATEGORY_VISITOR >
void ball::CategoryManager::visitCategories ( const t_CATEGORY_VISITOR &  visitor  )  const

Invoke the specified visitor functor on each category managed by this object, supplying that functor non-modifiable access to each category. visitor must be a functor that can be called as if it had the following signature:

          void operator()(const Category *);

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