CnC
 All Classes Namespaces Functions Variables Typedefs Enumerator Friends
Public Types | Public Member Functions
tag_collection< Tag, Tuner > Class Template Reference

A tag collection is a set of tags of the same type. It is used to prescribe steps. By default, tags are not stored. More...

List of all members.

Public Types

typedef Tag tag_type
 the tag type
typedef
Tuner::tag_table_type::const_iterator 
const_iterator
 const forward iterator as in STL
typedef
Internal::tag_collection_base
< Tag, Tuner >::callback_type 
callback_type

Public Member Functions

template<class Derived >
 tag_collection (context< Derived > &ctxt, const std::string &name, const Tuner &tnr)
 constructor which registers collection with given context
template<typename UserStep , typename STuner , typename Arg >
error_type prescribes (const step_collection< UserStep, STuner > &s, Arg &arg)
 Declare the prescription relationship between the tag collection and a step collection.
void put (const Tag &t)
 prescribe the associated step. If we are preserving tags for this collection, make a copy of the tag and store it in the collection.
void put_range (const typename Tuner::range_type &r)
 prescribe an entire range of tags
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 tag instances from the collection
size_t size ()
 returns number of elements in collection
bool empty ()
 returns true if size()==0, false otherwise
void on_put (callback_type *cb)

Detailed Description

template<typename Tag, typename Tuner = tag_tuner<>>
class CnC::tag_collection< Tag, Tuner >

A tag collection is a set of tags of the same type. It is used to prescribe steps. By default, tags are not stored.

Tag must provide copy and default constructors and the assigment operator.

If Tag is not convertable into size_t, a suitable hash_compare class 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 specialized templates for cnc_hash and/or cnc_equal or cnc_tag_hash_compare or specify and implement your own compatible class.

Definition at line 128 of file cnc.h.


Member Typedef Documentation

typedef Internal::tag_collection_base< Tag, Tuner >::callback_type callback_type

callback type for tag-collections

See also:
register_callback

Definition at line 214 of file cnc.h.


Constructor & Destructor Documentation

tag_collection ( context< Derived > &  ctxt,
const std::string &  name,
const Tuner &  tnr 
)

constructor which registers collection with given context

Parameters:
ctxtthe context this collection belongs to
namean optional name, used for debug output and tracing
tnran optional tuner object which must persist throughout the lifetime of the tag-collection by default a default-constructed tuner will be used.

Member Function Documentation

const_iterator begin ( ) const

returns begin() as in STL containers

Note:
iteration through collections is not thread safe; use it only between calls to CnC::context::wait() and putting tags
const_iterator end ( ) const

returns end() as in STL containers

Note:
iteration through collections is not thread safe; use it only between calls to CnC::context::wait() and putting tags
void on_put ( callback_type cb)

Call this to register a on-put-callback for the tag-collection. When registered, callback.on_put( tag ) gets called when a tag was put successfully. e.g. it will not get called a second time on a second put if memoization is enabled. The call is blocking, e.g. the triggering/calling "put" will not return to its caller until the callback has terminated. The provided object will be deleted when the collection is deleted.

See also:
graph for more details, in particular about thread-safety issues
Note:
not thread-safe, to be called in safe state only (between program start or calling context::wait() and putting the first tag or item).
not needed for regular CnC
error_type prescribes ( const step_collection< UserStep, STuner > &  s,
Arg &  arg 
)

Declare the prescription relationship between the tag collection and a step collection.

Parameters:
sclass representing step collection. s is required to provide the following const method, where Arg a is the optional parameter described below.
 int execute( const Tag & tag, Arg & a ) const; 

A copy of s will be created by calling its copy constructor.

Parameters:
argThis argument will be the parameter passed to Step::execute and the tuner methods. The object must exist as long as instances of the given step might be executed. Usually arg will be the containing context.
Returns:
0 if succeeded, error code otherwise
void put ( const Tag &  t)

prescribe the associated step. If we are preserving tags for this collection, make a copy of the tag and store it in the collection.

Parameters:
tthe tag to be put
void put_range ( const typename Tuner::range_type &  r)

prescribe an entire range of tags

Parameters:
rA range, which is potentially splittible through a partitioner. Following the TBB range/splittable concept, extended by STL container requirements, a range R must provide the following interface:
  • R::R( const R& ) : Copy constructor.
  • int size() : return number of elements (tags) in range
  • const_iterator : forward iterator (operator++, operator tag_type() const) to make it work with tbb::blocked_range, the cast operator is used instead of operator*().
  • const_iterator begin() const : first member of range
  • const_iterator end() const : Exclusive upper bound on range Using it with the default_partitioner also requires
  • R::R( R& r, tbb::split ) : Split r into two subranges.
  • bool R::is_divisible() const : true if range can be partitioned into two subranges.
void unsafe_reset ( )

removes all of the tag instances from the collection

Note:
not thread-safe, to be called in safe state only (between program start or calling context::wait() and putting the first tag or item).

The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerator Friends