BDE 4.14.0 Production release
Loading...
Searching...
No Matches
ball_categorymanager.h
Go to the documentation of this file.
1/// @file ball_categorymanager.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// ball_categorymanager.h -*-C++-*-
8#ifndef INCLUDED_BALL_CATEGORYMANAGER
9#define INCLUDED_BALL_CATEGORYMANAGER
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup ball_categorymanager ball_categorymanager
15/// @brief Provide a manager of named categories each having "thresholds".
16/// @addtogroup bal
17/// @{
18/// @addtogroup ball
19/// @{
20/// @addtogroup ball_categorymanager
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#ball_categorymanager-purpose"> Purpose</a>
25/// * <a href="#ball_categorymanager-classes"> Classes </a>
26/// * <a href="#ball_categorymanager-description"> Description </a>
27/// * <a href="#ball_categorymanager-thread-safety"> Thread Safety </a>
28/// * <a href="#ball_categorymanager-usage"> Usage </a>
29/// * <a href="#ball_categorymanager-example-1-basic-usage"> Example 1: Basic Usage </a>
30///
31/// # Purpose {#ball_categorymanager-purpose}
32/// Provide a manager of named categories each having "thresholds".
33///
34/// # Classes {#ball_categorymanager-classes}
35///
36/// - ball::CategoryManager: manager of category registry
37///
38/// @see ball_category, ball_loggermanager, ball_loggercategoryutil
39///
40/// # Description {#ball_categorymanager-description}
41/// This component provides a registry for category information and
42/// functions to manage the registry and its members. By "category" we mean a
43/// named entity that identifies a region or functional area of a program. A
44/// category name can be an arbitrary string, including the empty string. Note
45/// that category names are case-sensitive.
46///
47/// Associated with each category, besides its name, are four threshold levels
48/// known as "record", "pass", "trigger", and "trigger-all". Threshold levels
49/// are values in the range `[0 .. 255]`. (See the @ref ball_loggermanager
50/// component-level documentation for a typical interpretation of these four
51/// thresholds.)
52///
53/// A category is represented by a `ball::Category` object. Although instances
54/// of `ball::Category` can be created directly, within the BALL logging
55/// framework they are generally created by the `ball::CategoryManager` class.
56/// `ball::CategoryManager` manages a registry of categories and exposes methods
57/// to add new categories to the registry (`addCategory`) and modify the
58/// threshold levels of existing categories (`setThresholdLevels`).
59/// `ball::Category` provides accessors for direct access to the name and
60/// threshold levels of a given category, and a single manipulator to set the
61/// four threshold levels levels (see @ref ball_category ).
62///
63/// ## Thread Safety {#ball_categorymanager-thread-safety}
64///
65///
66/// `ball::CategoryManager` is *thread-safe*, meaning that any operation on the
67/// same instance can be safely invoked from any thread concurrently with any
68/// other operation.
69///
70/// ## Usage {#ball_categorymanager-usage}
71///
72///
73/// This section illustrates intended use of this component.
74///
75/// ### Example 1: Basic Usage {#ball_categorymanager-example-1-basic-usage}
76///
77///
78/// The code fragments in the following example illustrate some basic operations
79/// of category management including (1) adding categories to the registry,
80/// (2) accessing and modifying the threshold levels of existing categories,
81/// and (3) iterating over the categories in the registry.
82///
83/// First we define some hypothetical category names:
84/// @code
85/// const char *myCategories[] = {
86/// "EQUITY.MARKET.NYSE",
87/// "EQUITY.MARKET.NASDAQ",
88/// "EQUITY.GRAPHICS.MATH.FACTORIAL",
89/// "EQUITY.GRAPHICS.MATH.ACKERMANN"
90/// };
91/// @endcode
92/// Next we create a `ball::CategoryManager` named `manager` and use the
93/// `addCategory` method to define a category for each of the names in
94/// `myCategories`. The threshold levels of each of the categories are set to
95/// slightly different values to help distinguish them when they are displayed
96/// later:
97/// @code
98/// ball::CategoryManager manager;
99///
100/// const int NUM_CATEGORIES = sizeof myCategories / sizeof *myCategories;
101/// for (int i = 0; i < NUM_CATEGORIES; ++i) {
102/// manager.addCategory(myCategories[i],
103/// 192 + i, 96 + i, 64 + i, 32 + i);
104/// }
105/// @endcode
106/// In the following, each of the new categories is accessed from the registry
107/// and their names and threshold levels printed:
108/// @code
109/// for (int i = 0; i < NUM_CATEGORIES; ++i) {
110/// const ball::Category *category =
111/// manager.lookupCategory(myCategories[i]);
112/// bsl::cout << "[ " << myCategories[i]
113/// << ", " << category->recordLevel()
114/// << ", " << category->passLevel()
115/// << ", " << category->triggerLevel()
116/// << ", " << category->triggerAllLevel()
117/// << " ]" << bsl::endl;
118/// }
119/// @endcode
120/// The following is printed to `stdout`:
121/// @code
122/// [ EQUITY.MARKET.NYSE, 192, 96, 64, 32 ]
123/// [ EQUITY.MARKET.NASDAQ, 193, 97, 65, 33 ]
124/// [ EQUITY.GRAPHICS.MATH.FACTORIAL, 194, 98, 66, 34 ]
125/// [ EQUITY.GRAPHICS.MATH.ACKERMANN, 195, 99, 67, 35 ]
126/// @endcode
127/// We next use the `setLevels` method of `ball::Category` to adjust the
128/// threshold levels of our categories. The following also demonstrates use of
129/// the `recordLevel`, etc., accessors of `ball::Category`:
130/// @code
131/// for (int i = 0; i < NUM_CATEGORIES; ++i) {
132/// ball::Category *category = manager.lookupCategory(myCategories[i]);
133/// category->setLevels(category->recordLevel() + 1,
134/// category->passLevel() + 1,
135/// category->triggerLevel() + 1,
136/// category->triggerAllLevel() + 1);
137/// }
138/// @endcode
139/// Repeating the second `for` loop from above generates the following output
140/// on `stdout`:
141/// @code
142/// [ EQUITY.MARKET.NYSE, 193, 97, 65, 33 ]
143/// [ EQUITY.MARKET.NASDAQ, 194, 98, 66, 34 ]
144/// [ EQUITY.GRAPHICS.MATH.FACTORIAL, 195, 99, 67, 35 ]
145/// [ EQUITY.GRAPHICS.MATH.ACKERMANN, 196, 100, 68, 36 ]
146/// @endcode
147/// Next we illustrate use of the index operator as a means of iterating over
148/// the registry of categories. In particular, we illustrate an alternate
149/// approach to modifying the threshold levels of our categories by iterating
150/// over the categories in the registry of `manager` to increment their
151/// threshold levels a second time:
152/// @code
153/// for (int i = 0; i < manager.length(); ++i) {
154/// ball::Category& category = manager[i];
155/// category.setLevels(category.recordLevel() + 1,
156/// category.passLevel() + 1,
157/// category.triggerLevel() + 1,
158/// category.triggerAllLevel() + 1);
159/// }
160/// @endcode
161/// Finally, we iterate over the categories in the registry to print them out
162/// one last time:
163/// @code
164/// for (int i = 0; i < manager.length(); ++i) {
165/// const ball::Category& category = manager[i];
166/// bsl::cout << "[ " << category.categoryName()
167/// << ", " << category.recordLevel()
168/// << ", " << category.passLevel()
169/// << ", " << category.triggerLevel()
170/// << ", " << category.triggerAllLevel()
171/// << " ]" << bsl::endl;
172/// }
173/// @endcode
174/// This iteration produces the following output on `stdout`:
175/// @code
176/// [ EQUITY.MARKET.NYSE, 194, 98, 66, 34 ]
177/// [ EQUITY.MARKET.NASDAQ, 195, 99, 67, 35 ]
178/// [ EQUITY.GRAPHICS.MATH.FACTORIAL, 196, 100, 68, 36 ]
179/// [ EQUITY.GRAPHICS.MATH.ACKERMANN, 197, 101, 69, 37 ]
180/// @endcode
181/// @}
182/** @} */
183/** @} */
184
185/** @addtogroup bal
186 * @{
187 */
188/** @addtogroup ball
189 * @{
190 */
191/** @addtogroup ball_categorymanager
192 * @{
193 */
194
195#include <balscm_version.h>
196
197#include <ball_category.h>
198#include <ball_ruleset.h>
200
201#include <bdlb_cstringequalto.h>
202#include <bdlb_cstringhash.h>
203
204#include <bslma_allocator.h>
205#include <bslma_default.h>
206
207#include <bslmt_mutex.h>
208#include <bslmt_readlockguard.h>
210
211#include <bsls_atomic.h>
212#include <bsls_types.h>
213
214#include <bsl_new.h>
215#include <bsl_string.h>
216#include <bsl_unordered_map.h>
217#include <bsl_vector.h>
218
219
220namespace ball {
221
222 // =====================
223 // class CategoryManager
224 // =====================
225
226/// This class manages a set (or "registry") of categories. Categories may be
227/// added to the registry, but they cannot be removed. However, the threshold
228/// levels of existing categories may be accessed and modified directly.
229///
230/// See @ref ball_categorymanager
232
233 // PRIVATE TYPES
234 typedef bsl::unordered_map<const char *,
235 int,
239
240 // DATA
241 CategoryMap d_registry; // mapping names to
242 // indices in
243 // `d_categories`
244
245 bsls::AtomicInt64 d_ruleSetSequenceNumber;
246 // sequence number that
247 // is incremented each
248 // time the rule set is
249 // changed
250
251 RuleSet d_ruleSet; // rule set that contains
252 // all registered rules
253
254 bslmt::Mutex d_ruleSetMutex; // serialize access to
255 // `d_ruleset`
256
257 bsl::vector<Category *> d_categories; // providing random
258 // access to categories
259
260 mutable bslmt::ReaderWriterLock d_registryLock; // ensuring MT-safety of
261 // category map
262
263 bslma::Allocator *d_allocator_p; // memory allocator
264 // (held, not owned)
265
266 private:
267 // NOT IMPLEMENTED
269 CategoryManager& operator=(const CategoryManager&);
270
271 // PRIVATE MANIPULATORS
272
273 /// Add to the registry of this category manager a category having the
274 /// specified `categoryName` and the specified `recordLevel`,
275 /// `passLevel`, `triggerLevel`, and `triggerAllLevel` threshold values,
276 /// respectively. Return the address of the newly-created, modifiable
277 /// category. The behavior is undefined unless a category having
278 /// `categoryName` does not already exist in the registry and each of
279 /// the specified threshold values is in the range `[0 .. 255]`. Note
280 /// that the category registry should be properly synchronized before
281 /// calling this method.
282 Category *addNewCategory(const char *categoryName,
283 int recordLevel,
284 int passLevel,
285 int triggerLevel,
286 int triggerAllLevel);
287
288 /// Apply all rules in the rule set to the specified `category`. The
289 /// behavior is undefined unless the caller holds a lock on the
290 /// `d_ruleSetMutex` mutex.
291 void privateApplyRulesToCategory(Category* category);
292
293 /// Apply all rules in the rule set to all categories. Use the
294 /// specified `ruleGuard` to provide synchronization. The behavior is
295 /// undefined unless `ruleGuard` holds a lock on `d_ruleSetMutex`. Note
296 /// that all methods that modify the rule set must lock `d_ruleSetMutex`
297 /// to perform that modification, so passing the guard avoids needlessly
298 /// unlocking and re-locking the mutex.
299 void privateApplyRulesToAllCategories(
301
302 public:
303 // BDE_VERIFY pragma: push
304 // BDE_VERIFY pragma: -FABC01 // Functions not in alphanumeric order
305
306 // CREATORS
307
308 /// Create a category manager. Optionally specify a `basicAllocator`
309 /// used to supply memory. If `basicAllocator` is 0, the currently
310 /// installed default allocator is used.
311 explicit CategoryManager(bslma::Allocator *basicAllocator = 0);
312
313 /// Destroy this category manager.
315
316 // MANIPULATORS
317
318 /// Return a non-`const` reference to the category at the specified
319 /// `index` in the registry of this category manager. The behavior is
320 /// undefined unless `0 <= index < length()`.
321 Category& operator[](int index);
322
323 /// Add to the registry of this category manager a category having the
324 /// specified `categoryName` and the specified `recordLevel`,
325 /// `passLevel`, `triggerLevel`, and `triggerAllLevel` threshold values,
326 /// respectively, if there is no category having `categoryName` and each
327 /// of the specified threshold values is in the range `[0 .. 255]`.
328 /// Return the address of the newly-created, modifiable category on
329 /// success, and 0 otherwise. The behavior is undefined unless a lock
330 /// is not held by this thread on the mutex returned by `rulesetMutex`.
331 /// Note that if a category having `categoryName` already exists in the
332 /// registry, 0 is returned.
333 Category *addCategory(const char *categoryName,
334 int recordLevel,
335 int passLevel,
336 int triggerLevel,
337 int triggerAllLevel);
338
339 /// Add to the registry of this category manager a category having the
340 /// specified `categoryName` and the specified `recordLevel`,
341 /// `passLevel`, `triggerLevel`, and `triggerAllLevel` threshold values,
342 /// respectively, if there is no category having `categoryName` and each
343 /// of the specified threshold values is in the range `[0 .. 255]`.
344 /// Return the address of the newly-created, modifiable category on
345 /// success, and 0 otherwise. If a newly-created category is returned
346 /// and the specified `categoryHolder` is non-null, then also load into
347 /// `categoryHolder` the returned category and its maximum level and
348 /// link `categoryHolder` to the category. The behavior is undefined
349 /// unless a lock is not held by this thread on the mutex returned by
350 /// `rulesetMutex`. Note that if a category having `categoryName`
351 /// already exists in the registry, 0 is returned.
353 const char *categoryName,
354 int recordLevel,
355 int passLevel,
356 int triggerLevel,
357 int triggerAllLevel);
358
359 /// Return the address of the modifiable category having the specified
360 /// `categoryName` in the registry of this category manager, or 0 if no
361 /// such category exists.
362 Category *lookupCategory(const char *categoryName);
363
364 /// Return the address of the modifiable category having the specified
365 /// `categoryName` in the registry of this category manager, or 0 if no
366 /// such category exists. If a category is returned and the specified
367 /// `categoryHolder` is non-null, then also load into `categoryHolder`
368 /// the returned category and its maximum level and link
369 /// `categoryHolder` to the category if it has not yet been linked.
371 const char *categoryName);
372
373 /// Reset the category holders to which all categories in the registry
374 /// of this category manager are linked to their default value. See the
375 /// function-level documentation of `CategoryHolder::reset()` for
376 /// further information on the default value of category holders.
378
379 /// Set the threshold levels of the category having the specified
380 /// `categoryName` in the registry of this category manager to the
381 /// specified `recordLevel`, `passLevel`, `triggerLevel`, and
382 /// `triggerAllLevel` values, respectively, if a category having
383 /// `categoryName` exists and each of the specified threshold values is
384 /// in the range `[0 .. 255]`. Otherwise, add to the registry a
385 /// category having `categoryName` and `recordLevel`, `passLevel`,
386 /// `triggerLevel`, and `triggerAllLevel` threshold values,
387 /// respectively, if there is no category having `categoryName` and each
388 /// of the specified threshold values is in the range `[0 .. 255]`.
389 /// Return the address of the (possibly newly-created) modifiable
390 /// category on success, and 0 otherwise (with no effect on any
391 /// category). The behavior is undefined unless a lock is not held by
392 /// this thread on the mutex returned by `rulesetMutex`.
393 Category *setThresholdLevels(const char *categoryName,
394 int recordLevel,
395 int passLevel,
396 int triggerLevel,
397 int triggerAllLevel);
398
399 /// Add the specified `ruleToAdd` to the set of (unique) rules
400 /// maintained by // this object. Return the number of rules added
401 /// (i.e., 1 on success and 0 if a rule with the same value is already
402 /// present). The behavior is undefined unless a lock is not held by
403 /// this thread on the mutex returned by `rulesetMutex`.
404 int addRule(const Rule& ruleToAdd);
405
406 /// Add each rule in the specified `ruleSet` to the set of (unique)
407 /// rules maintained by this object. Return the number of rules added.
408 /// The behavior is undefined unless a lock is not held by this thread
409 /// on the mutex returned by `rulesetMutex`. Note that each rule having
410 /// the same value as an existing rule will be ignored.
412
413 /// Remove the specified `ruleToRemove` from the set of (unique) rules
414 /// maintained by this object. Return the number of rules removed
415 /// (i.e., 1 on success and 0 if no rule having the same value is
416 /// found). The behavior is undefined unless a lock is not held by this
417 /// thread on the mutex returned by `rulesetMutex`.
418 int removeRule(const Rule& ruleToRemove);
419
420 /// Remove each rule in the specified `ruleSet` from the set of rules
421 /// maintained by this object. Return the number of rules removed. The
422 /// behavior is undefined unless a lock is not held by this thread on
423 /// the mutex returned by `rulesetMutex`.
425
426 /// Remove every rule from the set of rules maintained by this object.
427 /// The behavior is undefined unless a lock is not held by this thread
428 /// on the mutex returned by `rulesetMutex`.
430
431 /// Return a non-`const` reference to the mutex that is used to guard
432 /// against concurrent access to the rule set. A lock on the returned
433 /// mutex should be acquired before accessing the properties of the rule
434 /// set returned by `ruleSet`. The behavior is undefined unless a lock
435 /// is acquired solely for the purpose of calling `ruleSet`.
437
438 /// Invoke the specified `visitor` functor on each category managed by
439 /// this object, supplying that functor modifiable access to each
440 /// category. `visitor` must be a functor that can be called as if it
441 /// had the following signature:
442 /// @code
443 /// void operator()(Category *);
444 /// @endcode
445 template <class t_CATEGORY_VISITOR>
446 void visitCategories(const t_CATEGORY_VISITOR& visitor);
447
448 // ACCESSORS
449
450 /// Return a `const` reference to the category at the specified `index`
451 /// in the registry of this category manager. The behavior is undefined
452 /// unless `0 <= index < length()`.
453 const Category& operator[](int index) const;
454
455 /// Return the number of categories in the registry of this category
456 /// manager.
457 int length() const;
458
459 /// Return the address of the non-modifiable category having the
460 /// specified `categoryName` in the registry of this category manager,
461 /// or 0 if no such category exists.
462 const Category *lookupCategory(const char *categoryName) const;
463
464 /// Return a `const` reference to the rule set maintained by this
465 /// category manager. The mutex returned by `rulesetMutex` should be
466 /// locked prior to accessing the rule set.
467 const RuleSet& ruleSet() const;
468
469 /// Return the sequence number that tracks changes to the rule set
470 /// maintained by this category manager. The value returned by this
471 /// method is guaranteed to monotonically increase between calls before
472 /// and after the rule set is changed, and is otherwise implementation
473 /// defined.
475
476 /// Invoke the specified `visitor` functor on each category managed by
477 /// this object, supplying that functor non-modifiable access to each
478 /// category. `visitor` must be a functor that can be called as if it
479 /// had the following signature:
480 /// @code
481 /// void operator()(const Category *);
482 /// @endcode
483 template <class t_CATEGORY_VISITOR>
484 void visitCategories(const t_CATEGORY_VISITOR& visitor) const;
485
486 // BDE_VERIFY pragma: pop
487};
488
489#ifndef BDE_OMIT_INTERNAL_DEPRECATED
490
491 // =========================
492 // class CategoryManagerIter
493 // =========================
494
495/// This class defines an iterator providing sequential, read-only access to
496/// the categories in the registry of a category manager. The order of the
497/// iteration is undefined.
498///
499/// @deprecated Use @ref CategoryManager::visitCategories accessor
500/// instead.
501///
502/// See @ref ball_categorymanager
504
505 // DATA
506 const CategoryManager *d_cm_p; // associated category manager (held)
507 int d_index; // index into category manager
508
509 private:
510 // NOT IMPLEMENTED
512 CategoryManagerIter& operator=(const CategoryManagerIter&);
513
514 public:
515 // CREATORS
516
517 /// Create an iterator providing non-modifiable access to the categories
518 /// in the specified `categoryManager` that is initialized to refer to
519 /// the first category in the sequence of categories in the registry of
520 /// `categoryManager`, if one exists, and is initialized to be invalid
521 /// otherwise. The order of iteration is undefined. The behavior is
522 /// undefined unless the lifetime of `categoryManager` is at least as
523 /// long as the lifetime of this iterator.
524 explicit CategoryManagerIter(const CategoryManager& categoryManager);
525
526 /// Destroy this iterator.
528
529 // MANIPULATORS
530
531 /// Advance this iterator to refer to the next unvisited category. If
532 /// no such category exists, this iterator becomes invalid. The
533 /// behavior is undefined unless this iterator is initially valid. Note
534 /// that the order of iteration is undefined.
535 void operator++();
536
537 // ACCESSORS
538
539 /// Return a non-zero value if this iterator is valid, and 0 otherwise.
540 operator const void *() const;
541
542 /// Return a `const` reference to the category currently referred to by
543 /// this iterator. The behavior is undefined unless this iterator is
544 /// valid.
545 const Category& operator()() const;
546};
547
548 // ==========================
549 // class CategoryManagerManip
550 // ==========================
551
552/// This class defines an iterator providing sequential, modifiable access
553/// to the categories in the registry of a category manager. The order of
554/// the iteration is undefined.
555///
556/// @deprecated Use @ref CategoryManager::visitCategories manipulator
557/// instead.
558///
559/// See @ref ball_categorymanager
561
562 // DATA
563 CategoryManager *d_cm_p; // associated category manager (held)
564 int d_index; // index into category manager
565
566 private:
567 // NOT IMPLEMENTED
570
571 public:
572 // CREATORS
573
574 /// Create an iterator providing modifiable access to the categories in
575 /// the specified `categoryManager` that is initialized to refer to the
576 /// first category in the sequence of categories in the registry of
577 /// `categoryManager`, if one exists, and is initialized to be invalid
578 /// otherwise. The order of iteration is undefined. The behavior is
579 /// undefined unless the lifetime of `categoryManager` is at least as
580 /// long as the lifetime of this iterator.
581 explicit CategoryManagerManip(CategoryManager *categoryManager);
582
583 /// Destroy this iterator.
585
586 // MANIPULATORS
587
588 /// Advance this iterator to refer to the next unvisited category. If
589 /// no such category exists, this iterator becomes invalid. The
590 /// behavior is undefined unless this iterator is initially valid. Note
591 /// that the order of iteration is undefined.
592 void advance();
593
594 /// Return a non-`const` reference to the category currently referred to
595 /// by this iterator. The behavior is undefined unless this iterator is
596 /// valid.
598
599 // ACCESSORS
600
601 /// Return a non-zero value if this iterator is valid, and 0 otherwise.
602 operator const void *() const;
603};
604
605#endif // BDE_OMIT_INTERNAL_DEPRECATED
606
607// ============================================================================
608// INLINE FUNCTION DEFINITIONS
609// ============================================================================
610
611 // ---------------------
612 // class CategoryManager
613 // ---------------------
614
615// MANIPULATORS
616inline
618{
620 return *d_categories[index];
621}
622
623inline
625{
626 return d_ruleSetMutex;
627}
628
629template <class t_CATEGORY_VISITOR>
630void CategoryManager::visitCategories(const t_CATEGORY_VISITOR& visitor)
631{
633 for (bsl::vector<Category *>::iterator it = d_categories.begin();
634 it != d_categories.end();
635 ++it) {
636 visitor(*it);
637 }
638}
639
640// ACCESSORS
641inline
643{
645 return static_cast<int>(d_categories.size());
646}
647
648inline
650{
652 return *d_categories[index];
653}
654
655inline
657{
658 return d_ruleSet;
659}
660
661inline
663{
664 return d_ruleSetSequenceNumber;
665}
666
667template <class t_CATEGORY_VISITOR>
668void CategoryManager::visitCategories(const t_CATEGORY_VISITOR& visitor) const
669{
671 for (bsl::vector<Category *>::const_iterator it = d_categories.begin();
672 it != d_categories.end();
673 ++it) {
674 visitor(*it);
675 }
676}
677
678#ifndef BDE_OMIT_INTERNAL_DEPRECATED
679
680 // -------------------------
681 // class CategoryManagerIter
682 // -------------------------
683
684// CREATORS
685inline
686CategoryManagerIter::CategoryManagerIter(
687 const CategoryManager& categoryManager)
688: d_cm_p(&categoryManager)
689, d_index(0)
690{
691}
692
693// MANIPULATORS
694inline
696{
697 ++d_index;
698}
699
700// ACCESSORS
701inline
702CategoryManagerIter::operator const void *() const
703{
704 return (0 <= d_index && d_index < d_cm_p->length()) ? this : 0;
705}
706
707inline
709{
710 return d_cm_p->operator[](d_index);
711}
712
713 // --------------------------
714 // class CategoryManagerManip
715 // --------------------------
716
717// CREATORS
718inline
719CategoryManagerManip::CategoryManagerManip(CategoryManager *categoryManager)
720: d_cm_p(categoryManager)
721, d_index(0)
722{
723}
724
725// MANIPULATORS
726inline
728{
729 ++d_index;
730}
731
732inline
734{
735 return d_cm_p->operator[](d_index);
736}
737
738// ACCESSORS
739inline
740CategoryManagerManip::operator const void *() const
741{
742 return (0 <= d_index && d_index < d_cm_p->length()) ? this : 0;
743}
744
745#endif // BDE_OMIT_INTERNAL_DEPRECATED
746
747} // close package namespace
748
749
750#endif
751
752// ----------------------------------------------------------------------------
753// Copyright 2015 Bloomberg Finance L.P.
754//
755// Licensed under the Apache License, Version 2.0 (the "License");
756// you may not use this file except in compliance with the License.
757// You may obtain a copy of the License at
758//
759// http://www.apache.org/licenses/LICENSE-2.0
760//
761// Unless required by applicable law or agreed to in writing, software
762// distributed under the License is distributed on an "AS IS" BASIS,
763// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
764// See the License for the specific language governing permissions and
765// limitations under the License.
766// ----------------------------- END-OF-FILE ----------------------------------
767
768/** @} */
769/** @} */
770/** @} */
Definition ball_category.h:362
Definition ball_categorymanager.h:503
const Category & operator()() const
Definition ball_categorymanager.h:708
void operator++()
Definition ball_categorymanager.h:695
~CategoryManagerIter()=default
Destroy this iterator.
Definition ball_categorymanager.h:560
void advance()
Definition ball_categorymanager.h:727
~CategoryManagerManip()=default
Destroy this iterator.
Category & operator()()
Definition ball_categorymanager.h:733
Definition ball_categorymanager.h:231
Category * lookupCategory(const char *categoryName)
CategoryManager(bslma::Allocator *basicAllocator=0)
Category * addCategory(const char *categoryName, int recordLevel, int passLevel, int triggerLevel, int triggerAllLevel)
const RuleSet & ruleSet() const
Definition ball_categorymanager.h:656
int addRule(const Rule &ruleToAdd)
int addRules(const RuleSet &ruleSet)
int removeRules(const RuleSet &ruleSet)
Category * lookupCategory(CategoryHolder *categoryHolder, const char *categoryName)
const Category * lookupCategory(const char *categoryName) const
bsls::Types::Int64 ruleSetSequenceNumber() const
Definition ball_categorymanager.h:662
int removeRule(const Rule &ruleToRemove)
Category & operator[](int index)
Definition ball_categorymanager.h:617
Category * setThresholdLevels(const char *categoryName, int recordLevel, int passLevel, int triggerLevel, int triggerAllLevel)
int length() const
Definition ball_categorymanager.h:642
void visitCategories(const t_CATEGORY_VISITOR &visitor)
Definition ball_categorymanager.h:630
Category * addCategory(CategoryHolder *categoryHolder, const char *categoryName, int recordLevel, int passLevel, int triggerLevel, int triggerAllLevel)
bslmt::Mutex & rulesetMutex()
Definition ball_categorymanager.h:624
~CategoryManager()
Destroy this category manager.
Definition ball_category.h:184
Definition ball_ruleset.h:151
Definition ball_rule.h:177
Definition bslstl_unorderedmap.h:1089
Definition bslstl_vector.h:1025
VALUE_TYPE * iterator
Definition bslstl_vector.h:1057
VALUE_TYPE const * const_iterator
Definition bslstl_vector.h:1058
Definition bslma_allocator.h:457
Definition bslmt_lockguard.h:234
Definition bslmt_mutex.h:315
Definition bslmt_readlockguard.h:287
Definition bslmt_readerwriterlock.h:294
Definition bsls_atomic.h:892
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition ball_administration.h:214
Definition bdlb_cstringequalto.h:120
Definition bdlb_cstringhash.h:234
long long Int64
Definition bsls_types.h:132