libFAUDES

Sections

Index

faudes::SymbolTable Class Reference

#include <symboltable.h>

Inherits faudes::Type.

List of all members.


Detailed Description

A SymbolTable associates sybolic names with indices.

Symbolic names are restricted to printable ascii, no quoatation ("), and no blanks. Indices are of type faudes Idx aka (long unsigned) integer and must be positive. Both, indices and symbolic names must be unique within each SymbolTable. Consistency checks on input data are preformed, regardless of the FAUDES_CHECKED compiletime option.

Generators refer to a global symboltable for event names and hold a local symboltable for state names.

Public Member Functions

 SymbolTable (void)
 Creates a new SymbolTable.
std::string Name (void) const
 Return name of SymbolTable.
void Name (const std::string &rName)
 Set name of SymbolTable.
Idx Size (void)
 Size of symboltabel.
void Clear (void)
 Clear all entries.
Idx MaxIndex (void) const
 Get maximum index which this SymbolTable accepts.
void MaxIndex (Idx index)
 Set maximum index which this SymbolTable accapts.
Idx LastIndex (void) const
 Get the largest index in use.
std::string Symbol (Idx index) const
 Symbolic 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 symbol.
std::string UniqueSymbol (const std::string &rName) const
 Create unique symbolic name by adding an underscore and extra digits.
Idx InsEntry (Idx index, const std::string &rName)
 Add new entry (aka symbolic name and index) to symboltable,.
Idx InsEntry (const std::string &rName)
 Merge a symbolic name with symboltable.
void SetEntry (Idx index, const std::string &rName)
 Set symbolic name for existing entry.
void SetDefaultSymbol (Idx index)
 Set default names ("1", "2", "3", .
void ClrEntry (Idx index)
 Delete entry by index.
void ClrEntry (const std::string &rName)
 Delete entry by symbol.
void RestrictDomain (const IndexSet &rDomain)
 Restrict to specified indicees.

Static Public Member Functions

static bool ValidSymbol (const std::string &rName)
 Test validiy of candidate symbol.
static SymbolTableGlobalEventSymbolTablep (void)
 Get Static Symboltable ref.

Private Member Functions

void DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Dummy, symboltable does not provide token io.
void DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Dummy, symboltable does not provide token io.

Private Attributes

std::string mMyName
 Name of the SymbolTable.
std::map< std::string, IdxmIndexMap
 Index lookup map.
std::map< Idx, std::string > mNameMap
 Name lookup map.
Idx mMaxIndex
 Upper limit (incl).
Idx mNextIndex
 Largest used index + 1.

Static Private Attributes

static SymbolTable msEventSymbolTable
 static event symbol table (should go to faudes::vGenerator, or faudes)


Constructor & Destructor Documentation

faudes::SymbolTable::SymbolTable ( void   ) 

Creates a new SymbolTable.


Member Function Documentation

std::string faudes::SymbolTable::Name ( void   )  const

Return name of SymbolTable.

void faudes::SymbolTable::Name ( const std::string &  rName  ) 

Set name of SymbolTable.

Idx faudes::SymbolTable::Size ( void   ) 

Size of symboltabel.

void faudes::SymbolTable::Clear ( void   )  [virtual]

Clear all entries.

Reimplemented from faudes::Type.

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

Get maximum index which this SymbolTable accepts.

void faudes::SymbolTable::MaxIndex ( Idx  index  ) 

Set maximum index which this SymbolTable accapts.

Parameters:
index New maximum index
Exceptions:
Exception 
  • symboltable overflow (id 40)

Idx faudes::SymbolTable::LastIndex ( void   )  const

Get the largest index in use.

std::string faudes::SymbolTable::Symbol ( Idx  index  )  const

Symbolic name lookup.

Parameters:
index Index to lookup
Returns:
Symbolic name of index, or empty string "" for non-existent index

Idx faudes::SymbolTable::Index ( const std::string &  rName  )  const

Index lookup.

Parameters:
rName Symbolic name to lookup
Returns:
Index of symbolic name, or 0 for non-existent name

bool faudes::SymbolTable::Exists ( Idx  index  )  const

Test existence of index.

Parameters:
index Index to test
Returns:
True, if index exists

bool faudes::SymbolTable::Exists ( const std::string &  rName  )  const

Test existence of symbol.

Parameters:
rName Symbolic name to test
Returns:
True, if name exists

bool faudes::SymbolTable::ValidSymbol ( const std::string &  rName  )  [static]

Test validiy of candidate symbol.

The current implementation insists in printable ascii, no quotes (") and no blanks. The no-quotes-restriction simplifies file io (see tokenreader.h), other restrictions are cosmetic.

Parameters:
rName Symbolic name to test
Returns:
True, if name is a valid symbol

std::string faudes::SymbolTable::UniqueSymbol ( const std::string &  rName  )  const

Create unique symbolic name by adding an underscore and extra digits.

The current implementation tries to be smart and overwrites any previously added digits. It is also slow.

Parameters:
rName Candidate symbolic name
Returns:
Unique symbolic name

Idx faudes::SymbolTable::InsEntry ( Idx  index,
const std::string &  rName 
)

Add new entry (aka symbolic name and index) to symboltable,.

Parameters:
index New index
rName New symbolic name
Returns:
New index
Exceptions:
Exception 
  • name already associated with another index (id 41)
  • index already associated with another name (id 42)
  • invalid name (id 43)

Idx faudes::SymbolTable::InsEntry ( const std::string &  rName  ) 

Merge a symbolic name with symboltable.

If the symbol does not exist, find a new index and add the new entry. If the symbol does exist, lookup its index.

Parameters:
rName Symbolic name to merge
Returns:
Index of rName
Exceptions:
Exception 
  • invalid name (id 43)

void faudes::SymbolTable::SetEntry ( Idx  index,
const std::string &  rName 
)

Set symbolic name for existing entry.

If the name is the emptystring, the an existing entry is cleared. All other invalid names throw an exception.

Parameters:
index Index to specify entry
rName New esymbolic name for index
Exceptions:
Exception 
  • name already associated with another index (id 41)
  • invalid name (id 43)

void faudes::SymbolTable::SetDefaultSymbol ( Idx  index  ) 

Set default names ("1", "2", "3", .

..) for index.

Parameters:
index Index for which to set the default name

void faudes::SymbolTable::ClrEntry ( Idx  index  ) 

Delete entry by index.

Parameters:
index Index to delete

void faudes::SymbolTable::ClrEntry ( const std::string &  rName  ) 

Delete entry by symbol.

Parameters:
rName Symbolic name to delete

void faudes::SymbolTable::RestrictDomain ( const IndexSet rDomain  ) 

Restrict to specified indicees.

Parameters:
rDomain Indicees to keep.

SymbolTable * faudes::SymbolTable::GlobalEventSymbolTablep ( void   )  [static]

Get Static Symboltable ref.

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

Dummy, symboltable does not provide token io.

Reimplemented from faudes::Type.

void faudes::SymbolTable::DoWrite ( TokenWriter rTw,
const std::string &  rLabel = "",
const Type pContext = 0 
) const [private, virtual]

Dummy, symboltable does not provide token io.

Reimplemented from faudes::Type.


Member Data Documentation

std::string faudes::SymbolTable::mMyName [private]

Name of the SymbolTable.

std::map<std::string,Idx> faudes::SymbolTable::mIndexMap [private]

Index lookup map.

std::map<Idx,std::string> faudes::SymbolTable::mNameMap [private]

Name lookup map.

Upper limit (incl).

Largest used index + 1.

static event symbol table (should go to faudes::vGenerator, or faudes)


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

libFAUDES 2.13a c++ source docu by doxygen 1.5.6