faudes::IndexSet Class Reference
[State, Event and Transition Set]

Set of indices. More...

#include <cfl_indexset.h>

List of all members.

Public Types

typedef TBaseSet< Idx >::Iterator Iterator
 Iterators on indexset.

Public Member Functions

 IndexSet (void)
 Constructor.
 IndexSet (const IndexSet &rOtherSet)
 Copy-constructor.
 IndexSet (const TBaseSet< Idx > &rOtherSet)
 Copy-constructor.
 IndexSet (const std::string &rFilename, const std::string &rLabel="")
 Construct from file.
virtual ~IndexSet (void)
 Virtual destructor.
Idx MaxIndex (void) const
 Get maximum index used in this set (0 for emptyset).
bool Valid (const Idx &rIndex) const
 Test whether index is not 0.
Idx Insert (void)
 Insert new index to set.
bool Insert (const Idx &rIndex)
 Insert specified index.
Idx Signature (void) const
 Compute an Idx type signature for a Set.
std::string Str (const Idx &rIndex) const
 Return pretty printable index.

Protected Member Functions

virtual void DoAssign (const IndexSet &rSource)
 Assign my members.
virtual void DoWrite (TokenWriter &tw, const std::string &rLabel="", const Type *pContext=0) const
 Write to TokenWriter, see Type::Write for public wrappers.
virtual void DoXWrite (TokenWriter &tw, const std::string &rLabel="", const Type *pContext=0) const
 Write to TokenWriter, see Type::Write for public wrappers.
virtual void DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Read from TokenReader, see Type::Read for public wrappers.

Friends

class TaIndexSet
 We implement "protected privacy for template classes" by friendship.

Detailed Description

Set of indices.

This class is built on top of the faudes version TBaseSet of STL sets. It provides the essentials of the STL interface and inherits the standard token IO interface from Type, so you may use Read and Write for file/string/console IO.

IndexSet is used as common base for TaIndexSet (indices with attributes), NameSet (indices with symbolic names) and TaNameSet (indices with attributes and symbolic names).

The index of value 0 is reserved to indicate the invalid index. If the macro FAUDES_CHECKED is defined, the attempt to insert an index 0 triggers an exception (id 61). Invalid iterators throw an exception (id 62) when used as an argument to a IndexSet function.

Technically, file IO is done by TaIndexSet functions. This requires a copy and for that reason may be reimplemented in a future versions. The format is demonstrated by the following example of a set with name "MySet" consisting of indices 17, 25, 26, 27, 28, 40:

 <Myset> 
 17 
 <Consecutive> 25 4 </Consecutive> 
 40 
 </MySet>  

Theere is a minimum number of consecutive indices for the use of the consecutive section defined in definitions.h.

Definition at line 78 of file cfl_indexset.h.


Member Typedef Documentation


Constructor & Destructor Documentation

faudes::IndexSet::IndexSet ( void   ) 

Constructor.

Definition at line 55 of file cfl_indexset.cpp.

faudes::IndexSet::IndexSet ( const IndexSet rOtherSet  ) 

Copy-constructor.

Definition at line 61 of file cfl_indexset.cpp.

faudes::IndexSet::IndexSet ( const TBaseSet< Idx > &  rOtherSet  ) 

Copy-constructor.

Definition at line 69 of file cfl_indexset.cpp.

faudes::IndexSet::IndexSet ( const std::string &  rFilename,
const std::string &  rLabel = "" 
)

Construct from file.

Uses the Read(TokenReader&, const std::string&) function to read. a IndexSet from section rLabel in file rFilename.

Parameters:
rFilename Name of file to read
rLabel Section to read
Exceptions:
Exception 
  • IO Errors (id 1)
  • Token mismatch (id 50, 51, 52)

Definition at line 77 of file cfl_indexset.cpp.

virtual faudes::IndexSet::~IndexSet ( void   )  [inline, virtual]

Virtual destructor.

Definition at line 124 of file cfl_indexset.h.


Member Function Documentation

void faudes::IndexSet::DoAssign ( const IndexSet rSource  )  [protected, virtual]

Assign my members.

This method maintains attributes provided that the type can be appropriately casted.

Parameters:
rSource Source to copy from
Returns:
Ref to this set

Definition at line 85 of file cfl_indexset.cpp.

void faudes::IndexSet::DoRead ( TokenReader rTr,
const std::string &  rLabel = "",
const Type pContext = 0 
) [protected, virtual]

Read from TokenReader, see Type::Read for public wrappers.

