#include <nameset.h>
Inheritance diagram for faudes::NameSet:
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>
Definition at line 74 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. | |
NameSet * | NewP () const |
Return a pointer to a NameSet with same Symboltable assigned. | |
SymbolTable * | SymbolTablep (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 | |
virtual void | DoWrite (TokenWriter &tw, const std::string &rLabel="", const Type *pContext=0) const |
Write to TokenWriter, see TBaseSet for public wrappers. | |
virtual void | DoDWrite (TokenWriter &tw, const std::string &rLabel="", const Type *pContext=0) const |
Write debug info to TokenWriter, see TBaseSet for public wrapper. | |
virtual void | DoRead (TokenReader &tr, const std::string &rLabel="", const Type *pContext=0) |
Read from TokenReader, see TBaseSet for public wrappers. | |
Protected Attributes | |
SymbolTable * | mpSymbolTable |
Pointer to local SymbolTable. | |
Friends | |
class | TaNameSet |
We implement "protected privacy for template classes" by friendship. |
|
Constructor for NameSet referring to the static SymbolTable.
Definition at line 28 of file nameset.cpp. |
|
Copy-constructor from other NameSet. This also copies the SymbolTable reference, hence the new NameSet will use the same SymbolTable as rOtherSet.
Definition at line 35 of file nameset.cpp. |
|
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.
Definition at line 43 of file nameset.cpp. |
|
Write debug info to TokenWriter, see TBaseSet for public wrapper. The debug version writes a format that includes symbolic names and indices.
Reimplemented from faudes::TBaseSet< Idx >. Reimplemented in faudes::TaNameSet< Attr >, faudes::TaNameSet< SimConditionAttribute >, faudes::TaNameSet< AttributeCFlags >, and faudes::TaNameSet< EventAttr >. Definition at line 84 of file nameset.cpp. |
|
Read from TokenReader, see TBaseSet for public wrappers. Uses TaNameSet::DoRead(TokenReader&,const std::string&) with void attributes. It is an error if the file contains an index (id 52).
Reimplemented from faudes::IndexSet. Reimplemented in faudes::TaNameSet< Attr >, faudes::TaNameSet< SimConditionAttribute >, faudes::TaNameSet< AttributeCFlags >, and faudes::TaNameSet< EventAttr >. Definition at line 90 of file nameset.cpp. |
|
Write to TokenWriter, see TBaseSet for public wrappers.
Reimplemented from faudes::IndexSet. Reimplemented in faudes::TaNameSet< Attr >, faudes::TaNameSet< SimConditionAttribute >, faudes::TaNameSet< AttributeCFlags >, and faudes::TaNameSet< EventAttr >. Definition at line 78 of file nameset.cpp. |
|
Delete element by iterator. Symbolic nam is not removed from SymbolTable.
Reimplemented from faudes::TBaseSet< Idx >. Reimplemented in faudes::TaNameSet< Attr >, faudes::TaNameSet< SimConditionAttribute >, faudes::TaNameSet< AttributeCFlags >, and faudes::TaNameSet< EventAttr >. Definition at line 154 of file nameset.cpp. |
|
Delete element by symbolic name. The symbolic name is not removed from the SymbolTable
Reimplemented in faudes::TaNameSet< Attr >, faudes::TaNameSet< SimConditionAttribute >, faudes::TaNameSet< AttributeCFlags >, and faudes::TaNameSet< EventAttr >. Definition at line 140 of file nameset.cpp. |
|
Delete element by index. The symbolic name is not removed from the SymbolTable.
Reimplemented in faudes::TaNameSet< Attr >, faudes::TaNameSet< SimConditionAttribute >, faudes::TaNameSet< AttributeCFlags >, and faudes::TaNameSet< EventAttr >. Definition at line 134 of file nameset.cpp. |
|
Erase elements specified by rOtherSet.
Reimplemented in faudes::TaNameSet< Attr >, faudes::TaNameSet< SimConditionAttribute >, faudes::TaNameSet< AttributeCFlags >, and faudes::TaNameSet< EventAttr >. Definition at line 159 of file nameset.cpp. |
|
Test existence of name.
Definition at line 214 of file nameset.cpp. |
|
Test existence of index.
Definition at line 209 of file nameset.cpp. |
|
Find iterator for name. Returns either a valid iterator or End() for non-existent.
Definition at line 224 of file nameset.cpp. |
|
Find iterator for index. Returns either a valid iterator or End() for non-existent.
Definition at line 219 of file nameset.cpp. |
|
Index lookup.
Definition at line 204 of file nameset.cpp. |
|
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.
Reimplemented in faudes::TaNameSet< Attr >, faudes::TaNameSet< SimConditionAttribute >, faudes::TaNameSet< AttributeCFlags >, and faudes::TaNameSet< EventAttr >. Definition at line 113 of file nameset.cpp. |
|
Add an element by index. Index must be already known to the global SymbolTable.
Reimplemented from faudes::IndexSet. Reimplemented in faudes::TaNameSet< Attr >, faudes::TaNameSet< SimConditionAttribute >, faudes::TaNameSet< AttributeCFlags >, and faudes::TaNameSet< EventAttr >. Definition at line 101 of file nameset.cpp. |
|
Inserts elements of rOtherSet.
Reimplemented in faudes::TaNameSet< Attr >, faudes::TaNameSet< SimConditionAttribute >, faudes::TaNameSet< AttributeCFlags >, and faudes::TaNameSet< EventAttr >. Definition at line 121 of file nameset.cpp. |
|
Return an empty NameSet with same SymbolTable as this set.
Reimplemented in faudes::TaNameSet< Attr >, faudes::TaNameSet< SimConditionAttribute >, faudes::TaNameSet< AttributeCFlags >, and faudes::TaNameSet< EventAttr >. Definition at line 57 of file nameset.cpp. |
|
Return a pointer to a NameSet with same Symboltable assigned.
Reimplemented in faudes::TaNameSet< Attr >, faudes::TaNameSet< SimConditionAttribute >, faudes::TaNameSet< AttributeCFlags >, and faudes::TaNameSet< EventAttr >. Definition at line 50 of file nameset.cpp. |
|
Set intersection operator.
Definition at line 260 of file nameset.cpp. |
|
Test for unequality.
Definition at line 288 of file nameset.cpp. |
|
Set union operator.
Definition at line 230 of file nameset.cpp. |
|
Set difference operator.
Definition at line 245 of file nameset.cpp. |
|
Test for subset.
Definition at line 300 of file nameset.cpp. |
|
Test for equality.
Definition at line 276 of file nameset.cpp. |
|
Test for superset.
Definition at line 312 of file nameset.cpp. |
|
Return pretty printable symbolic name for index. Primary meant for debugging messages.
Reimplemented from faudes::IndexSet. Reimplemented in faudes::TaNameSet< Attr >, faudes::TaNameSet< SimConditionAttribute >, faudes::TaNameSet< AttributeCFlags >, and faudes::TaNameSet< EventAttr >. Definition at line 324 of file nameset.cpp. |
|
Name lookup.
Definition at line 171 of file nameset.cpp. |
|
Set new name for existing name FAUDES_CHECKED checks if the specified name exists in NameSet.
Definition at line 189 of file nameset.cpp. |
|
Set new name for existing index. FAUDES_CHECKED checks if index exists in NameSet.
Definition at line 176 of file nameset.cpp. |
|
Set SymbolTable reference. This function sets the reference to the SymbolTable. The current implementation clears the set, future versions may implement a re-indexing.
Definition at line 69 of file nameset.cpp. |
|
Get Pointer mpSymbolTable.
Definition at line 64 of file nameset.cpp. |
|
We implement "protected privacy for template classes" by friendship. This is used for the pragmatic implemention conversion constructors. |
|
Pointer to local SymbolTable.
|