classias::quark_base< item_base > Class Template Reference


Detailed Description

template<class item_base>
class classias::quark_base< item_base >

Quark for associating an item with an identifier.

Parameters:
item_base The type of an item.


Public Types

typedef item_base item_type
 The type representing an item.
typedef quark_base< item_base > this_class
 The type of this class.
typedef std::vector< item_typeinverse_map_type
 The type implementing a vector of items.
typedef inverse_map_type::size_type value_type
 The type representing a unique identifier.
typedef UNORDERED_MAP< item_type,
value_type
forward_map_type
 The type associating an item to its unique identifier.

Public Member Functions

 quark_base ()
 Constructs the object.
 quark_base (const this_class &src)
 Constructs the object by copying the source object.
virtual ~quark_base ()
 Destructs the object.
this_classoperator= (const this_class &src)
 Copies another object to this object.
value_type size () const
 Returns the number of item-identifier associations.
bool exists (const item_type &x)
 Tests whether an item has an identifier assigned.
value_type operator() (const item_type &x)
 Assigns the unique identifier for an item.
value_type associate (const item_type &x)
 Assigns a unique identifier for a new item.
value_type to_value (const item_type &x) const
 Returns the unique identifier for an item.
value_type to_value (const item_type &x, const value_type &def) const
 Returns the unique identifier for an item.
const item_typeto_item (const value_type &v) const
 Returns the item for the unique identifier.

Protected Attributes

forward_map_type m_fwd
 Forward mapping: (item0, item1) -> value.
inverse_map_type m_inv
 Inverse mapping: value -> (item0, item1).


Constructor & Destructor Documentation

template<class item_base>
classias::quark_base< item_base >::quark_base ( const this_class src  )  [inline]

Constructs the object by copying the source object.

Parameters:
src The source object.


Member Function Documentation

template<class item_base>
this_class& classias::quark_base< item_base >::operator= ( const this_class src  )  [inline]

Copies another object to this object.

Parameters:
src The source object.
Returns:
this_class& The reference to this object.

template<class item_base>
value_type classias::quark_base< item_base >::size (  )  const [inline]

Returns the number of item-identifier associations.

Return values:
value_type The number of associations between items and identifiers.

template<class item_base>
bool classias::quark_base< item_base >::exists ( const item_type x  )  [inline]

Tests whether an item has an identifier assigned.

Parameters:
x The item.
Return values:
bool true if the item is known.

template<class item_base>
value_type classias::quark_base< item_base >::operator() ( const item_type x  )  [inline]

Assigns the unique identifier for an item.

If the item is unknown, this function assigns a new unique identifier to the item and return it.

Parameters:
x The item.
Returns:
value_type The unique identifier.

template<class item_base>
value_type classias::quark_base< item_base >::associate ( const item_type x  )  [inline]

Assigns a unique identifier for a new item.

If the item is unknown, this function assigns a new unique identifier to the item and return it. If the item is known, this function returns the existing identifier that was associated with the item.

Parameters:
x The item.
Returns:
value_type The unique identifier.

template<class item_base>
value_type classias::quark_base< item_base >::to_value ( const item_type x  )  const [inline]

Returns the unique identifier for an item.

If the item is unknown, this function throws quark_error.

Parameters:
x The item.
Returns:
value_type The unique identifier.
Exceptions:
quark_error. 

template<class item_base>
value_type classias::quark_base< item_base >::to_value ( const item_type x,
const value_type def 
) const [inline]

Returns the unique identifier for an item.

If the item is unknown, this function returns the default identifier.

Parameters:
x The item.
def The default identifier if the item is unknown.
Returns:
value_type The unique identifier.

template<class item_base>
const item_type& classias::quark_base< item_base >::to_item ( const value_type v  )  const [inline]

Returns the item for the unique identifier.

If the unique identifier is unknown, this function throws quark_error.

Parameters:
v The unique identifier.
Returns:
item_type& The reference to the item associated with the identifier.
Exceptions:
quark_error. 


Copyright (c) 2002-2009 by Naoaki Okazaki
Mon Dec 28 23:41:05 2009