|
Vector bass class.
More...
#include <cfl_basevector.h>
Public Types |
typedef size_t | Position |
| convenience typedef for positions (must be unsigned)
|
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 Type * | Elementp (void) const |
| Prototype for vector entries.
|
virtual const Type & | Element (void) const |
| Prototype for vector entries.
|
virtual Type * | NewElement (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 Type & | At (const Position &pos) const |
| Access element.
|
virtual Type & | At (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.
|
| Type (void) |
| Constructor.
|
| Type (const Type &rType) |
| Copy constructor.
|
virtual | ~Type (void) |
| Destructor.
|
virtual Type * | New (void) const |
| Construct on heap.
|
virtual Type * | Copy (void) const |
| Construct on heap.
|
virtual const Type * | Cast (const Type *pOther) const |
| Cast other object to this type.
|
virtual Type & | Assign (const Type &rSrc) |
| Assign configuration data from other object.
|
virtual Type & | operator= (const Type &rSrc) |
| Assign configurationdata from other object.
|
virtual bool | Equal (const Type &rOther) const |
| Test equality of configuration data.
|
virtual bool | operator== (const Type &rOther) const |
| Test equality of configuration data.
|
virtual bool | operator!= (const Type &rOther) const |
| Test equality of configuration data.
|
void | Write (const Type *pContext=0) const |
| Write configuration data to console.
|
void | Write (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0, std::ios::openmode openmode=std::ios::out|std::ios::trunc) const |
| Write configuration data to a file.
|
void | Write (const std::string &pFileName, std::ios::openmode openmode) const |
| Write configuration data to a file.
|
void | Write (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const |
| Write configuration data to TokenWriter.
|
virtual void | XWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0) const |
| Write configuration data to an XML file.
|
void | XWrite (const Type *pContext=0) const |
| Write configuration data in XML format to concole Note: this write function uses the virtual function DoXWrite(), to be reimplemented by derived classes.
|
void | XWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const |
| Write configuration data in XML format to TokenWriter.
|
std::string | ToString (const std::string &rLabel="", const Type *pContext=0) const |
| Write configuration data to a string.
|
std::string | ToText (const std::string &rLabel="", const Type *pContext=0) const |
| Write configuration data to a formated string.
|
void | DWrite (const Type *pContext=0) const |
| Write configuration data to console, debugging format.
|
void | DWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0, std::ios::openmode openmode=std::ios::out|std::ios::trunc) const |
| Write configuration data to a file, debugging format.
|
void | DWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const |
| Write configuration data in debug format to TokenWriter.
|
void | SWrite (TokenWriter &rTw) const |
| Write statistics comment to TokenWriter.
|
void | SWrite (void) const |
| Write statistics comment to console.
|
std::string | ToSText (void) const |
| Write statistics to a string.
|
void | Read (const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0) |
| Read configuration data from file with label specified.
|
void | FromString (const std::string &rString, const std::string &rLabel="", const Type *pContext=0) |
| Read configuration data from a string.
|
void | Read (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0) |
| Read configuration data from TokenReader with label sepcified.
|
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.
|
void | DoAssign (const vBaseVector &rSourceVector) |
| Assignment method.
|
void | DoAssign (const Type &rSrc) |
| Assign configuration data from other object.
|
bool | DoEqual (const Type &rOther) const |
| Test equality of configuration data.
|
virtual void | DoXWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const |
| Write configuration data of this object to TokenWriter in XML format.
|
virtual const TypeDefinition * | TypeDefinitionp (void) const |
| Get objects's type definition.
|
virtual const std::string & | TypeName (void) const |
| Get objects's type name.
|
virtual Token | XBeginTag (const std::string &rLabel="", const std::string &rFallbackLabel="") const |
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
convenience typedef for positions (must be unsigned)
Definition at line 197 of file cfl_basevector.h.
Constructor & Destructor Documentation
faudes::vBaseVector::vBaseVector |
( |
void |
| ) |
|
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 |
Member Function Documentation
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
-
- Exceptions
-
Definition at line 382 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
-
- Exceptions
-
Definition at line 387 of file cfl_basevector.cpp.
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.
const Type & faudes::vBaseVector::At |
( |
const Position & |
pos | ) |
const |
|
virtual |
void faudes::vBaseVector::Clear |
( |
void |
| ) |
|
|
virtual |
void faudes::vBaseVector::DoAssign |
( |
const vBaseVector & |
rSourceVector | ) |
|
|
protected |
void faudes::vBaseVector::DoDWrite |
( |
TokenWriter & |
rTw, |
|
|
const std::string & |
rLabel = "" , |
|
|
const Type * |
pContext = 0 |
|
) |
| const |
|
protectedvirtual |
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 |
|
) |
| |
|
protectedvirtual |
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 |
|
protectedvirtual |
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
-
- Exceptions
-
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 |
|
protectedvirtual |
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 |
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 |
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
-
Definition at line 265 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
-
Definition at line 410 of file cfl_basevector.cpp.
const std::string & faudes::vBaseVector::FilenameAt |
( |
const Position & |
pos | ) |
const |
Get filename of entry.
- Parameters
-
- Returns
- Filename assoiated with entry
- Exceptions
-
Definition at line 398 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::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 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
-
Definition at line 324 of file cfl_basevector.cpp.
const std::string & faudes::vBaseVector::Name |
( |
void |
| ) |
const |
|
virtual |
void faudes::vBaseVector::Name |
( |
const std::string & |
rName | ) |
|
|
virtual |
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 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
-
- Exceptions
-
Definition at line 343 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
-
- Exceptions
-
Definition at line 357 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::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::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 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
-
Definition at line 248 of file cfl_basevector.cpp.
Idx faudes::vBaseVector::Size |
( |
void |
| ) |
const |
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.
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 |
The documentation for this class was generated from the following files:
libFAUDES 2.28a
--- 2016.09.13
--- c++ api documentaion by doxygen
|