|
BDE 4.39.x Production Release
|
#include <ball_categorymanager.h>
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.
Public Types | |
| typedef CategoryCallbacks::NameFilter | CategoryNameFilterCallback |
| typedef CategoryCallbacks::DefaultThresholdLevels | DefaultThresholdLevelsCallback |
Public Member Functions | |
| CategoryManager (bslma::Allocator *basicAllocator=0) | |
| CategoryManager (int defaultRecordLevel, int defaultPassLevel, int defaultTriggerLevel, int defaultTriggerAllLevel, const DefaultThresholdLevelsCallback &defaultThresholdLevelsCallback, const CategoryNameFilterCallback &categoryNameFilterCallback, bslma::Allocator *basicAllocator=0) | |
| ~CategoryManager () | |
| Category & | operator[] (int index) |
| Category * | addCategory (const char *categoryName, int recordLevel, int passLevel, int triggerLevel, int triggerAllLevel) |
| Category * | addCategory (CategoryHolder *categoryHolder, const char *categoryName, int recordLevel, int passLevel, int triggerLevel, int triggerAllLevel) |
| Category * | addCategoryHierarchically (const char *categoryName) |
| void | addDefaultCategory () |
| Category & | defaultCategory () |
| Category * | lookupCategory (const char *categoryName) |
| Category * | lookupCategory (CategoryHolder *categoryHolder, const char *categoryName) |
| void | resetCategoryHolders () |
| void | resetDefaultThresholdLevels () |
| const Category * | setCategory (const char *categoryName) |
| const Category * | setCategory (CategoryHolder *categoryHolder, const char *categoryName) |
| Category * | setCategory (const char *categoryName, int recordLevel, int passLevel, int triggerLevel, int triggerAllLevel) |
| int | setDefaultThresholdLevels (int recordLevel, int passLevel, int triggerLevel, int triggerAllLevel) |
| void | setDefaultThresholdLevelsCallback (const DefaultThresholdLevelsCallback *defaultThresholdLevelsCallback) |
| Category * | setThresholdLevels (const char *categoryName, int recordLevel, int passLevel, int triggerLevel, int triggerAllLevel) |
| int | setThresholdLevelsHierarchically (const char *categoryNamePrefix, int recordLevel, int passLevel, int triggerLevel, int triggerAllLevel) |
| int | addRule (const Rule &ruleToAdd) |
| int | addRules (const RuleSet &ruleSet) |
| int | removeRule (const Rule &ruleToRemove) |
| int | removeRules (const RuleSet &ruleSet) |
| void | removeAllRules () |
| bslmt::Mutex & | rulesetMutex () |
| void | setMaxNumCategories (int length) |
| template<class t_CATEGORY_VISITOR > | |
| void | visitCategories (const t_CATEGORY_VISITOR &visitor) |
| const Category & | operator[] (int index) const |
| const Category & | defaultCategory () const |
| int | length () const |
| const Category * | lookupCategory (const char *categoryName) const |
| int | maxNumCategories () const |
| const RuleSet & | ruleSet () const |
| bsls::Types::Int64 | ruleSetSequenceNumber () const |
| void | setCategoryThresholdsToCurrentDefaults (Category *category) const |
| void | setCategoryThresholdsToFactoryDefaults (Category *category) const |
| template<class t_CATEGORY_VISITOR > | |
| void | visitCategories (const t_CATEGORY_VISITOR &visitor) const |
| int | defaultPassThresholdLevel () const |
| int | defaultRecordThresholdLevel () const |
| int | defaultTriggerAllThresholdLevel () const |
| int | defaultTriggerThresholdLevel () const |
| ThresholdAggregate | defaultThresholdLevels () const |
| int | thresholdLevelsForNewCategory (ThresholdAggregate *levels, const char *categoryName) const |
CategoryNameFilterCallback is the type of the user-supplied functor that translates external category names to internal names.
| typedef CategoryCallbacks::DefaultThresholdLevels ball::CategoryManager::DefaultThresholdLevelsCallback |
DefaultThresholdLevelsCallback is the type of the functor that determines default threshold levels for categories added to the registry by the setCategory(const char *) method.
|
explicit |
Create a category manager with the hardwired default levels for new categories and no defaults or namefilter callback set. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.
| ball::CategoryManager::CategoryManager | ( | int | defaultRecordLevel, |
| int | defaultPassLevel, | ||
| int | defaultTriggerLevel, | ||
| int | defaultTriggerAllLevel, | ||
| const DefaultThresholdLevelsCallback & | defaultThresholdLevelsCallback, | ||
| const CategoryNameFilterCallback & | categoryNameFilterCallback, | ||
| bslma::Allocator * | basicAllocator = 0 |
||
| ) |
Create a category manager with the specified default threshold level values defaultRecordLevel, defaultPassLevel, defaultTriggerLevel, defaultTriggerAllLevel, the defaultThresholdLevelsCallback, and the categoryNameFilterCallback. 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.
| 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, possibly changed by the registered category name filter callback, and having the specified recordLevel, passLevel, triggerLevel, and triggerAllLevel threshold values, respectively, if there is no category having (the possibly filtered) 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.
rulesetMutex. categoryName already exists in the registry, 0 is returned. categoryName already exists.
|
inline |
Add to the registry of this category manager a category having the specified categoryName, possibly changed by the registered category name filter callback, and having the specified recordLevel, passLevel, triggerLevel, and triggerAllLevel threshold values, respectively, if there is no category having (the possibly filtered) 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.
rulesetMutex. categoryName already exists in the registry, 0 is returned. categoryName already exists. | Category * ball::CategoryManager::addCategoryHierarchically | ( | const char * | categoryName | ) |
Add a new category with the specified categoryName, possibly changed by the registered category name filter callback, unless it already exists. Return a pointer to the newly added category in case it did not already exist. Determine the threshold levels for the category by finding the longest category name or category name prefix that is a prefix of this (possibly filtered) categoryName and use its settings. If no such category or category hierarchical setting exists use the defaults. Otherwise, if a category already exists with (the possibly filtered) categoryName do nothing and return 0.
| void ball::CategoryManager::addDefaultCategory | ( | ) |
If this method is called the first time (d_defaultCategory_p is null) add a new category with the (unspecified) default category name (possibly changed by the registered category name filter callback). Use the default threshold levels for the new category.
| int ball::CategoryManager::addRule | ( | const Rule & | ruleToAdd | ) |
Add the specified ruleToAdd 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).
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.
rulesetMutex.
|
inline |
Return a non-const reference to the Default Category in this category registry.
addDefaultCategory has been called.
|
inline |
Return a const reference to the Default Category in this category registry.
addDefaultCategory has been called. | int ball::CategoryManager::defaultPassThresholdLevel | ( | ) | const |
Return the default pass threshold level of this object.
| int ball::CategoryManager::defaultRecordThresholdLevel | ( | ) | const |
Return the default record threshold level of this object.
| ThresholdAggregate ball::CategoryManager::defaultThresholdLevels | ( | ) | const |
Return the default threshold levels associated with this object.
| int ball::CategoryManager::defaultTriggerAllThresholdLevel | ( | ) | const |
Return the default trigger-all threshold level of this object.
| int ball::CategoryManager::defaultTriggerThresholdLevel | ( | ) | const |
Return the default trigger threshold level of this object.
|
inline |
Return the number of categories in the registry of this category manager.
| 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.
| Category * ball::CategoryManager::lookupCategory | ( | const char * | categoryName | ) |
Return the address of the modifiable category having the specified categoryNamein the registry of this category manager, or 0 if no such category exists.
| const Category * ball::CategoryManager::lookupCategory | ( | const char * | categoryName | ) | const |
Return the address of the non-modifiable category having the specified categoryName, possibly changed by the registered category name filter callback, in the registry of this category manager, or 0 if no such category exists.
|
inline |
Return the current capacity of this category registry. A capacity of 0 implies that no limit will be imposed; otherwise, new categories may be added only if numCategories() < maxNumCategories().
0 < maxNumCategories() < numCategories() is a valid state, implying no new categories may be added.
|
inline |
Return a non-const reference to the category at the specified index in the registry of this category manager.
0 <= index < length().
|
inline |
Return a const reference to the category at the specified index in the registry of this category manager.
0 <= index < length(). | void ball::CategoryManager::removeAllRules | ( | ) |
Remove every rule from the set of rules maintained by this object.
rulesetMutex. | int ball::CategoryManager::removeRule | ( | const Rule & | ruleToRemove | ) |
Remove the specified ruleToRemove 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).
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.
rulesetMutex. | 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.
| void ball::CategoryManager::resetDefaultThresholdLevels | ( | ) |
Reset the default threshold levels to the original "factory-supplied" default values or the factory overrides supplied at construction.
|
inline |
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.
|
inline |
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.
ruleSet.
|
inline |
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.
| const Category * ball::CategoryManager::setCategory | ( | CategoryHolder * | categoryHolder, |
| const char * | categoryName | ||
| ) |
Add to this category registry a new category having the specified categoryName, possibly changed by the registered category name filter callback, and default threshold levels if (the possibly filtered) categoryName is not present in the registry and the number of categories in the registry is less than the registry capacity. Return the address of the (possibly newly-created) non-modifiable category having (the possibly filtered) categoryName, if such a category exists, and the address of the non-modifiable Default Category otherwise. If 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.
categoryName is null-terminated.
|
inline |
Add to this category registry a new category having the specified categoryName, possibly changed by the registered category name filter callback, and default threshold levels if (the possibly filtered) categoryName is not present in the registry and the number of categories in the registry is less than the registry capacity. Return the address of the (possibly newly-created) non-modifiable category having (the possibly filtered) categoryName, if such a category exists, and the address of the non-modifiable Default Category otherwise.
categoryName is null-terminated. | Category * ball::CategoryManager::setCategory | ( | const char * | categoryName, |
| int | recordLevel, | ||
| int | passLevel, | ||
| int | triggerLevel, | ||
| int | triggerAllLevel | ||
| ) |
Add to this category registry a new category having the specified categoryName, possibly changed by the registered category name filter callback, and having recordLevel, passLevel, triggerLevel, and triggerAllLevel threshold levels, respectively, if (1) (the possibly filtered) categoryName is not present in the registry, (2) the number of categories in the registry is less than the registry capacity, and (3) recordLevel, passLevel, triggerLevel, and triggerAllLevel are all within the range [0 .. 255]. If (the possibly filtered) categoryName is already present and each threshold level is within the valid range then reset the threshold levels of (the possibly filtered) categoryName to the specified values. Return the address of the (possibly newly-created) modifiable category having (the possibly filtered) categoryName if that categoryName was either created or its thresholds reset, and 0 otherwise.
categoryName is null-terminated. | void ball::CategoryManager::setCategoryThresholdsToCurrentDefaults | ( | Category * | category | ) | const |
Set the threshold levels of the specified category in this category registry of this category manager to the current default threshold values.
category is non-null. | void ball::CategoryManager::setCategoryThresholdsToFactoryDefaults | ( | Category * | category | ) | const |
Set the threshold levels of the specified category in the category registry of this category manager to the original "factory-supplied" default values or the factory overrides supplied at construction.
category is non-null. | int ball::CategoryManager::setDefaultThresholdLevels | ( | int | recordLevel, |
| int | passLevel, | ||
| int | triggerLevel, | ||
| int | triggerAllLevel | ||
| ) |
Set the default threshold levels to the specified recordLevel, passLevel, triggerLevel, and triggerAllLevel values, respectively, if each threshold level is in the range [0 .. 255]. Return 0 on success, and a non-zero value otherwise (with no effect on any of the default threshold levels).
| void ball::CategoryManager::setDefaultThresholdLevelsCallback | ( | const DefaultThresholdLevelsCallback * | defaultThresholdLevelsCallback | ) |
Set the default-thresholds callback to the specified defaultThresholdLevelsCallback if it is not null, and remove any existing callback if defaultThresholdLevelsCallback is null.
|
inline |
Set the capacity of this category registry to the specified length. If length is 0, no limit will be imposed. No categories are removed from the registry if the current number of categories exceeds length. However, subsequent attempts to add categories to the registry will fail.
0 <= length. | 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, possibly changed by the registered category name filter callback, in the registry of this category manager to the specified recordLevel, passLevel, triggerLevel, and triggerAllLevel values, respectively, if a category having (the possibly filtered) categoryName exists and each of the specified threshold values is in the range [0 .. 255]. Otherwise, add to the registry a category having (the possibly filtered) categoryName and recordLevel, passLevel, triggerLevel, and triggerAllLevel threshold values, respectively, if there is no category having (the possibly filtered) 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).
rulesetMutex. | int ball::CategoryManager::setThresholdLevelsHierarchically | ( | const char * | categoryNamePrefix, |
| int | recordLevel, | ||
| int | passLevel, | ||
| int | triggerLevel, | ||
| int | triggerAllLevel | ||
| ) |
Set the threshold levels of all existing and future categories whose name starts with the specified categoryNamePrefix unless it is empty, possibly changed by the registered category name filter callback, to the specified recordLevel, passLevel, triggerLevel, and triggerAllLevel if those levels form valid settings and return the number of categories updated (zero or a positive number). In case categoryNamePrefix is empty update all categories with the threshold levels and delete all stored orphan hierarchical settings. In other words an empty category setting will never overwrite the defaults for future hierarchical categories.
rulesetMutex. If any of the specified threshold levels is invalid, return a negative value. | int ball::CategoryManager::thresholdLevelsForNewCategory | ( | ThresholdAggregate * | levels, |
| const char * | categoryName | ||
| ) | const |
Load into the specified *levels the threshold levels that would be set for a newly and non-hierarchically created category. Return 0 on success and a non-zero value otherwise. If the client has configured a default threshold levels callback, the categoryName, possibly changed by the registered category name filter callback, will be supplied to that callback which will set *levels. Otherwise, if no default threshold levels callback has been provided, the default threshold levels are used.
| 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:
visitor calls any method on this CategoryManager object. | 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:
visitor calls any method on this CategoryManager object.