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

#include <nameset.h>

Inheritance diagram for faudes::NameSet:

faudes::IndexSet faudes::TBaseSet< Idx > faudes::TaNameSet< Attr > List of all members.

Detailed Description

Set of indices with symbolic names.

In a NameSet, symbolic names are mandatory. The class is derived from IndexSet and uses a pointer to a SymbolTable to maintain the symbolic names. The static SymbolTable is used as default, which in the context of libfaudes becomes the global event symbol table. It is an error to refer to an unknown symbolic name or to an index with no name associated. When FAUDES_CHECKED is defined, an exception will be thrown. It is also considered an error to relate two NameSets that refer to different SymbolTables (using e.g. SetUnion).

Since symbolic names are mandatory, file IO uses names rather than indices. Technically, file IO is done by TaNameSet 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 "Alphabet" consisting of events "alpha", "beta" and "gamma":

 <Alphabet> 
 "alpha" "beta" "gamma"
 <\Alphabet> 
Note that when reading a file, indices will be associated with the symbolic names based on availability. Within one libfaudes session, each individual event will be referred to by a unique index.

Definition at line 73 of file nameset.h.

Public Member Functions

 NameSet (void)
 Constructor for NameSet referring to the static SymbolTable.
 NameSet (const NameSet &rOtherSet)
 Copy-constructor from other NameSet.
 NameSet (const std::string &rFilename, const std::string &rLabel="NameSet")
 Constructor from file.
NameSet NewN () const
 Return an empty NameSet with same SymbolTable as this set.
NameSetNewP () const
 Return a pointer to a NameSet with same Symboltable assigned.
SymbolTableSymbolTablep (void) const
 Get Pointer mpSymbolTable.
void SymbolTablep (SymbolTable *pSymTab)
 Set SymbolTable reference.
bool Insert (Idx index)
 Add an element by index.
Idx Insert (const std::string &rName)
 Add an element by its symbolic name.
void InsertSet (const NameSet &rOtherSet)
 Inserts elements of rOtherSet.
bool Erase (Idx index)
 Delete element by index.
bool Erase (const std::string &rName)
 Delete element by symbolic name.
Iterator Erase (const Iterator &pos)
 Delete element by iterator.
void EraseSet (const NameSet &rOtherSet)
 Erase elements specified by rOtherSet.
void SymbolicName (Idx index, const std::string &rName)
 Set new name for existing index.
void SymbolicName (const std::string &rName, const std::string &rNewName)
 Set new name for existing name FAUDES_CHECKED checks if the specified name exists in NameSet.
std::string SymbolicName (Idx index) const
 Name lookup.
Idx Index (const std::string &rName) const
 Index lookup.
bool Exists (Idx index) const
 Test existence of index.
bool Exists (const std::string &rName) const
 Test existence of name.
NameSet::Iterator Find (Idx index) const
 Find iterator for index.
NameSet::Iterator Find (const std::string &rName) const
 Find iterator for name.
NameSet operator+ (const NameSet &rOtherSet) const
 Set union operator.
NameSet operator- (const NameSet &rOtherSet) const
 Set difference operator.
NameSet operator * (const NameSet &rOtherSet) const
 Set intersection operator.
bool operator== (const NameSet &rOtherSet) const
 Test for equality.
bool operator!= (const NameSet &rOtherSet) const
 Test for unequality.
bool operator<= (const NameSet &rOtherSet) const
 Test for subset.
bool operator>= (const NameSet &rOtherSet) const
 Test for superset.
std::string Str (Idx index) const
 Return pretty printable symbolic name for index.

Protected Member Functions

void DoWrite (TokenWriter &tw, const std::string &rLabel) const
 Write to TokenWriter, see TBaseSet for public wrappers.
void DoDWrite (TokenWriter &tw) const
 Write debug info to TokenWriter, see TBaseSet for public wrapper.
void DoRead (TokenReader &tr, const std::string &rLabel="NameSet")
 Read from TokenReader, see TBaseSet for public wrappers.

Protected Attributes

SymbolTablempSymbolTable
 Pointer to local SymbolTable.

Friends

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


Constructor & Destructor Documentation

faudes::NameSet::NameSet void   ) 
 

Constructor for NameSet referring to the static SymbolTable.

Definition at line 28 of file nameset.cpp.

faudes::NameSet::NameSet const NameSet rOtherSet  ) 
 

Copy-constructor from other NameSet.

This also copies the SymbolTable reference, hence the new NameSet will use the same SymbolTable as rOtherSet.

Parameters:
rOtherSet Set to copy

Definition at line 35 of file nameset.cpp.