This method invokes TokenReader::ReadBegin() to seek the specified section, reads subsequent integer tokens as indexes, and calls matching TokenReader::ReadEnd(). If no section is specified, the section is assumed to start at the current position of the token stream. If the current position is no begin token, the section "IndexSet" is read. When used by a derived class with attributes, attributes are read, too.

Parameters:
rTr Reference to tokenreader
rLabel Section to read, defaults to current begin label or else "IndexSet"
pContext Read context to provide contextual information
Exceptions:
Exception 
  • IO errors (id 1)
  • token mismatch (id 50, 51, 52)

Reimplemented from faudes::TBaseSet< Idx >.

Definition at line 198 of file cfl_indexset.cpp.

void faudes::IndexSet::DoWrite ( TokenWriter tw,
const std::string &  rLabel = "",
const Type pContext = 0 
) const [protected, virtual]

Write to TokenWriter, see Type::Write for public wrappers.

Appends the IndexSet to TokenWriter. This will write a section with label as specified that holds integer tokens to represent the IndexSet. For non-default attribute values, the respective index is followed by the attribute value. The latter may consist of sections (or tokens different from integer or string) to allow for transparent reading; see AttributeVoid and AttributeFlags. Example for a set with name "MySet" consisting of indices 17, 25, 40, where index 25 has a nontrivial attribute attached:

 <Myset> 
 17 
 25 <AValue> "Some Value" </AValue> 
 40 
 </MySet>  
Parameters:
tw Reference to TokenWriter
rLabel Label of section to write, defaults to name of set or "IndexSet"
pContext Write context to provide contextual information
Exceptions:
Exception 
  • IO errors (id 2)

Reimplemented from faudes::TBaseSet< Idx >.

Definition at line 92 of file cfl_indexset.cpp.

void faudes::IndexSet::DoXWrite ( TokenWriter tw,
const std::string &  rLabel = "",
const Type pContext = 0 
) const [protected, virtual]

Write to TokenWriter, see Type::Write for public wrappers.

Appends the IndexSet to TokenWriter using XML format.

Parameters:
tw Reference to TokenWriter
rLabel Label of section to write, defaults to name of set or "IndexSet"
pContext Write context to provide contextual information
Exceptions:
Exception 
  • IO errors (id 2)

Reimplemented from faudes::Type.

Definition at line 142 of file cfl_indexset.cpp.

bool faudes::IndexSet::Insert ( const Idx rIndex  )  [virtual]

Insert specified index.

Parameters:
rIndex Index to insert
Returns:
True if index was new to set

Reimplemented from faudes::TBaseSet< Idx >.

Reimplemented in faudes::TaIndexSet< Attr >, faudes::TaIndexSet< DiagLabelSet >, faudes::TaIndexSet< HioStateFlags >, and faudes::TaIndexSet< StateAttr >.

Definition at line 321 of file cfl_indexset.cpp.

Idx faudes::IndexSet::Insert ( void   ) 

Insert new index to set.

Returns:
New index

Reimplemented in faudes::TaIndexSet< Attr >, faudes::TaIndexSet< DiagLabelSet >, faudes::TaIndexSet< HioStateFlags >, and faudes::TaIndexSet< StateAttr >.

Definition at line 313 of file cfl_indexset.cpp.

Idx faudes::IndexSet::MaxIndex ( void   )  const

Get maximum index used in this set (0 for emptyset).

Returns:
max indices

Definition at line 298 of file cfl_indexset.cpp.

Idx faudes::IndexSet::Signature ( void   )  const

Compute an Idx type signature for a Set.

The value is computed by summing up the product of every index with an integer starting at 1 (for the first index) and ending at Size() (for the last index).

Returns:
Idx type set signature

Definition at line 333 of file cfl_indexset.cpp.

std::string faudes::IndexSet::Str ( const Idx rIndex  )  const [inline, virtual]

Return pretty printable index.

Parameters:
rIndex Index to print
Returns:
String

Reimplemented from faudes::TBaseSet< Idx >.

Definition at line 185 of file cfl_indexset.h.

bool faudes::IndexSet::Valid ( const Idx rIndex  )  const [virtual]

Test whether index is not 0.

Parameters:
rIndex Index to test
Returns:
True if idx!=0

Reimplemented from faudes::TBaseSet< Idx >.

Definition at line 327 of file cfl_indexset.cpp.


Friends And Related Function Documentation

friend class TaIndexSet [friend]

We implement "protected privacy for template classes" by friendship.

This is used for the pragmatic implemention conversion constructors.

Definition at line 88 of file cfl_indexset.h.


The documentation for this class was generated from the following files:

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen