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

Vector bass class. More...

#include <cfl_basevector.h>

List of all members.

Classes

class  ElementRecord
 Internal entry data type. More...

Public Types

typedef std::vector< int >
::size_type 
Position
 convenience typedef for positions

Public Member Functions

 vBaseVector (void)
 Constructor.
 vBaseVector (const vBaseVector &rOtherVector)
 Copy-constructor.
 vBaseVector (const std::string &rFilename, const std::string &rLabel="BaseVector")
 Constructor from file.
virtual ~vBaseVector (void)
 Virtual destructor.
virtual const TypeElementp (void) const
 Prototype for vector entries.
virtual const TypeElement (void) const
 Prototype for vector entries.
virtual TypeNewElement (void)
 Factory method for vector entries.
virtual bool ElementTry (const Type &rElement) const
 Test whether the specified element is acceptebla for this vector.
const std::string & Name (void) const
 Return name of vBaseVector.
void Name (const std::string &rName)
 Set name of vBaseVector.
virtual void Clear (void)
 Clear all vector.
Idx Size (void) const
 Get size of vector.
void Size (Idx len)
 Set size of vector.
bool Empty (void) const
 Check if the vBaseVector ist Empty.
virtual const TypeAt (const Position &pos) const
 Access element.
virtual TypeAt (const Position &pos)
 Access element.
virtual void Replace (const Position &pos, const Type &rElem)
 Replace specified entry.
virtual void Replace (const Position &pos, Type *pElem)
 Replace specified entry.
virtual void Replace (const Position &pos, const std::string &rFileName)
 Replace specified entry.
virtual void Erase (const Position &pos)
 Erase entry by position.
virtual void Insert (const Position &pos, const Type &rElem)
 Insert specified entry.
virtual void Insert (const Position &pos, Type *rElem)
 Insert specified entry.
virtual void Insert (const Position &pos, const std::string &rFileName)
 Insert specified entry.
virtual void PushBack (const Type &rElem)
 Append specified entry.
virtual void PushBack (Type *rElem)
 Append specified entry.
virtual void PushBack (const std::string &rFileName)
 Append specified entry.
virtual void Append (const Type &rElem)
 Append specified entry.
virtual void Append (Type *rElem)
 Append specified entry.
virtual void Append (const std::string &rFileName)
 Append specified entry.
void FilenameAt (const Position &pos, const std::string &rFileName)
 Specify a filename.
const std::string & FilenameAt (const Position &pos) const
 Get filename of entry.
void TakeOwnership (void)
 Take ownership of all entries.
void TakeCopies (void)
 Take local copies of all entries.

Protected Types

typedef std::vector
< ElementRecord >::iterator 
iterator
 convenience typedef

Protected Member Functions

virtual void DoDWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Token output, debugging see Type::DWrite for public wrappers.
virtual void DoSWrite (TokenWriter &rTw) const
 Token output, see Type::SWrite for public wrappers.
virtual void DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Token output, see Type::Write for public wrappers.
virtual void DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Token input, see Type::Read for public wrappers.
virtual void DoAssign (const vBaseVector &rSourceVector)
 Assignment method.

Protected Attributes

std::vector< ElementRecordmVector
 STL vector of element.

Private Attributes

std::string mMyName
 Name of TBaseVector.

Detailed Description

Vector bass class.

This class is designed as a random access container for a small number of comperatively large objects, eg a vector of generators to model a decentralized DES. The API is restricted to simple positional access and there are no explicit iterators nor is there a deferred copy mechanism. As with other faudes containers, vBaseVector is the universal base class for all faudes vector data types. The latter explicitely refer to the element data type and are implemented as templates.

Internally, the vBaseVector template uses STL vector of pointers to the individual entries. When adding an entry, you may either do so be refernce or by pointer. When setting by reference, the vector takes a copy and owns the new entry. When setting by a pointer, the vector only records the reference. The vector tracks ownership of each entry in order to properly destruct entries.

vBaseVector serves as a base class for all libFaudes vectors:

  • GeneratorVector (vector or generators)
  • EventSetVector (vector of event sets)

Token io assumes that the type parameter is a faudes type, ie. entries of the vector provide token io themselfs. To derive a vector class with non-faudes-type entries, you will need to reimplement token io. As a convenience feature, the vector keeps a record of filenames associated with individual entries. You can inspect and edit this record via the FilenameAt members. When writing the vector to a file and all entries have an associated filename, output will be to the individual files.

