Public Member Functions
|template<class Derived > |
| ||item_collection (context< Derived > &ctxt, const std::string &name, const Tuner &tnr)|
| ||constructor which registers collection with given context |
|void ||set_max (size_t mx)|
| ||Declares the maxium tag value. |
|void ||put (const Tag &tag, const Item &item)|
| ||make copies of the item and the tag and store them in the collection. |
|void ||get (const Tag &tag, Item &item) const |
| ||get an item |
|bool ||unsafe_get (const Tag &tag, Item &item) const |
| ||try to get an item and store it in given object (non-blocking) |
|const_iterator ||begin () const |
| ||returns begin() as in STL containers |
|const_iterator ||end () const |
| ||returns end() as in STL containers |
|void ||unsafe_reset ()|
| ||removes all of the item instances from the collection |
size_t ||size ()|
| ||returns number of elements in collection |
bool ||empty ()|
| ||returns true if size()==0, false otherwise |
template<typename Tag, typename Item, typename Tuner = hashmap_tuner>
class CnC::item_collection< Tag, Item, Tuner >
An item collection is a mapping from tags to items.
Tag and Item must provide copy and default constructors and the assigment operator.
Th last template argument is an optional tuner. The tuner provides tuning hints, such as the type of the data store or information about its use in distributed environments. Most importantly it tells the runtime and compiler which type of data store it should use. By default that's a hash-map (hashmap_tuner). For non default-supported tag types (e.g. those that are not convertable into size_t) a suitable cnc_hash template specialization must be provided. If in addition your type does not support std::equal_to you also need to specialize cnc_equal. For the vector-based data store (vector_tuner) that's not necessary, but the tag-type must then be convertible to and from size_t.
- See also:
- CnC::item_tuner for more information.
The CnC runtime will make a copy of your item when it is 'put' into the item_collection. The CnC runtime will delete the copied item copy once the get-count reaches 0 (or, if no get-count was provided, once the collection is destroyed). If the item-type is a pointer type, the runtime will not delete the memory the item points to. If you store pointeres, you have to care for the appropriate garbage collection, e.g. you might consider using smart pointers.
Definition at line 230 of file cnc.h.