BDE 4.14.0 Production release
|
Provide a list of attribute container addresses.
This component defines a class ball::AttributeContainerList
that provides a linked list of ball::AttributeContainer
object addresses. Addresses can be prepended (to the front of the list) using the pushFront()
method. The pushFront()
method returns an iterator that can be used later to efficiently remove the added element. The ball::AttributeContainerList
also provides a hasValue()
operation, that returns true
if any of the attribute containers in the list contain the supplied attribute, and false
otherwise. The ball::AttributeContainerList
maintains a store of free list-nodes to minimize the amount of memory allocation required if addresses are frequently added and removed from the container. This component also defines a class ball::AttributeContainerListIterator
(as well as the alias ball::AttributeContainerList::iterator)
that provides an STL-style iterator over the addresses in a ball::AttributeContainer
.
This component participates in the implementation of "Rule-Based Logging". For more information on how to use that feature, please see the package level documentation and usage examples for "Rule-Based Logging".
ball::AttributeContainerList
is const thread-safe, meaning that accessors may be invoked concurrently from different threads, but it is not safe to access or modify a ball::AttributeContainerList
in one thread while another thread modifies the same object.
This section illustrates intended use of this component.
In the following example we demonstrate how to create a ball::AttributeContainerList
object, how to add and remove elements from the list, and how to walk the list of attribute container addresses.
We start by creating three attribute sets that we will use to populate our attribute container list. Note that this example uses the AttributeSet
implementation of the ball::AttributeContainer
protocol defined in the ball_attributecontainer component documentation.
We now create a ball::AttributeContainerList
and add the three attribute container addresses to the list:
We can use the hasValue()
operation to test which attribute value are contained within the list of containers:
We can use the iterators to efficiently remove elements from the list:
Finally, we can use either the stream operator or the print()
method to print the attributes within an attribute container list:
The resulting output will be the following:
Note that the output shows the values in s2
(i.e., ("Set2", 2)
) and then the values in s1
(i.e., ("Set1", 1)
).