Detailed Description

A TypeDefinition defines a faudes-type in that it specifies a faudes-type name to identify the type and a method NewObject() to instantiate objects of the respective type.

In this sense, TypeDefinition is a so called factory class. Technically, the TypeDefinition holds one instance of the faude type, the so called prototype object, and NewObject() invokes the New() method of the prototype. Notebly, there is only one class TypeDefinition that by parametrisation defins all derivates of Type.

TypeDefinition is derived from faudes::Documentation and therefore additional documentation-data can be associated.

Definition at line 1467 of file cfl_types.h.

#include <cfl_types.h>

Public Member Functions

 TypeDefinition (const std::string &name="")
 Constructor. More...
 
virtual ~TypeDefinition (void)
 Destructor. More...
 
const TypePrototype (void) const
 Return pointer to faudes-object prototype. More...
 
TypeNewObject (void) const
 Construct faudes-object on heap. More...
 
const std::string & XElementTag (void) const
 Parameter access: Xml Element Tag. More...
 
void XElementTag (const std::string &rTag)
 Parameter access: Xml Element Tag. More...
 
Typeoperator= (const Type &rSrc)
 Assign configurationdata from other object. More...
 
bool operator== (const Type &rOther) const
 Test equality of configuration data. More...
 
bool operator!= (const Type &rOther) const
 Test equality of configuration data. More...
 
- Public Member Functions inherited from faudes::Documentation
 Documentation (void)
 Constructor. More...
 
 Documentation (const Documentation &rOther)
 Copy constructor. More...
 
virtual ~Documentation (void)
 Destructor. More...
 
const std::string & Name (void) const
 Get name of the entety to document (aka faudes-type or faudes-function). More...
 
const std::string & PlugIn (void) const
 Get name of plugin. More...
 
const std::string & CType (void) const
 Get corresponding C++ type. More...
 
const std::string & TextDoc (void) const
 
const std::string & HtmlDoc (void) const
 
const std::string & Keywords (void) const
 
std::string MatchKeyword (const std::string &rPattern) const
 Search comma-seperated keywords for a substring. More...
 
int KeywordsSize (void) const
 Not implemented. More...
 
std::string KeywordAt (int pos) const
 
bool AutoRegistered (void) const
 Get auto-register flag. More...
 
bool ApplicationRegistered (void) const
 Get application-registered flag. More...
 
virtual void MergeDocumentation (TokenReader &rTr)
 Merge documentation from token stream. More...
 
Typeoperator= (const Type &rSrc)
 Assign configurationdata from other object. More...
 
bool operator== (const Type &rOther) const
 Test equality of configuration data. More...
 
bool operator!= (const Type &rOther) const
 Test equality of configuration data. More...
 
- Public Member Functions inherited from faudes::Type
 Type (void)
 Constructor. More...
 
 Type (const Type &rType)
 Copy constructor. More...
 
virtual ~Type (void)
 Destructor. More...
 
virtual TypeNew (void) const
 Construct on heap. More...
 
virtual TypeCopy (void) const
 Construct on heap. More...
 
virtual const TypeCast (const Type *pOther) const
 Cast other object to this type. More...
 
virtual TypeAssign (const Type &rSrc)
 Assign configuration data from other object. More...
 
Typeoperator= (const Type &rSrc)
 Assign configurationdata from other object. More...
 
virtual bool Equal (const Type &rOther) const
 Test equality of configuration data. More...
 
bool operator== (const Type &rOther) const
 Test equality of configuration data. More...
 