Definition at line 70 of file cfl_basevector.h.


Member Typedef Documentation

typedef std::vector<ElementRecord>::iterator faudes::vBaseVector::iterator [protected]

convenience typedef

Definition at line 521 of file cfl_basevector.h.

typedef std::vector<int>::size_type faudes::vBaseVector::Position

convenience typedef for positions

Reimplemented in faudes::TBaseVector< T >.

Definition at line 197 of file cfl_basevector.h.


Constructor & Destructor Documentation

faudes::vBaseVector::vBaseVector ( void   ) 

Constructor.

Definition at line 46 of file cfl_basevector.cpp.

faudes::vBaseVector::vBaseVector ( const vBaseVector rOtherVector  ) 

Copy-constructor.

Parameters:
rOtherVector Source to copy from

Definition at line 68 of file cfl_basevector.cpp.

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

Constructor from file.

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

Definition at line 56 of file cfl_basevector.cpp.

faudes::vBaseVector::~vBaseVector ( void   )  [virtual]

Virtual destructor.

Definition at line 76 of file cfl_basevector.cpp.


Member Function Documentation

void faudes::vBaseVector::Append ( const std::string &  rFileName  )  [virtual]

Append specified entry.

Synonymous for PushBack. This method reads the sepcified entry from file and the vector becomes the owner of the new entry.

Parameters:
rFileName Element to insert

Definition at line 392 of file cfl_basevector.cpp.

void faudes::vBaseVector::Append ( Type rElem  )  [virtual]

Append specified entry.

Synonymous for PushBack. This method avoids to copy the entry to replace and only records the reference. The vector does not take ownership of the new entry. I.e., when the vector is destroyed, or the entry is deleted from the vector, the entry itself remains allocated.

Parameters:
rElem Element to insert
Exceptions:
Exception 
  • Cannot cast element type (63)

Definition at line 387 of file cfl_basevector.cpp.

void faudes::vBaseVector::Append ( const Type rElem  )  [virtual]

Append specified entry.

Synonymous for PushBack. This method takes a copy of the entry to replace and the vector becomes the owner of the copy.

Parameters:
rElem Element to append
Exceptions:
Exception 
  • Cannot cast element type (63)

Definition at line 382 of file cfl_basevector.cpp.

Type & faudes::vBaseVector::At ( const Position pos  )  [virtual]

Access element.

Parameters:
pos Specify entry to access
Exceptions:
Exception 
  • Position out of range (id 69)

Reimplemented in faudes::TBaseVector< T >.

Definition at line 192 of file cfl_basevector.cpp.

const Type & faudes::vBaseVector::At ( const Position pos  )  const [virtual]

Access element.

Parameters:
pos Specify entry to access
Exceptions:
Exception 
  • Position out of range (id 69)

Reimplemented in faudes::TBaseVector< T >.

Definition at line 180 of file cfl_basevector.cpp.

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

Clear all vector.

Reimplemented from faudes::Type.

Definition at line 127 of file cfl_basevector.cpp.

void faudes::vBaseVector::DoAssign ( const vBaseVector rSourceVector  )  [protected, virtual]

Assignment method.

Definition at line 108 of file cfl_basevector.cpp.

void faudes::vBaseVector::DoDWrite ( TokenWriter rTw,
const std::string &  rLabel = "",
const Type pContext = 0 
) const [protected, virtual]

Token output, debugging see Type::DWrite for public wrappers.

The method assumes that the type parameter is a faudes type and uses the provide write method per entry. Reimplement this function in derived classes for non-faudes type vectors.

Parameters:
rTw Reference to TokenWriter
rLabel Label of section to write, defaults to name of set
pContext Write context to provide contextual information

Reimplemented from faudes::Type.

Definition at line 469 of file cfl_basevector.cpp.

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

Token input, see Type::Read for public wrappers.

The method assumes that the type parameter is a faudes type and uses the provide read method per entry. Reimplement this function in derived classes for non-faudes type vectors. By convention, the default label "" should be translated to some meaningful default, eg "GeneratorVector" for a vector of generators. The pContext pointer can be type-checked and interpreted, ie as a symboltable to provide symbolic names. It is also passed on to vector entries.

Parameters:
rTr Reference to TokenReader
rLabel Label of section to read, defaults to name of set
pContext Read context to provide contextual information

Reimplemented from faudes::Type.

Definition at line 494 of file cfl_basevector.cpp.

void faudes::vBaseVector::DoSWrite ( TokenWriter rTw  )  const [protected, virtual]

Token output, see Type::SWrite for public wrappers.

The method assumes that the type parameter is a faudes type and uses the provide write method per entry. Reimplement this function in derived classes for non-faudes type vectors.

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

Reimplemented from faudes::Type.

Definition at line 482 of file cfl_basevector.cpp.

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

Token output, see Type::Write for public wrappers.

The method assumes that the type parameter is a faudes type and uses the provide write method per entry. Reimplement this function in derived classes for non-faudes type vectors.

Parameters:
rTw Reference to TokenWriter
rLabel Label of section to write, defaults to name of set
pContext Write context to provide contextual information

Reimplemented from faudes::Type.

Definition at line 439 of file cfl_basevector.cpp.

const Type & faudes::vBaseVector::Element ( void   )  const [virtual]

Prototype for vector entries.

This is a convenience wrapper for Elementp.

Returns:
Element protoype

Definition at line 93 of file cfl_basevector.cpp.

const Type * faudes::vBaseVector::Elementp ( void   )  const [virtual]

Prototype for vector entries.

The virtual base vBaseVector will provide a plain Type object. Derived vector classes are meant to reimplement this function.

Returns:
Element protoype

Reimplemented in faudes::TBaseVector< T >.

Definition at line 87 of file cfl_basevector.cpp.

bool faudes::vBaseVector::ElementTry ( const Type rElement  )  const [virtual]

Test whether the specified element is acceptebla for this vector.

This is a convenience wrapper for Elementp.

Parameters:
rElement Element to type check.
Returns:
True, if provided element is accepted by this vector.

Reimplemented in faudes::TBaseVector< T >.

Definition at line 103 of file cfl_basevector.cpp.

bool faudes::vBaseVector::Empty ( void   )  const

Check if the vBaseVector ist Empty.

Returns:
True if empty

Definition at line 174 of file cfl_basevector.cpp.

void faudes::vBaseVector::Erase ( const Position pos  )  [virtual]

Erase entry by position.

If the vector owns the entry, it will be destructed.

Parameters:
pos Specify entry to erase
Exceptions:
Exception 
  • Position out of range (id 69)

Definition at line 265 of file cfl_basevector.cpp.

const std::string & faudes::vBaseVector::FilenameAt ( const Position pos  )  const

Get filename of entry.

Parameters:
pos Position of entry
Returns:
Filename assoiated with entry
Exceptions:
Exception 
  • Position out of range (id 69)

Definition at line 398 of file cfl_basevector.cpp.

void faudes::vBaseVector::FilenameAt ( const Position pos,
const std::string &  rFileName 
)

Specify a filename.

When each entry has a filenam specified, file io of the vector will be to indivudual files.

Parameters:
pos Position of entry
rFileName Filename relative to vector file
Exceptions:
Exception 
  • Position out of range (id 69)

Definition at line 410 of file cfl_basevector.cpp.

void faudes::vBaseVector::Insert ( const Position pos,
const std::string &  rFileName 
) [virtual]

Insert specified entry.

This method reads the sepcified entry from file and the vector becomes the owner of the new entry.

Parameters:
pos Position at which to insert
rFileName Element to insert
Exceptions:
Exception 
  • Position out of range (id 69)

Definition at line 324 of file cfl_basevector.cpp.

void faudes::vBaseVector::Insert ( const Position pos,
Type rElem 
) [virtual]

Insert specified entry.

This method avoids to copy the entry to replace and only records the reference. The vector does not take ownership of the new entry. I.e., when the vector is destroyed, or the entry is deleted from the vector, the entry itself remains allocated.

Parameters:
pos Position at which to insert
rElem Element to insert
Exceptions:
Exception 
  • Position out of range (id 69)
  • Cannot cast element type (63)

Definition at line 302 of file cfl_basevector.cpp.

void faudes::vBaseVector::Insert ( const Position pos,
const Type rElem 
) [virtual]

Insert specified entry.

This method takes a copy of the entry to replace and the vector becomes the owner of the copy.

Parameters:
pos Position at which to insert
rElem Element to insert
Exceptions:
Exception 
  • Position out of range (id 69)
  • Cannot cast element type (63)

Definition at line 280 of file cfl_basevector.cpp.