faudes::NameSet::NameSet const std::string &  rFilename,
const std::string &  rLabel = "NameSet"
 

Constructor from file.

This constructor reads a NameSet from a file using the DoRead(TokenReader&, const std::string&) function. The section is specified by rLabel and the static SymbolTable is used.

Parameters:
rFilename Name of file
rLabel Section for the set in the file;

Definition at line 43 of file nameset.cpp.


Member Function Documentation

void faudes::NameSet::DoDWrite TokenWriter tw  )  const [protected, virtual]
 

Write debug info to TokenWriter, see TBaseSet for public wrapper.

The debug version writes a format that includes symbolic names and indices.

Parameters:
tw Reference to TokenWriter
Exceptions:
Exception 
  • IO errors (id 2)

Reimplemented from faudes::TBaseSet< Idx >.

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 84 of file nameset.cpp.

void faudes::NameSet::DoRead TokenReader tr,
const std::string &  rLabel = "NameSet"
[protected, virtual]
 

Read from TokenReader, see TBaseSet for public wrappers.

Uses TaNameSet::Read(TokenReader&,const std::string&) with void attributes. It is an error if the file contains an index (id 52).

Parameters:
tr Reference to TokenReader
rLabel Label to read
Exceptions:
Exception 
  • IO errors (id 1)
  • token mismatch (id 50, 51, 52)

Reimplemented from faudes::IndexSet.

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 90 of file nameset.cpp.

void faudes::NameSet::DoWrite TokenWriter tw,
const std::string &  rLabel
const [protected, virtual]
 

Write to TokenWriter, see TBaseSet for public wrappers.

Parameters:
tw Reference to TokenWriter
rLabel Label of the section to write
Exceptions:
Exception 
  • IO errors (id 2)

Reimplemented from faudes::IndexSet.

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 78 of file nameset.cpp.

NameSet::Iterator faudes::NameSet::Erase const Iterator pos  )  [virtual]
 

Delete element by iterator.

Symbolic nam is not removed from SymbolTable.

Parameters:
pos NameSet::iterator
Returns:
iterator to next element
Exceptions:
Exception 
  • invalid iterator (id 62)

Reimplemented from faudes::TBaseSet< Idx >.

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 153 of file nameset.cpp.

bool faudes::NameSet::Erase const std::string &  rName  ) 
 

Delete element by symbolic name.

The symbolic name is not removed from the SymbolTable

Parameters:
rName symbolic name
Returns:
True if element did exist
Exceptions:
Exception 
  • unknown symbolic name (id 66)

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 139 of file nameset.cpp.

bool faudes::NameSet::Erase Idx  index  ) 
 

Delete element by index.

The symbolic name is not removed from the SymbolTable.

Parameters:
index Index
Returns:
True if element did exist

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 133 of file nameset.cpp.

void faudes::NameSet::EraseSet const NameSet rOtherSet  ) 
 

Erase elements specified by rOtherSet.

Parameters:
rOtherSet Other StateSet
Exceptions:
Exception 
  • symboltable mismatch (id 67)

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 158 of file nameset.cpp.

bool faudes::NameSet::Exists const std::string &  rName  )  const
 

Test existence of name.

Parameters:
rName Symbolic name to test
Returns:
True if index is in this set

Definition at line 213 of file nameset.cpp.

bool faudes::NameSet::Exists Idx  index  )  const
 

Test existence of index.

Parameters:
index Index to test
Returns:
True if index is in this set

Definition at line 208 of file nameset.cpp.

NameSet::Iterator faudes::NameSet::Find const std::string &  rName  )  const
 

Find iterator for name.

Returns either a valid iterator or End() for non-existent.

Parameters:
rName Name to find
Returns:
NameSet::Iterator

Definition at line 223 of file nameset.cpp.

NameSet::Iterator faudes::NameSet::Find Idx  index  )  const
 

Find iterator for index.

Returns either a valid iterator or End() for non-existent.

Parameters:
index Index to find
Returns:
NameSet::Iterator

Definition at line 218 of file nameset.cpp.

Idx faudes::NameSet::Index const std::string &  rName  )  const
 

Index lookup.

Parameters:
rName Symbolic name to look up
Returns:
Corresponding index or 0 for non-existent

Definition at line 203 of file nameset.cpp.

Idx faudes::NameSet::Insert const std::string &  rName  ) 
 

Add an element by its symbolic name.

If the name is unknown, a new index will be generated and recorded in the symboltable. If the name is known, the corresponding index will be added to the set.

Parameters:
rName Symbolic name of element to add
Returns:
Index of (new) element

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 112 of file nameset.cpp.

bool faudes::NameSet::Insert Idx  index  ) 
 

Add an element by index.