bool operator!= (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual const std::string & TypeName (void) const
 Get objects's type name. More...
 
void Write (const Type *pContext=0) const
 Write configuration data to console. More...
 
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. More...
 
void Write (const std::string &pFileName, std::ios::openmode openmode) const
 Write configuration data to a file. More...
 
void Write (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to TokenWriter. More...
 
virtual void XWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to an XML file. More...
 
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. More...
 
void XWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in XML format to TokenWriter. More...
 
std::string ToString (const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to a string. More...
 
std::string ToText (const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to a formated string. More...
 
void DWrite (const Type *pContext=0) const
 Write configuration data to console, debugging format. More...
 
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. More...
 
void DWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in debug format to TokenWriter. More...
 
void SWrite (TokenWriter &rTw) const
 Write statistics comment to TokenWriter. More...
 
void SWrite (void) const
 Write statistics comment to console. More...
 
std::string ToSText (void) const
 Write statistics to a string. More...
 
void Read (const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from file with label specified. More...
 
void FromString (const std::string &rString, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from a string. More...
 
void Read (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from TokenReader with label sepcified. More...
 

Static Public Member Functions

template<class T >
static TypeDefinitionConstructor (const std::string &rTypeName="")
 Construct empty TypeDefinition object. More...
 
static TypeDefinitionConstructor (Type *pProto, const std::string &rTypeName="")
 Construct empty TypeDefinition object. More...
 
template<class T >
static TypeDefinitionFromFile (const std::string &rFileName)
 Construct TypeDefinition object and read name and documentation-data from TokenReader. More...
 

Protected Member Functions

void DoAssign (const TypeDefinition &rSrc)
 Std faudes type interface: assignment. More...
 
bool DoEqual (const TypeDefinition &rOther) const
 Std faudes type interface: test equality. More...
 
 TypeDefinition (const TypeDefinition &rOther)
 Disable copy constructor. More...
 
void Clear (void)
 Clear documentation-data; do NOT delete prototype (this is for using Read to merge/overwrite documentation) More...
 
virtual void Prototype (Type *pType)
 Use given object as prototype. More...
 
virtual void DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data of this object from TokenReader. More...
 
virtual void DoReadCore (TokenReader &rTr)
 Read configuration data of this object from TokenReader. More...
 
virtual void DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data of this object to TokenWriter. More...
 
virtual void DoWriteCore (TokenWriter &rTw) const
 Write configuration data of this object to TokenWriter. More...
 
- Protected Member Functions inherited from faudes::Documentation
void Name (const std::string &name)
 Set name. More...
 
void PlugIn (const std::string &plugin)
 Set name of plugin. More...
 
void CType (const std::string &name)
 Set C++ type. More...
 
void TextDoc (const std::string &textdoc)
 Set a short textual documentation. More...
 
void AutoRegistered (bool flag)
 Set auto-register flag. More...
 
void ApplicationRegistered (bool flag)
 Set application-registered flag. More...
 
void HtmlDoc (const std::string &fname)
 Set name of file pointing to the html documentation. More...
 
void AddKeyword (const std::string &rKeyword)
 Append keyword. More...
 
void DoAssign (const Documentation &rSrc)
 Std faudes type interface: assignment. More...
 
bool DoEqual (const Documentation &rOther) const
 Std faudes type interface: test equality. More...
 
- Protected Member Functions inherited from faudes::Type
void DoAssign (const Type &rSrc)
 Assign configuration data from other object. More...
 
bool DoEqual (const Type &rOther) const
 Test equality of configuration data. More...
 
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. More...
 
virtual void DoDWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in debugging format to TokenWriter. More...
 
virtual void DoSWrite (TokenWriter &rTw) const
 Write statistical data as a comment to TokenWriter. More...
 
virtual const TypeDefinitionTypeDefinitionp (void) const
 Get objects's type definition. More...
 
virtual Token XBeginTag (const std::string &rLabel="", const std::string &rFallbackLabel="") const
 

Protected Attributes

TypempType
 Type-pointer tp prototype instance. More...
 
std::string mXElementTag
 Extra documentation/parameter: Xml Element Tag. More...
 
- Protected Attributes inherited from faudes::Documentation
std::string mName
 Faudes name. More...
 
std::string mPlugIn
 Faudes plugin. More...
 
std::string mCType
 Corresponing C++ type, or "" if no such. More...
 
std::string mTextDoc
 String containing the text-documentation. More...
 
std::string mHtmlDoc
 String containing the filename of the corresponding html-documentation. More...
 
std::string mKeywords
 Comma-seperated string containing all keywords. More...
 
bool mAutoRegistered
 Flag to indicate automated registration. More...
 
bool mApplicationRegistered
 Flag to indicate application registration. More...
 

Friends

class TypeRegistry
 

Additional Inherited Members

- Static Protected Attributes inherited from faudes::Documentation
static const char mDelim = ';'
 Constant characted used to seperate keywords. More...
 

Constructor & Destructor Documentation

◆ TypeDefinition() [1/2]

faudes::TypeDefinition::TypeDefinition ( const std::string &  name = "")
inline

Constructor.

The default constructor instantiates an invalid type definition without prototype. To construct a valid type definition, use the static Constructor() template function.

Definition at line 1489 of file cfl_types.h.

◆ ~TypeDefinition()

virtual faudes::TypeDefinition::~TypeDefinition ( void  )
inlinevirtual

Destructor.

Delete prototype object.

Definition at line 1496 of file cfl_types.h.

◆ TypeDefinition() [2/2]

faudes::TypeDefinition::TypeDefinition ( const TypeDefinition rOther)
inlineprotected

Disable copy constructor.

Definition at line 1616 of file cfl_types.h.

Member Function Documentation

◆ Clear()

void faudes::TypeDefinition::Clear ( void  )
protectedvirtual

Clear documentation-data; do NOT delete prototype (this is for using Read to merge/overwrite documentation)

Reimplemented from faudes::Documentation.

Definition at line 722 of file cfl_types.cpp.

◆ Constructor() [1/2]

template<class T >
TypeDefinition * faudes::TypeDefinition::Constructor ( const std::string &  rTypeName = "")
static

Construct empty TypeDefinition object.

The given template parameter denotes any libFAUDES class derived from faudes::Type A new instance of this class is assigned to member variable (pType) whereas the name is set as specified.

Template Parameters
TActual c class, derived from Type
Parameters
rTypeNameName to identify this faudes-type<; defaults to the plattform dependand typeid from the c++ runtime type information system.
Returns
Newly constructed type definition.

Definition at line 1724 of file cfl_types.h.

◆ Constructor() [2/2]

TypeDefinition * faudes::TypeDefinition::Constructor ( Type pProto,
const std::string &  rTypeName = "" 
)
static

Construct empty TypeDefinition object.

The given prototype is assigned to the member variable pType,

Parameters
pProtoPrototype, derived from Type
rTypeNameName to identify this faudes-type<; defaults to the plattform dependand typeid from the c++ runtime type information system.
Returns
Newly constructed type definition.

Definition at line 710 of file cfl_types.cpp.

◆ DoAssign()

void faudes::TypeDefinition::DoAssign ( const TypeDefinition rSrc)
protected

Std faudes type interface: assignment.

Parameters
rSrcSource to copy from

Definition at line 732 of file cfl_types.cpp.

◆ DoEqual()

bool faudes::TypeDefinition::DoEqual ( const TypeDefinition rOther) const
protected

Std faudes type interface: test equality.

Parameters
rOtherOther object to compare with.
Returns
True on match.

Definition at line 745 of file cfl_types.cpp.

◆ DoRead()

void faudes::TypeDefinition::DoRead ( TokenReader rTr,
const std::string &  rLabel = "",
const Type pContext = 0 
)
protectedvirtual

Read configuration data of this object from TokenReader.

The section defaults to "TypeDefinition", context ignored. Actual reading is done by DoReadCore.

Parameters
rTrTokenReader to read from
rLabelSection to read
pContextRead context to provide contextual information (ignored)
Exceptions
Exception
  • Token mismatch (id 50, 51, 52)
  • IO error (id 1)

Reimplemented from faudes::Documentation.

Definition at line 755 of file cfl_types.cpp.

◆ DoReadCore()

void faudes::TypeDefinition::DoReadCore ( TokenReader rTr)
protectedvirtual

Read configuration data of this object from TokenReader.

This method reads members only, it does not read the section.

Parameters
rTrTokenReader to read from
Exceptions
Exception
  • Token mismatch (id 50, 51, 52)
  • IO error (id 1)

Reimplemented from faudes::Documentation.

Definition at line 768 of file cfl_types.cpp.

◆ DoWrite()

void faudes::TypeDefinition::DoWrite ( TokenWriter rTw,
const std::string &  rLabel = "",
const Type pContext = 0 
) const
protectedvirtual

Write configuration data of this object to TokenWriter.

The section defaults to "TypeDefinition", context ignored. Actual writing is done by DoWriteCore.

Parameters
rTwReference to TokenWriter
rLabelLabel of section to write
pContextWrite context to provide contextual information
Exceptions
Exception
  • IO errors (id 2)

Reimplemented from faudes::Documentation.

Definition at line 791 of file cfl_types.cpp.

◆ DoWriteCore()

void faudes::TypeDefinition::DoWriteCore ( TokenWriter rTw) const
protectedvirtual

Write configuration data of this object to TokenWriter.

This method wrtite plain member data, the section lables are not written.

Parameters
rTwReference to TokenWriter
Exceptions
Exception
  • IO errors (id 2)

Reimplemented from faudes::Documentation.

Definition at line 800 of file cfl_types.cpp.

◆ FromFile()

template<class T >
TypeDefinition * faudes::TypeDefinition::FromFile ( const std::string &  rFileName)
static

Construct TypeDefinition object and read name and documentation-data from TokenReader.

Template Parameters
TActual c class, derived from Type
Parameters
rFileNameName of file to read.
Returns
Newly constructed type definition.
Exceptions
Exception
  • Token mismatch (id 50, 51, 52)
  • IO Error (id 1)

Definition at line 1732 of file cfl_types.h.

◆ NewObject()

Type * faudes::TypeDefinition::NewObject ( void  ) const

Construct faudes-object on heap.

Return pointer to new instance of assigned Type class.

Note: If no prototype is installed, NULL is returned.

Returns
Pointer to new Type instance.

Definition at line 836 of file cfl_types.cpp.

◆ operator!=()

bool faudes::Type::operator!=

Test equality of configuration data.

See operator==(const Type&).

This method calls the virtual method DoEqual(). Re-implementation can be done via the convenience macros FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.

Parameters
rOtherOther objevt to compare with.
Returns
True on mismatch.

Definition at line 1137 of file cfl_types.cpp.

◆ operator=()

Type & faudes::Type::operator=

Assign configurationdata from other object.

Derived classes should implement the operator form for the assignment for each source type which allows for a non-trivial assignment. This includes the particular case were the source and destination types match exactly. In the latter case the DoAssign method should be invoked. In contrast to the Assign function, the operator form must not be reimplemented for missmatched source types: the operator form only accepts sensible source types. This allows for compiletime typeckecking. However, the downside is that when the type is not known at compiletime, configuration is not properly assigned.

Re-implementation can be done via the convenience macros FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.

Parameters
rSrcSource to copy from
Returns
Reference to this object.

Definition at line 1135 of file cfl_types.cpp.

◆ operator==()

bool faudes::Type::operator==

Test equality of configuration data.

The operator form of the equality test is only defined for matching types, no cast will be performed. Thus, the test will be optimistic if the type is not known at compiletime. The object name or id is not considered in the test.

This methoc calls the virtual method DoEqual(). Re-implementation can be done via the convenience macros FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.

Parameters
rOtherOther object to compare with.
Returns
True on match.

Definition at line 1136 of file cfl_types.cpp.

◆ Prototype() [1/2]

void faudes::TypeDefinition::Prototype ( faudes::Type pType)
protectedvirtual

Use given object as prototype.

The TypeDefinition takes ownership of the provided object.

Parameters
pTypeAny class that inherits Type.

Definition at line 820 of file cfl_types.cpp.

◆ Prototype() [2/2]

const Type * faudes::TypeDefinition::Prototype ( void  ) const

Return pointer to faudes-object prototype.

Note: this method is meant for inspection only, control over the prototype remains with the TypeDefinition. Use NewObject() to instantiate a new faudes-object.

Returns
Reference to prototype object

Definition at line 815 of file cfl_types.cpp.

◆ XElementTag() [1/2]

void faudes::TypeDefinition::XElementTag ( const std::string &  rTag)

Parameter access: Xml Element Tag.

Parameters
rTagNew tag parameter

Definition at line 852 of file cfl_types.cpp.

◆ XElementTag() [2/2]

const std::string & faudes::TypeDefinition::XElementTag ( void  ) const

Parameter access: Xml Element Tag.

This parameter is used for Xml IO of sets and vectors. It determines the tag to used for individual elments.

Returns
Tag parameter.

Definition at line 847 of file cfl_types.cpp.

Friends And Related Function Documentation

◆ TypeRegistry

friend class TypeRegistry
friend

Definition at line 1473 of file cfl_types.h.

Member Data Documentation

◆ mpType

Type* faudes::TypeDefinition::mpType
protected

Type-pointer tp prototype instance.

Definition at line 1701 of file cfl_types.h.

◆ mXElementTag

std::string faudes::TypeDefinition::mXElementTag
protected

Extra documentation/parameter: Xml Element Tag.

Definition at line 1704 of file cfl_types.h.


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

libFAUDES 2.32f --- 2024.12.22 --- c++ api documentaion by doxygen