Public Types | |
| typedef Tag | tag_ype |
| the tag type | |
Public Member Functions | |
| template<class Derived> | |
| item_collection (context< Derived > *ctxt) | |
| constructor which registers collection with given context | |
| void | put (const Tag &tag, const Item &item, int get_count=-1) |
| 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 &t, Item &i) 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 | 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 | |
Tag and Item must provide copy and default constructors and the assigment operator.
If Tag is not convertable into size_t, a suitable cnc_tag_hash_compare struct must be provided which satisifies the requirements for tbb::concurrent_hash_map. The default cnc_tag_hash_compare works for types that can be converted to size_t and have an operator==. You can provide a specialized template for cnc_tag_hash_compare or specify and implement your own compatible class.
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.
Definition at line 166 of file cnc.h.
| item_collection | ( | context< Derived > * | ctxt | ) | [inline] |
| void put | ( | const Tag & | tag, | |
| const Item & | item, | |||
| int | get_count = -1 | |||
| ) |
make copies of the item and the tag and store them in the collection.
| tag | the tag identifying the item | |
| item | the item to be copied and stored | |
| get_count | after get_count many 'get()'s the item can be removed by default, the item is not removed until the collection is deleted. |
| void get | ( | const Tag & | tag, | |
| Item & | item | |||
| ) | const |
get an item
| tag | the tag identifying the item | |
| item | reference to item to store result in |
| DataNotReady | throws exception if data not yet available. |
| bool unsafe_get | ( | const Tag & | t, | |
| Item & | i | |||
| ) | const |
try to get an item and store it in given object (non-blocking)
| tat | the tag identifying the item | |
| item | reference to item to store result in |
| DataNotReady | might throw exception if data not available (yet) |
| const_iterator begin | ( | ) | const |
returns begin() as in STL containers
| const_iterator end | ( | ) | const |
returns end() as in STL containers
1.5.6