Index must be already known to the global SymbolTable.

Parameters:
index Index to add
Returns:
True, if element was new to set
Exceptions:
Exception 
  • no symbolic name for index (id 65)

Reimplemented from faudes::IndexSet.

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 100 of file nameset.cpp.

void faudes::NameSet::InsertSet const NameSet rOtherSet  ) 
 

Inserts elements of rOtherSet.

Parameters:
rOtherSet Other NameSet
Exceptions:
Exception 
  • symboltable mismatch (id 67)

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 120 of file nameset.cpp.

NameSet faudes::NameSet::NewN  )  const
 

Return an empty NameSet with same SymbolTable as this set.

Returns:
New empty NameSet

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 57 of file nameset.cpp.

NameSet * faudes::NameSet::NewP  )  const
 

Return a pointer to a NameSet with same Symboltable assigned.

Returns:
Pointer to new empty NameSet on heap

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 50 of file nameset.cpp.

NameSet faudes::NameSet::operator * const NameSet rOtherSet  )  const
 

Set intersection operator.

Returns:
Intersection NameSet
Exceptions:
Exception 
  • symboltable mismatch (id 67)

Definition at line 259 of file nameset.cpp.

bool faudes::NameSet::operator!= const NameSet rOtherSet  )  const
 

Test for unequality.

Definition at line 287 of file nameset.cpp.

NameSet faudes::NameSet::operator+ const NameSet rOtherSet  )  const
 

Set union operator.

Returns:
Union Set
Exceptions:
Exception 
  • symboltable mismatch (id 67)

Definition at line 229 of file nameset.cpp.

NameSet faudes::NameSet::operator- const NameSet rOtherSet  )  const
 

Set difference operator.

Returns:
Difference NameSet
Exceptions:
Exception 
  • symboltable mismatch (id 67)

Definition at line 244 of file nameset.cpp.

bool faudes::NameSet::operator<= const NameSet rOtherSet  )  const
 

Test for subset.

Definition at line 299 of file nameset.cpp.

bool faudes::NameSet::operator== const NameSet rOtherSet  )  const
 

Test for equality.

Definition at line 275 of file nameset.cpp.

bool faudes::NameSet::operator>= const NameSet rOtherSet  )  const
 

Test for superset.

Definition at line 311 of file nameset.cpp.

std::string faudes::NameSet::Str Idx  index  )  const
 

Return pretty printable symbolic name for index.

Primary meant for debugging messages.

Parameters:
index Index to print
Returns:
String

Reimplemented from faudes::IndexSet.

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 323 of file nameset.cpp.

std::string faudes::NameSet::SymbolicName Idx  index  )  const
 

Name lookup.

Parameters:
index Index to lookup
Returns:
Corresponding name or empty std::string if non-existent

Definition at line 170 of file nameset.cpp.

void faudes::NameSet::SymbolicName const std::string &  rName,
const std::string &  rNewName
 

Set new name for existing name FAUDES_CHECKED checks if the specified name exists in NameSet.

Parameters:
rName Symbolic name to edit
rNewName New name
Exceptions:
Exception 
  • symbolic name not in this set (id 60)
  • new name already associated with another index (id 44)

Definition at line 188 of file nameset.cpp.

void faudes::NameSet::SymbolicName Idx  index,
const std::string &  rName
 

Set new name for existing index.

FAUDES_CHECKED checks if index exists in NameSet.

Parameters:
index Index to edit
rName New name
Exceptions:
Exception 
  • index not in this set (id 60)
  • index not found in SymbolTable (id 42)
  • name already associated with another index (id 44)

Definition at line 175 of file nameset.cpp.

void faudes::NameSet::SymbolTablep SymbolTable pSymTab  ) 
 

Set SymbolTable reference.

This function sets the reference to the SymbolTable. The current implementation clears the set, future versions may implement a re-indexing.

Parameters:
pSymTab Pointer to SymbolTable

Definition at line 69 of file nameset.cpp.

SymbolTable * faudes::NameSet::SymbolTablep void   )  const
 

Get Pointer mpSymbolTable.

Returns:
Pointer mpSymbolTable

Definition at line 64 of file nameset.cpp.


Friends And Related Function Documentation

friend class TaNameSet [friend]
 

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

This is used for the pragmatic implemention conversion constructors.

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 79 of file nameset.h.


Member Data Documentation

SymbolTable* faudes::NameSet::mpSymbolTable [protected]
 

Pointer to local SymbolTable.

Definition at line 390 of file nameset.h.


The documentation for this class was generated from the following files:
Generated on Fri May 9 11:26:48 2008 for libFAUDES 2.09b by  doxygen 1.4.4