void faudes::vBaseVector::Name ( const std::string &  rName  )  [virtual]

Set name of vBaseVector.

Parameters:
rName Name to set

Reimplemented from faudes::Type.

Definition at line 143 of file cfl_basevector.cpp.

const std::string & faudes::vBaseVector::Name ( void   )  const [virtual]

Return name of vBaseVector.

Returns:
Name of vBaseVector

Reimplemented from faudes::Type.

Definition at line 138 of file cfl_basevector.cpp.

Type * faudes::vBaseVector::NewElement ( void   )  [virtual]

Factory method for vector entries.

This is a convenience wrapper using Elementp.

Returns:
New element allocated on heap

Definition at line 98 of file cfl_basevector.cpp.

void faudes::vBaseVector::PushBack ( const std::string &  rFileName  )  [virtual]

Append specified entry.

This method reads the sepcified entry from file and the vector becomes the owner of the new entry.

Parameters:
rFileName Element to insert

Definition at line 371 of file cfl_basevector.cpp.

void faudes::vBaseVector::PushBack ( Type rElem  )  [virtual]

Append specified entry.

This method avoids to copy the entry to replace and only records the reference. The vector does not take ownership of the new entry. I.e., when the vector is destroyed, or the entry is deleted from the vector, the entry itself remains allocated.

Parameters:
rElem Element to insert
Exceptions:
Exception 
  • Cannot cast element type (63)

Definition at line 357 of file cfl_basevector.cpp.

void faudes::vBaseVector::PushBack ( const Type rElem  )  [virtual]

Append specified entry.

This method takes a copy of the entry to replace and the vector becomes the owner of the copy.

Parameters:
rElem Element to append
Exceptions:
Exception 
  • Cannot cast element type (63)

Definition at line 343 of file cfl_basevector.cpp.

void faudes::vBaseVector::Replace ( const Position pos,
const std::string &  rFileName 
) [virtual]

Replace specified entry.

This method reads the sepcified entry from file and the vector becomes the owner of the new entry.

Parameters:
pos Position to replace
rFileName New entry to be read from file
Exceptions:
Exception 
  • Position out of range (id 69)

Definition at line 248 of file cfl_basevector.cpp.

void faudes::vBaseVector::Replace ( const Position pos,
Type pElem 
) [virtual]

Replace specified entry.

This method avoids to copy the entry to replace and only records the reference. The vector does not take ownership of the new entry. I.e., when the vector is destroyed, or the entry is deleted from the vector, the entry itself remains allocated.

Parameters:
pos Position to replace
pElem New entry
Exceptions:
Exception 
  • Position out of range (id 69)
  • Cannot cast element type (63)

Definition at line 227 of file cfl_basevector.cpp.

void faudes::vBaseVector::Replace ( const Position pos,
const Type rElem 
) [virtual]

Replace specified entry.

This method takes a copy of the entry to replace and the vector becomes the owner of the copy.

Parameters:
pos Position to replace
rElem New entry
Exceptions:
Exception 
  • Position out of range (id 69)
  • Cannot cast element type (63)

Definition at line 206 of file cfl_basevector.cpp.

void faudes::vBaseVector::Size ( Idx  len  ) 

Set size of vector.

If the new size is smaller than the current size, the vector is truncated. If it is larger, default members are inserted at the end.

Parameters:
len Number of entries in vector

Definition at line 153 of file cfl_basevector.cpp.

Idx faudes::vBaseVector::Size ( void   )  const

Get size of vector.

Returns:
Number of entries.

Definition at line 148 of file cfl_basevector.cpp.

void faudes::vBaseVector::TakeCopies ( void   ) 

Take local copies of all entries.

This method will construct local copies of all entries not previously owned.

Definition at line 422 of file cfl_basevector.cpp.

void faudes::vBaseVector::TakeOwnership ( void   ) 

Take ownership of all entries.

Thsi method will take ownership of all entries, including those, that have been set by pointer reference. When the vector is destructed, all entries will be destructed, too. However, write access may invalidate element pointers.

Definition at line 432 of file cfl_basevector.cpp.


Member Data Documentation

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

Name of TBaseVector.

Definition at line 526 of file cfl_basevector.h.

std::vector<ElementRecord> faudes::vBaseVector::mVector [protected]

STL vector of element.

Definition at line 518 of file cfl_basevector.h.


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

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