libFAUDES

Sections

Index

rtitypes.h

Go to the documentation of this file.
00001 /** @file rtitypes.h Runtime interface, faudes types */
00002 
00003 /* FAU Discrete Event Systems Library (libfaudes)
00004 
00005 Copyright (C) 2009 Ruediger Berndt
00006 Copyright (C) 2009 Thomas Moor
00007 
00008 This library is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU Lesser General Public
00010 License as published by the Free Software Foundation; either
00011 version 2.1 of the License, or (at your option) any later version.
00012 
00013 This library is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 Lesser General Public License for more details.
00017 
00018 You should have received a copy of the GNU Lesser General Public
00019 License along with this library; if not, write to the Free Software
00020 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00021 
00022 
00023 #ifndef FAUDES_RTITYPES_H
00024 #define FAUDES_RTITYPES_H
00025 
00026 #include <list>
00027 #include <string>
00028 #include <vector>
00029 #include <map>
00030 #include <utility>
00031 #include <string>
00032 #include <iostream>
00033 #include <typeinfo>
00034 #include <algorithm>
00035 
00036 #include "definitions.h"
00037 #include "token.h"
00038 #include "tokenreader.h"
00039 #include "tokenwriter.h"
00040 #include "exception.h"
00041 
00042 
00043 
00044 
00045 namespace faudes {
00046 
00047 
00048 /************************************************
00049  ************************************************
00050  ************************************************/
00051 
00052 
00053 /** @defgroup RunTimeInterface  Run-Time Interface
00054 
00055 The libFAUDES run-time interface (RTI) facilitates the development 
00056 of applications that are transparent to libFAUDES extensions.
00057 It provides a TypeRegistry for the application 
00058 to instantiate objects by specifying their type as a std::string. 
00059 The TypeRegistry is accompanied by the FunctionRegistry for 
00060 the application to execute functions by their name. Thus, a libFAUDES
00061 application can query both registries and provide the 
00062 supported types and functions to the user. 
00063 The <a href="../registry/index.html">libFAUDES user-reference</a> 
00064 is set up by the build system to represent the contents of both
00065 registries.
00066 
00067 The run-time interface is implemented
00068 by the following components:
00069 - base class faudes::Type for RTI enabled classes (faudes-types)
00070 - documentation class faudes::TypeDefinition to accompany faudes-types;
00071 - container class faudes::TypeRegistry to hold faudes::TypeDefintiion objects;
00072 - base class faudes::Function for RTI enabled function wrappers (faudes-functions);
00073 - documentation class faudes::FunctionDefinition to accompany faudes-functions;
00074 - container class faudes::FunctionRegistry to hold FunctionDefintiion objects.
00075 
00076 @section RunTimeInterfaceSec2 Faudes-Types
00077 
00078 Classes that participate in the run-time interface are referred to
00079 as faudes-types, instances are so called faudes-objects. Any faudes-type must
00080 be derived from the base class faudes::Type. Thus, a faudes-type inherits
00081 the convenience interface for token io from Type, and, most relevent for the run-time 
00082 interface, the factory function New(): each faudes-types must reimplement New() 
00083 to allocate a new object of their respective type on heap. For a fully functional
00084 faudes-type, also an appropriate assignment operator and a copy constructor
00085 are required.
00086 
00087 
00088 @section RunTimeInterfaceSec3 Faudes-Type Definitions
00089 
00090 A faudes-type is accompanied by an instance of faudes::TypeDefinition. It holds
00091 a name (std::string) to identify the faudes-type,
00092 documentation (short text and html reference), 
00093 and one faudes-object of the respective faudes-type.
00094 The latter is referred to as the prototype object and its New() method is used to construct 
00095 new faudes-objects of the respective faudes-type. Thus, given a TypeDefinition,
00096 one can instantiate a corresponding faudes-object. To setup a
00097 FunctionDefinition, you are meant to provide the faudes-type name, the protototype
00098 and a file from which to read the documentation.
00099 
00100 
00101 @section RunTimeInterfaceSec4 Faudes-Functions and Faudes-Function Definitions
00102 
00103 Functions that participate in the run-time interface are organized similar
00104 to faudes-types. There is a base class faudes::Function from which to derive 
00105 particular faudes-functions. The base class provides an interface to set
00106 function parameter values and to actually  execute the function on the parameters. 
00107 To derive a class from Function, you must reimplement the methods New(), DoTypeCheck(), 
00108 and DoExecute(). The DoTypeCheck method is supposed to use a dynamic cast
00109 to initialize typed references to the function parameters. The DoExecute method
00110 then executes the function, typically by invoking a function via its
00111 c++ api. Each Function class is accompanied by a faudes::FunctionDefinition instance
00112 which holds a prototype, basic documentation and a list of valid signatures. The signatures
00113 represent valid parameter type configurations in terms of faudes-types. 
00114 
00115 @section RunTimeInterfaceSec5 Type- and Function-Registry 
00116 
00117 The faudes::TypeRegistry and the faudes::FunctionRegistry are containers for TypeDefinition
00118 and FunctionDefinition instances, respectively. Applications access the registries via
00119 faudes-type names and faudes-function names, see e.g. the global functions NewObject() and
00120 NewFunction(). There is also in interface to iterate through the regsitries and
00121 to test for the existence of an entry. However, while both registries inherit the std token-io
00122 interface, neither registry can be fully configured by reading from file. This is because
00123 each entry requires not only data (documentation, signature, etc) but also a prototype
00124 instance. The std c++ run-time type information (RTTI) does not provide a mechanism
00125 to instatiate an object of a class that is specified at runtime. Thus, each protototype
00126 must be specified at compiletime. This is done by in global function
00127 LoadRegistry(). It inserts each prototype together with its faudes-type or -function name,
00128 to subsquently read further documentation from a configuration file ("libfaudes.rti").
00129 The build system provides two hooks in this process to minimise the amount of 
00130 extra handwritten code.
00131  
00132 
00133 @section RunTimeInterfaceSec6 RTI and the Build System
00134 
00135 At stage <tt>make configure</tt>, the build system sets up the function LoadRegistry()
00136 by  
00137 - setting the macro FAUDES_PLUGINS_RTILOAD to a list of function calls in order to invoke
00138    one load function per plugin;
00139 - running the tool <tt>rti2code</tt> to generate c code to register faudes-types and
00140    -functions found in the configuration file ("libfaudes.rti").
00141 
00142 Code generation should work for all types and functions with documentation entry "CType()" specified. 
00143 Since there is only one CType() entry, all signatures of a function must be implemented by a single
00144 c-function. The generated code is placed at "./include/rtiautoload.*". The build system also provides 
00145 support to merge the configuration file from various sources, incl. plugins.
00146 
00147 To have your C++ class participate in the libFAUDES run-time interface:
00148 
00149 -# derive your class from faudes::Type;
00150 -# make sure your class has a copy constructor;
00151 -# use the provided macros to reimplement the virtual functions New(), Copy(), Cast(), Assign(),
00152    Equal(), and the operators =, == and !=;
00153 -# reimplement the virtual functions DoRead(), DoWrite() and Clear();
00154 -# optionally, reimplement the alternative output formats DoDWrite(), DoSWrtite(),
00155    DoAssign() and DoEqual();
00156 -# provide an .rti file for the formal TypeDefinition; 
00157 -# supplement your .rti file by an html formated documentation text;  
00158  
00159 You will need to inspect and edit the main Makefile or your plugin's Makefile
00160 to advertise your additional sources. A <tt>make configure</tt> will then
00161 assemble all bits and pieces.
00162 
00163 To have your C++ function participate in the libFAUDES run-time interface:
00164 
00165 -# Make sure all your parameters are faudes-types;
00166 -# Provide an .rti file for the formal FunctionDefinition, advertise this file;
00167    either in the main Makefile or in the Makefile of your plugin;
00168 -# supplement yout .rti file by an html formated documentation text;  
00169 
00170 
00171 */
00172 
00173 
00174 
00175 /**
00176  * Base class of all libFAUDES objects that participate in
00177  * the run time interface. Eg, generator, alphabet, attributes etc.
00178  * The class is designed to impose as little overhead as possible, and
00179  * hence, does not hold any data. It does, however, provide a
00180  * uniform interface for token IO, assignment, and the run-time interface.
00181  *
00182  * Token IO converts to objects configuration data to and from token streams.
00183  * It can be facilitated for file IO but also for conversions to/from std::string.
00184  * When deriving from Type, you should reimplement virtual protected
00185  * - DoRead to read the defining data from a token stream
00186  * - DoWrite to write the defining data to a token stream
00187  *
00188  * To support the faudes run-time interface, the class Type also 
00189  * declares the virtual functions for type-cast and assignment
00190  * - New to construct an object of identical type on heap, 
00191  * - Clear to reset all configuration data,
00192  * - Cast to dynamically cast another object to this type,
00193  * - Assign to do an assignment from any castable Type derivate
00194  * - Equal to test equality with any castable Type derivate
00195  * - DoAssign, or the operator "=", to assign from an object with identical type.
00196  * - DoEqual, or the operators "==" and "!=", to test equality of configuration data
00197  * 
00198  * While New, Cast, Assign, Equal and the operators "=", "==", "!=" can be derived via the
00199  * convenience macros FAUDES_TYPE_DELARATION and FAUDES_TYPE_IMPLEMENTATION,
00200  * Clear, DoAssign and DoEqual must be adapted to the actual member data.
00201  *
00202  * @ingroup RunTimeInterface
00203  */
00204    
00205 class Type {
00206 
00207  public:
00208 
00209   /** Constructor */
00210   Type(void);
00211 
00212   /** Copy constructor */
00213   Type(const Type& rType);
00214 
00215   /** Destructor */
00216   virtual ~Type(void);
00217 
00218   /**
00219    * Construct on heap. 
00220    * Technically not a constructor, this function creates an object with the
00221    * same type Type. New() is defined as a virtual function and derived
00222    * classes are meant to re-implement with the appropiate constructor.
00223    * This can be done via the provided macros FAUDES_TYPE_DECLARATION and
00224    * FAUDES_TYPE_IMPLEMENTATION.
00225    * As with new, it is the callers reponsabilty to delete the object when no longer needed.
00226    *
00227    * @return 
00228    *   Pointer to new Type object
00229    */
00230   virtual Type* New(void) const;
00231 
00232   /**
00233    * Construct on heap. 
00234    * Technically not a constructor, this function creates an object with the
00235    * same type Type and the same configuration. Copy() is defined as a virtual function and derived
00236    * classes are meant to re-implement with the appropiate copy constructor.
00237    * This can be done via the provided macros FAUDES_TYPE_DECLARATION and
00238    * FAUDES_TYPE_IMPLEMENTATION.
00239    * As with new, it is the callers reponsabilty to delete the object when no longer needed.
00240    *
00241    * @return 
00242    *   Pointer to new Type object
00243    */
00244   virtual Type* Copy(void) const;
00245 
00246   /**
00247    * Cast other object to this type.
00248    * Enables the run-time interface to test whether pObject is derived
00249    * from this object. This feature is used e.g. in the faudes container
00250    * classes to test attributes. Derived classes must reimplement this
00251    * function using the appropriate dynamic cast.
00252    *
00253    * Re-implementation can be done via the convenience macros
00254    * FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.
00255    *
00256    * @return 
00257    *   Typed pointer object
00258    */
00259   virtual const Type* Cast(const Type* pOther) const;
00260 
00261   /**
00262    * Clear configuration data.  Derived classes should re-implement this
00263    * method to ensure some consistent configuration data.
00264    */
00265   virtual void Clear(void);
00266 
00267   /**
00268    * Assign configuration data from other object. 
00269    * Derived classes should reimplement this method to first try to cast
00270    * the source to the respective class. If successful, the protected 
00271    * function DoAssign is invoked to perform the actual assignment. If the cast fails,
00272    * the Assign method of the parent class is called. Thus, faudes
00273    * objects are up- and downcatsted for assignment, maintaining as much of
00274    * the source data as digestable by the destination object. On the downside,
00275    * there is no sensible typechecking at compile-time.
00276    *
00277    * Re-implementation can be done via the convenience macros
00278    * FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.
00279    * 
00280    * @param rSrc 
00281    *    Source to copy from
00282    * @return Reference to this object.
00283    */
00284   virtual Type& Assign(const Type& rSrc);
00285 
00286 
00287   /**
00288    * Assign configurationdata from other object. 
00289    * Derived classes should implement the operator form for the assignment
00290    * for each source type which allows for a non-trivial assignment. This includes
00291    * the particular case were the source and destination types match exactly. In the
00292    * latter case the DoAssign method should be invoked. In contrast to
00293    * the Assign function, the operator form must not be reimplemented for
00294    * missmatched source types: the operator form only accepts sensible source types.
00295    * This allows for compiletime typeckecking. However, the downside is that
00296    * when the type is not known at compiletime, configuration is not properly
00297    * assigned.
00298    *
00299    * Re-implementation can be done via the convenience macros
00300    * FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.
00301    * 
00302    * @param rSrc 
00303    *    Source to copy from
00304    * @return Reference to this object.
00305    */
00306   virtual Type& operator=(const Type& rSrc);
00307 
00308   /**
00309    * Test equality of configuration data.
00310    * Derived classes should reimplement this method to return true
00311    * if both actual types and configuration data match.
00312    * The object name is not consired in the test.
00313    *
00314    * This method calls the virtual method DoEqual(). Re-implementation can 
00315    * be done via the convenience macros
00316    * FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.
00317    * 
00318    * @param rOther 
00319    *    Other objevt to compare with.
00320    * @return 
00321    *   True on match.
00322    */
00323   virtual bool Equal(const Type& rOther) const;
00324 
00325   /**
00326    * Test equality of configuration data.
00327    * The operator form of the equality test is only defined for matching
00328    * types, no cast will be performed. Thus, the test will be optimistic
00329    * if the type is not known at compiletime.
00330    * The object name is not consired in the test.
00331    *
00332    * This methoc calls the virtual method DoEqual(). Re-implementation can 
00333    * be done via the convenience macros
00334    * FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.
00335    * 
00336    * @param rOther 
00337    *    Other objevt to compare with.
00338    * @return 
00339    *   True on match.
00340    */
00341   virtual bool operator==(const Type& rOther) const;
00342 
00343 
00344   /**
00345    * Test equality of configuration data.
00346    * See operator==(const Type&).
00347    *
00348    * This method calls the virtual method DoEqual(). Re-implementation can 
00349    * be done via the convenience macros
00350    * FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.
00351    * 
00352    * @param rOther 
00353    *    Other objevt to compare with.
00354    * @return 
00355    *   True on mismatch.
00356    */
00357   virtual bool operator!=(const Type& rOther) const;
00358 
00359 
00360   /** 
00361    * Set the objects's name.
00362    *
00363    * The base class Type does not implement an object name,
00364    * derivatives usually do so, except for attributes. 
00365    *
00366    * @param rName
00367    *   Name
00368    */
00369   virtual void Name(const std::string& rName);
00370 
00371   /** 
00372    * Get objects's name 
00373    *
00374    * The base class Type does not implement an object name,
00375    * derivatives usually do so, except for attributes. 
00376    * @return 
00377    *   Name of generator
00378    */
00379   virtual const std::string& Name(void) const;
00380 
00381 
00382   /**
00383    * Write configuration data to console.
00384    * Note: this write function uses the virtual function DoWrite(), to be 
00385    * reimplemented by derived classes.
00386    *
00387    * @param pContext
00388    *   Write context to provide contextual information
00389    *
00390    */
00391   void Write(const Type* pContext=0) const;
00392 
00393   /**
00394    * Write configuration data to a file. 
00395    * Note: this write function uses the virtual function DoWrite(), to be 
00396    * reimplemented by derived classes.
00397    *
00398    * @param pFileName
00399    *   Name of file
00400    * @param rLabel
00401    *   Label of section to write
00402    * @param pContext
00403    *   Write context to provide contextual information
00404    * @param openmode
00405    *   ios::openmode 
00406    *
00407    * @exception Exception
00408    *   - IO errors (id 2)
00409    */
00410   void Write(const std::string& pFileName, const std::string& rLabel="",
00411        const Type* pContext=0, std::ios::openmode openmode = std::ios::out|std::ios::trunc) const;
00412 
00413   /**
00414    * Write configuration data to a file. 
00415    * Note: this write function uses the virtual function DoWrite(), to be 
00416    * reimplemented by derived classes.
00417    *
00418    * @param pFileName
00419    *   Name of file
00420    * @param openmode
00421    *   ios::openmode 
00422    *
00423    * @exception Exception
00424    *   - IO errors (id 2)
00425    */
00426   void Write(const std::string& pFileName, std::ios::openmode openmode) const;
00427 
00428   /**
00429    * Write configuration data to TokenWriter.
00430    * Note: this write function uses the virtual function DoWrite(), to be 
00431    * reimplemented by derived classes.
00432    *
00433    * @param rTw
00434    *   Reference to TokenWriter
00435    * @param rLabel
00436    *   Label of section to write
00437    * @param pContext
00438    *   Write context to provide contextual information
00439    *
00440    * @exception Exception 
00441    *   - IO errors (id 2)
00442    */
00443   void Write(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const;
00444 
00445   /**
00446    * Write configuration data to a string.
00447    * Note: this write function uses the virtual function DoWrite(), to be 
00448    * reimplemented by derived classes.
00449    *
00450    * @param rLabel
00451    *   Label of section to write
00452    * @param pContext
00453    *   Write context to provide contextual information
00454    * @return
00455    *   output string
00456    * @exception Exception
00457    *   - IO errors (id 2)
00458    */
00459   std::string ToString(const std::string& rLabel="", const Type* pContext=0) const;
00460 
00461   /**
00462    * Write configuration data to a formated string.
00463    * In contrast to ToString, ToText does not suppress comments and
00464    * End-Of-Line marks. 
00465    * Note: this write function uses the virtual function DoWrite(), to be 
00466    * reimplemented by derived classes.
00467    *
00468    * @param rLabel
00469    *   Label of section to write
00470    * @param pContext
00471    *   Write context to provide contextual information
00472    * @return
00473    *   output string
00474    * @exception Exception
00475    *   - IO errors (id 2)
00476    */
00477   std::string ToText(const std::string& rLabel="", const Type* pContext=0) const;
00478 
00479   /**
00480    * Write configuration data to console, debugging format.
00481    * Note: this write function uses the virtual function DoDWrite(), to be 
00482    * reimplemented by derived classes.
00483    *
00484    * @param pContext
00485    *   Write context to provide contextual information
00486    *
00487    */
00488   void DWrite(const Type* pContext=0) const;
00489 
00490   /**
00491    * Write configuration data to a file, debugging format. 
00492    * Note: this write function uses the virtual function DoDWrite(), to be 
00493    * reimplemented by derived classes.
00494    *
00495    * @param pFileName
00496    *   Name of file
00497    * @param rLabel
00498    *   Label of section to write
00499    * @param pContext
00500    *   Write context to provide contextual information
00501    * @param openmode
00502    *   ios::openmode 
00503    *
00504    * @exception Exception
00505    *   - IO errors (id 2)
00506    */
00507   void DWrite(const std::string& pFileName, const std::string& rLabel="",
00508         const Type* pContext=0, std::ios::openmode openmode = std::ios::out|std::ios::trunc) const;
00509 
00510   /**
00511    * Write configuration data in debug format to TokenWriter.
00512    * Note: this write function uses the virtual function DoWrite(), to be 
00513    * reimplemented by derived classes.
00514    *
00515    * @param rTw
00516    *   Reference to TokenWriter
00517    * @param rLabel
00518    *   Label of section to write
00519    * @param pContext
00520    *   Write context to provide contextual information
00521    *
00522    * @exception Exception 
00523    *   - IO errors (id 2)
00524    */
00525   void DWrite(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const;
00526 
00527   /**
00528    * Write statistics comment to TokenWriter.
00529    * Note: this write function use the virtual function DoSWrite(), to be 
00530    * reimplemented by derived classes.
00531    *
00532    * @param rTw
00533    *   Reference to TokenWriter
00534    *
00535    * @exception Exception 
00536    *   - IO errors (id 2)
00537    */
00538   void SWrite(TokenWriter& rTw) const;
00539 
00540   /**
00541    * Write statistics comment to console.
00542    * Note: this write function uses the virtual function DoSWrite(), to be 
00543    * reimplemented by derived classes.
00544    *
00545    */
00546   void SWrite(void) const;
00547 
00548   /**
00549    * Write statistics to a string.
00550    * Note: this write function uses the virtual function DoSWrite(), to be 
00551    * reimplemented by derived classes.
00552    *
00553    * @return
00554    *   output string
00555    * @exception Exception
00556    *   - IO errors (id 2)
00557    */
00558   std::string ToSText(void) const;
00559 
00560   /**
00561    * Read configuration data from file with label specified.
00562    * Note: all read functions use the virtual function DoRead(), to be 
00563    * reimplemented for by derived classes.
00564    *
00565    * @param rFileName
00566    *   Name of file
00567    * @param rLabel
00568    *   Section to read from 
00569    * @param pContext
00570    *   Read context to provide contextual information
00571    *
00572    * @exception Exception
00573    *   - IO errors (id 1)
00574    *   - token mismatch from DoRead()
00575    */
00576   void Read(const std::string& rFileName, const std::string& rLabel = "", const Type* pContext=0);
00577 
00578   /**
00579    * Write configuration data to a string.
00580    * Note: this write function uses the virtual function DoWrite(), to be 
00581    * reimplemented by derived classes.
00582    *
00583    * @param rString
00584    *   String to read from
00585    * @param rLabel
00586    *   Section to read
00587    * @param pContext
00588    *   Read context to provide contextual information
00589    * @exception Exception
00590    *   - IO errors (id 1)
00591    *   - token mismatch from DoRead()
00592    */
00593   void FromString(const std::string& rString, const std::string& rLabel="", const Type* pContext=0);
00594 
00595   /**
00596    * Read configuration data from TokenReader with label sepcified.
00597    * Note: all read functions use the virtual function DoRead(), to be 
00598    * reimplemented for by derived classes.
00599    *
00600    * @param rTr
00601    *   Reference to tokenreader
00602    * @param rLabel
00603    *   Section to read
00604    * @param pContext
00605    *   Read context to provide contextual information
00606    *
00607    * @exception Exception
00608    *   - IO errors (id 1)
00609    *   - token mismatch from DoRead()
00610    */
00611   void Read(TokenReader& rTr, const std::string& rLabel = "", const Type* pContext=0);
00612 
00613 
00614  protected:
00615 
00616   /**
00617    * Assign configuration data from other object. 
00618    *
00619    * Reimplement this function to copy all configuration data from
00620    * another faudes object. Typically, you will first call the base class'
00621    * DoAssign, which includes a Clear(). Then, you will set up any additional members.
00622    *
00623    * @param rSrc 
00624    *    Source to copy from
00625    * @return Reference to this object.
00626    */
00627   virtual Type& DoAssign(const Type& rSrc);
00628 
00629   /**
00630    * Test equality of configuration data.
00631    * Derived classes should reimplement this method to compare all relevant 
00632    * configuration, except the name.
00633    * 
00634    * @param rOther 
00635    *    Other object to compare with.
00636    * @return 
00637    *   True on match.
00638    */
00639   virtual bool DoEqual(const Type& rOther) const;
00640 
00641 
00642   /**
00643    * Read configuration data of this object from TokenReader.
00644    *
00645    * Reimplement this method in derived classes to provide the std token io
00646    * interface defined in the public section of Type.
00647    *
00648    * @param rTr
00649    *   TokenReader to read from
00650    * @param rLabel
00651    *   Section to read
00652    * @param pContext
00653    *   Read context to provide contextual information
00654    *
00655    * @exception Exception
00656    *   - IO error (id 1)
00657    */
00658   virtual void DoRead(TokenReader& rTr,  const std::string& rLabel = "", const Type* pContext=0);
00659  
00660   /**
00661    * Write configuration data of this object to TokenWriter.
00662    *
00663    * Reimplement this method in derived classes to provide the std token io
00664    * interface defined in the public section of Type.
00665    *
00666    * @param rTw
00667    *   Reference to TokenWriter
00668    * @param rLabel
00669    *   Label of section to write
00670    * @param pContext
00671    *   Write context to provide contextual information
00672    *
00673    * @exception Exception 
00674    *   - IO errors (id 2)
00675    */
00676   virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const;
00677 
00678   /**
00679    * Write configuration data in debugging format to TokenWriter.
00680    *
00681    * Reimplement this method in derived classes to provide the std token io
00682    * interface defined in the public section of Type.
00683    *
00684    * @param rTw
00685    *   Reference to TokenWriter
00686    * @param rLabel
00687    *   Label of section to write
00688    * @param pContext
00689    *   Write context to provide contextual information
00690    *
00691    * @exception Exception 
00692    *   - IO errors (id 2)
00693    */
00694   virtual void DoDWrite(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const;
00695 
00696   /**
00697    * Write statistical data as a comment to TokenWriter.
00698    *
00699    * Reimplement this method in derived classes to provide the std token io
00700    * interface defined in the public section of Type.
00701    *
00702    * @param rTw
00703    *   Reference to TokenWriter
00704    *
00705    * @exception Exception 
00706    *   - IO errors (id 2)
00707    */
00708   virtual void DoSWrite(TokenWriter& rTw) const;
00709 
00710   /** static default name */
00711   const static std::string mName;
00712 
00713 };
00714 
00715 
00716 
00717 
00718 /** faudes type declaration macro */
00719 #define FAUDES_TYPE_DECLARATION(ftype,fbase)    \
00720   public: \
00721   virtual ftype* New(void) const; \
00722   virtual ftype* Copy(void) const; \
00723   virtual const ftype* Cast(const Type* pOther) const; \
00724   virtual ftype& Assign(const Type& rSrc); \
00725   virtual bool Equal(const Type& rOther) const; \
00726   virtual ftype& operator=(const ftype& rSrc); \
00727   virtual bool operator==(const ftype& rOther) const; \
00728   virtual bool operator!=(const ftype& rOther) const;
00729 
00730 /** faudes type implementation macros, individual */
00731 #define FAUDES_TYPE_IMPLEMENTATION_NEW(ftype,fbase,ftemp) \
00732   ftemp ftype* ftype::New(void) const {     \
00733     return new ftype(); } 
00734 #define FAUDES_TYPE_IMPLEMENTATION_COPY(ftype,fbase,ftemp)  \
00735   ftemp ftype* ftype::Copy(void) const {      \
00736     return new ftype(*this); } 
00737 #define FAUDES_TYPE_IMPLEMENTATION_CAST(ftype,fbase,ftemp)  \
00738   ftemp const ftype* ftype::Cast(const Type* pOther) const { \
00739     return dynamic_cast<const ftype*>(pOther);} 
00740 #define FAUDES_TYPE_IMPLEMENTATION_ASSIGN(ftype,fbase,ftemp)  \
00741   ftemp ftype& ftype::Assign(const Type& rSrc) { \
00742     if(const ftype* csattr=dynamic_cast<const ftype*>(&rSrc)) { this->Clear(); return DoAssign(*csattr);} \
00743     fbase::Assign(rSrc); \
00744     return *this;} \
00745   ftemp ftype& ftype::operator=(const ftype& rSrc) { this->Clear(); return DoAssign(rSrc); }
00746 #define FAUDES_TYPE_IMPLEMENTATION_EQUAL(ftype,fbase,ftemp) \
00747   ftemp bool ftype::Equal(const Type& rOther) const { \
00748     if(&rOther==this) return true; \
00749     if(typeid(rOther) != typeid(*this)) return false; \
00750     const ftype* csattr=dynamic_cast<const ftype*>(&rOther); \
00751     if(!csattr) return false; \
00752     if(!DoEqual(*csattr)) return false;   \
00753     return true;} \
00754     ftemp bool ftype::operator==(const ftype& rOther) const { return DoEqual(rOther); } \
00755     ftemp bool ftype::operator!=(const ftype& rOther) const { return !DoEqual(rOther); }
00756 
00757 
00758 /** faudes type implementation macros, overall */
00759 #define FAUDES_TYPE_IMPLEMENTATION(ftype,fbase,ftemp) \
00760   ftemp ftype* ftype::New(void) const {     \
00761     return new ftype(); }  \
00762   ftemp ftype* ftype::Copy(void) const {      \
00763     return new ftype(*this); }  \
00764   ftemp const ftype* ftype::Cast(const Type* pOther) const { \
00765     return dynamic_cast<const ftype*>(pOther);} \
00766   ftemp ftype& ftype::Assign(const Type& rSrc) { \
00767     if(const ftype* csattr=dynamic_cast<const ftype*>(&rSrc)) { this->Clear(); return DoAssign(*csattr);} \
00768     fbase::Assign(rSrc); \
00769     return *this;} \
00770   ftemp ftype& ftype::operator=(const ftype& rSrc) { this->Clear(); return DoAssign(rSrc); } \
00771   ftemp bool ftype::Equal(const Type& rOther) const { \
00772     if(&rOther==this) return true; \
00773     if(typeid(rOther) != typeid(*this)) return false; \
00774     const ftype* csattr=dynamic_cast<const ftype*>(&rOther);  \
00775     if(!csattr) return false; \
00776     if(!DoEqual(*csattr)) return false;   \
00777     return true;} \
00778   ftemp bool ftype::operator==(const ftype& rOther) const { return DoEqual(rOther); } \
00779   ftemp bool ftype::operator!=(const ftype& rOther) const { return !DoEqual(rOther); }
00780 
00781 /** faudes type implementation macros, overall, debug version */
00782 /*
00783 #define FAUDES_TYPE_IMPLEMENTATION(ftype,fbase,ftemp) \
00784   ftemp ftype* ftype::New(void) const {     \
00785     return new ftype(); }  \
00786   ftemp const ftype* ftype::Cast(const Type* pOther) const { \
00787     return dynamic_cast<const ftype*>(pOther);} \
00788   ftemp ftype& ftype::Assign(const Type& rSrc) { \
00789     FD_WARN("RTI "<< typeid(ftype).name() << "::ASSIGN() V: " << typeid(*this).name() << \
00790       " from " << typeid(rSrc).name()); \
00791     if(const ftype* csattr=dynamic_cast<const ftype*>(&rSrc)) { this->Clear(); return DoAssign(*csattr);} \
00792     fbase::Assign(rSrc); \
00793     return *this;} \
00794   ftemp ftype& ftype::operator=(const ftype& rSrc) { \
00795     FD_WARN("RTI "<< typeid(ftype).name() << "::ASSIGN() O: " << typeid(*this).name() << \
00796       " from " << typeid(rSrc).name()); \
00797     this->Clear(); \
00798     return DoAssign(rSrc); }
00799 */
00800 
00801 
00802 
00803 /**
00804  * Structure to hold documentation data relating to a faudes-type or -function. 
00805  * This class is the common base for faudes::TypeDefinition and faudes::FunctionDefinition. 
00806  * It supports token io as demonstrated by the follwoing example for a type defintion:
00807  *
00808  * @code
00809  *  <TypeDefinition>
00810  *      % name of this faudes-type, incl. colon separated plugin name
00811  *  "CoreFaudes::Generator"
00812  *
00813  *      % corresponding C++ type (optional)
00814  *      +faudes::cGenerator+
00815  *
00816  *      % short docu
00817  *  <TextDoc> "The common 5 tuple G=(Sigma, Q, delta, Qo, Qm)."
00818  *
00819  *      % html reference for documentation
00820  *  <HtmlDoc> "generators.html#plain" </HtmlDoc>
00821  *
00822  *      % relevant keywords 
00823  *  <Keywords> "generator" "language" </Keywords>
00824  *
00825  *  </TypeDefinition>
00826  * @endcode
00827  *
00828  * Technical detail: Documentation is derived from Type for the purpose of token IO only.
00829  * Documentation accompanies a faudes Type, but does itself not constitute a faudes object.
00830  */
00831 
00832 class Documentation : public Type {
00833 
00834  public:
00835   /** Constructor */
00836   Documentation(void);
00837 
00838   /** Destructor */
00839   virtual ~Documentation(void){};
00840 
00841   /**
00842    * Get name of the entety to document (aka faudes-type or faudes-function).
00843    *
00844    * @return
00845    *  Name
00846    */
00847   const std::string& Name(void) const;
00848 
00849   /**
00850    * Get name of plugin.
00851    * The plugin name defaults to CoreFaudes.
00852    *
00853    * @return
00854    *  Name
00855    */
00856   const std::string& PlugIn(void) const;
00857 
00858   /**
00859    * Get corresponding C++ type
00860    *
00861    * @return
00862    *  CType, or "" if no such
00863    */
00864   const std::string& CType(void) const;
00865 
00866   /**
00867    * @return
00868    *  Short textual documentation.
00869    */
00870   const std::string& TextDoc(void) const;
00871 
00872   /**
00873    * @return
00874    *  Filename pointing to the html documentation.
00875    */
00876   const std::string& HtmlDoc(void) const;
00877 
00878   /**
00879    * @return
00880    *  CSV-string containing keywords.
00881    */
00882   const std::string& Keywords(void) const;
00883 
00884   /**
00885    * Search comma-seperated keywords for a substring. This should be
00886    * extended to regular expressions in a future release.
00887    *
00888    * @param rPattern
00889    *  String-pattern.
00890    *
00891    * @return
00892    *  Matching keyword or "" if no match
00893    */
00894   std::string MatchKeyword(const std::string& rPattern) const;
00895 
00896   /**
00897    * Not implemented
00898    * @return
00899    *  Number of keywords.
00900    */
00901   int KeywordsSize(void) const;
00902 
00903   /**
00904    * @param pos
00905    *   Position of keyword
00906    * @return
00907    *  Keyword at specified position (or "" if pos out of range)
00908    */
00909   std::string KeywordAt(int pos) const;
00910 
00911 
00912  protected:
00913 
00914   /**
00915    * Set name.
00916    *
00917    * @param name
00918    *  New name.
00919    */
00920   void Name(const std::string& name);
00921 
00922   /**
00923    * Set name of plugin
00924    *
00925    * @param plugin
00926    *  New name.
00927    */
00928   void PlugIn(const std::string& plugin);
00929 
00930   /**
00931    * Set C++ type
00932    *
00933    * @param name
00934    *  New ctype.
00935    */
00936   void CType(const std::string& name);
00937 
00938   /**
00939    * Set a short textual documentation.
00940    *
00941    * @param textdoc
00942    *  New textual documentation.
00943    */
00944   void TextDoc(const std::string& textdoc);
00945 
00946   /**
00947    * Set name of file pointing to the html documentation.
00948    *
00949    * @param fname
00950    *  Filename
00951    */
00952   void HtmlDoc(const std::string& fname);
00953 
00954   /**
00955    * Append keyword.
00956    *
00957    * @param rKeyword
00958    *  Keyword
00959    */
00960   void AddKeyword(const std::string& rKeyword);
00961 
00962   /**
00963    * Clear 
00964    */
00965   void Clear(void);
00966 
00967   /**
00968    * Read configuration data of this object from TokenReader.
00969    *
00970    * This virtual function reads documentation members only. 
00971    * It does NOT read the enclosing begin and end tokens.
00972    * Both, rLabel and Pontext are ignored.
00973    *
00974    * @param rTr
00975    *   TokenReader to read from
00976    * @param rLabel
00977    *   Section to read
00978    * @param pContext
00979    *   Read context to provide contextual information (ignored)
00980    *
00981    * @exception Exception
00982    *  - Token mismatch (id 50, 51, 52)
00983    *  - IO Error (id 1)
00984    */
00985   virtual void DoRead(TokenReader& rTr,  const std::string& rLabel = "", const Type* pContext=0);
00986  
00987   /**
00988    * Write configuration data of this object to TokenWriter.
00989    *
00990    * This virtual function reads documentation members only. 
00991    * It does NOT write enclosing begin and end tokens.
00992    * Both, rLabel and Pontext are ignored.
00993    *
00994    * @param rTw
00995    *   Reference to TokenWriter
00996    * @param rLabel
00997    *   Label of section to write
00998    * @param pContext
00999    *   Write context to provide contextual information
01000    *
01001    * @exception Exception 
01002    *   - IO errors (id 2)
01003    */
01004   virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const;
01005 
01006 
01007   /** Faudes name. */
01008   std::string mName;
01009 
01010   /** Faudes plugin. */
01011   std::string mPlugIn;
01012 
01013   /** Corresponing C++ type, or "" if no such. */
01014   std::string mCType;
01015 
01016   /** String containing the text-documentation. */
01017   std::string mTextDoc;
01018 
01019   /** String containing the filename of the corresponding html-documentation. */
01020   std::string mHtmlDoc;
01021 
01022   /** Comma-seperated string containing all keywords. */
01023   std::string mKeywords;
01024 
01025   /** Constant characted used to seperate keywords */
01026   static const char mDelim = ';';
01027 
01028 }; // Documentation
01029 
01030 
01031 
01032 /**
01033  * A TypeDefinition defines a faudes-type in that it specifies
01034  * a faudes-type name to identify the type and a method
01035  * NewObject() to instantiate objects of the respective type. 
01036  * In this sense, TypeDefinition is a so called factory class.
01037  * Technically, the TypeDefinition holds one instance of the faude type,
01038  * the so called prototype object, and NewObject() invokes the New() method
01039  * of the prototype. Notebly, there is only one class TypeDefinition that by
01040  * parametrisation defins all derivates of Type.
01041  * 
01042  * TypeDefinition is derived from faudes::Documentation and therefore additional
01043  * documentation-data can be associated.
01044  *
01045  * @ingroup RunTimeInterface
01046  */
01047 
01048 class TypeDefinition : public Documentation {
01049 
01050  public:
01051 
01052   /** 
01053    * Constructor 
01054    *
01055    * The default constructor instantiates an invalid type definition
01056    * without prototype. To construct
01057    * a valid type definition, use the static Constructor() template
01058    * function.
01059    */
01060   TypeDefinition(const std::string& name="") : Documentation(), mpType(NULL) {Name(name);};
01061 
01062   /**
01063    * Destructor.
01064    *
01065    * Delete prototype object.
01066    */
01067   virtual ~TypeDefinition(void){ Prototype(NULL); };
01068 
01069   /**
01070    * Construct empty TypeDefinition object.
01071    * The given template parameter denotes any libFAUDES class derived from faudes::Type
01072    * A new instance of this class is assigned to member variable (pType)
01073    * whereas the name is set as specified.
01074    *
01075    * @tparam T
01076    *   Actual c class, derived from Type
01077    * @param rTypeName
01078    *   Name to identify this faudes-type<; defaults to the plattform
01079    *   dependand typeid from the c++ runtime type information system.
01080    * @return
01081    *   Newly constructed type definition.
01082    *
01083    */
01084   template<class T>
01085   static TypeDefinition* Constructor(const std::string& rTypeName="");
01086 
01087   /**
01088    * Construct empty TypeDefinition object.
01089    * The given prototype is assigned to the member variable pType,
01090    *
01091    * @param pProto
01092    *   Prototype, derived from Type
01093    * @param rTypeName
01094    *   Name to identify this faudes-type<; defaults to the plattform
01095    *   dependand typeid from the c++ runtime type information system.
01096    * @return
01097    *   Newly constructed type definition.
01098    *
01099    */
01100   static TypeDefinition* Constructor(Type* pProto, const std::string& rTypeName="");
01101 
01102   /**
01103    * Construct TypeDefinition object and read name and
01104    * documentation-data from TokenReader.
01105    *
01106    * @tparam T
01107    *   Actual c class, derived from Type
01108    * @param rFileName
01109    *   Name of file to read.
01110    * @return
01111    *   Newly constructed type definition.
01112    *
01113    * @exception Exception
01114    *  - Token mismatch (id 50, 51, 52)
01115    *  - IO Error (id 1)
01116    */
01117   template<class T>
01118   static TypeDefinition* FromFile(const std::string& rFileName);
01119 
01120 
01121   /**
01122    * Return pointer to faudes-object prototype 
01123    *
01124    * Note: this method is meant for inspection only, control over
01125    * the prototype remains with the TypeDefinition. Use
01126    * NewObject() to instantiate a new faudes-object.
01127    *
01128    * @return
01129    *   Reference to prototype object
01130    */
01131   const Type* Prototype(void) const;
01132 
01133 
01134   /**
01135    * Construct faudes-object on heap.
01136    * Return pointer to new instance of assigned Type class.
01137    *
01138    * Note: If no prototype is installed, NULL is returned.
01139    *
01140    * @return
01141    *  Pointer to new Type instance.
01142    */
01143   Type* NewObject(void) const;
01144 
01145   /**
01146    * Merge documentation and from token stream.
01147    * This member reads the body of the TypeDefinition token format
01148    * and sets the documentation and accordingly. An exception is
01149    * thrown if the current type name differs from the one in the documentation.
01150    *
01151    * @param rTr
01152    *  TokenReader to read from.
01153    *
01154    * @exception Exception
01155    *  - Type mismatch (id )
01156    *  - Token mismatch (id 50, 51, 52)
01157    *  - IO Error (id 1)
01158    */
01159   void MergeDocumentationBody(TokenReader& rTr);
01160 
01161  protected:
01162 
01163 
01164   /** Disable copy constructor */
01165  TypeDefinition(const TypeDefinition& rOther) : Documentation(rOther) {}; // todo: implement ?? for stl maps ?
01166 
01167   /**
01168    * Clear documentation-data; do *NOT* delete prototype  (this is for using Read to 
01169    * merge/overwrite documentation)
01170    */
01171   void Clear(void);
01172 
01173   /**
01174    * Use given object as prototype.
01175    *
01176    * The TypeDefinition takes ownership of the
01177    * provided object.
01178    *
01179    * @param pType
01180    *  Any class that inherits Type.
01181    */
01182   void Prototype(Type* pType);
01183 
01184   /**
01185    * Read configuration data of this object from TokenReader.
01186    *
01187    * The section is hardcode to "TypeDefinition", context ignored.
01188    *
01189    * @param rTr
01190    *   TokenReader to read from
01191    * @param rLabel
01192    *   Section to read
01193    * @param pContext
01194    *   Read context to provide contextual information (ignored)
01195    *
01196    * @exception Exception
01197    *   - IO error (id 1)
01198    */
01199   virtual void DoRead(TokenReader& rTr,  const std::string& rLabel = "", const Type* pContext=0);
01200  
01201   /**
01202    * Write configuration data of this object to TokenWriter.
01203    *
01204    * The section is hardcode to "TypeDefinition", context ignored.
01205    *
01206    * @param rTw
01207    *   Reference to TokenWriter
01208    * @param rLabel
01209    *   Label of section to write
01210    * @param pContext
01211    *   Write context to provide contextual information
01212    *
01213    * @exception Exception 
01214    *   - IO errors (id 2)
01215    */
01216   virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const;
01217 
01218   /** Type-pointer to store address of libFAUDES-Type instance */
01219   Type* mpType;
01220 
01221 }; //TypeDefinition
01222 
01223 
01224 /*
01225 ********************************************************************
01226 ********************************************************************
01227 ********************************************************************
01228 
01229 Elementary type, representing an integer value.
01230 
01231 ********************************************************************
01232 ********************************************************************
01233 ********************************************************************
01234 */
01235 
01236 /** Elementary type */
01237 class Integer : public Type {
01238 
01239  public:
01240   /** Constructor */
01241   Integer(void);
01242 
01243   /**
01244    * Constructor provided with initial value.
01245    *
01246    * @param val
01247    *  Initial value.
01248    */
01249   Integer(SignedIdx val);
01250 
01251   /** Destructor */
01252   ~Integer(void){}
01253 
01254   /**
01255    * Construct on heap.
01256    * Create new Integer instance and return pointer.
01257    *
01258    * @return
01259    *  Pointer to Integer instance.
01260    *
01261    */
01262   virtual Type* New(void) const;
01263 
01264   /**
01265    * Construct copy on heap.
01266    * Create new Integer instance and return pointer.
01267    *
01268    * @return
01269    *  Pointer to Integer instance.
01270    *
01271    */
01272   virtual Type* Copy(void) const;
01273 
01274   /**
01275    * Set value.
01276    *
01277    * @param val
01278    *  Value to be set. (SignedIdx)
01279    */
01280   void CValue(SignedIdx val);
01281 
01282   /**
01283    * Get value.
01284    *
01285    * @return
01286    *  Value of object. (SignedIdx)
01287    */
01288   SignedIdx CValue(void) const;
01289 
01290   /**
01291    * Get reference.
01292    *
01293    * @return
01294    *  Reference to c value.
01295    */
01296   SignedIdx* CReference(void);
01297 
01298   /**
01299    * Sum operator.
01300    */
01301   Integer operator+ (const SignedIdx& clint){
01302     CValue(mCInteger + clint);
01303     return(*this);
01304   }
01305 
01306   /**
01307    * Sum operator.
01308    */
01309   Integer operator+ (const Integer& coint){
01310     CValue(mCInteger + coint.CValue());
01311     return(*this);
01312   }
01313 
01314   /**
01315    * Assignment operator.
01316    */
01317   Integer operator= (const SignedIdx& clint){
01318     CValue(clint);
01319     return(*this);
01320   }
01321 
01322   /**
01323    * Assignment operator.
01324    */
01325   Integer operator= (const Integer& coint){
01326     CValue(coint.CValue());
01327     return(*this);
01328   }
01329 
01330   /**
01331    * Assignment/Sum operator
01332    */
01333   Integer operator+= (const SignedIdx& clint){
01334     SignedIdx litmp = CValue();
01335     CValue(litmp + clint);
01336     return(*this);
01337   }
01338 
01339   /**
01340    * Assignment/Sum operator
01341    */
01342   Integer operator+= (const Integer& coint){
01343     SignedIdx litmp = CValue() + coint.CValue();
01344     CValue(litmp);
01345     return(*this);
01346   }
01347 
01348   /**
01349    * Conversion to C++ type 
01350    */
01351   operator SignedIdx() const { return CValue();};
01352 
01353 
01354   /**
01355    * Reimplementation of faudes::Type::DoWrite()
01356    * Write data to Tokenwriter.
01357    *
01358    * @param rTw
01359    *  Reference to TokenWriter.
01360    * @param rLabel
01361    *  Label of section to write.
01362    * @param pContext
01363    *    Context information
01364    *
01365    * @exception Exception
01366    *  - IO Error (id 2)
01367    */
01368   void DoWrite(TokenWriter& rTw, const std::string& rLabel = "", const Type* pContext=0) const;
01369 
01370   /**
01371    * Read data from TokenReader.
01372    *
01373    * @param rTr
01374    *  Reference to TokenReader.
01375    * @param rLabel
01376    *  Section to read.
01377    * @param pContext
01378    *    Context information
01379    *
01380    * @exception Exception
01381    *  - Token mismatch
01382    *  - IO Error
01383    */
01384   void DoRead(TokenReader& rTr,  const std::string& rLabel = "", const Type* pContext=0);
01385 
01386  protected:
01387 
01388   /** Variable to store current value. */
01389   SignedIdx mCInteger;
01390 
01391 }; // Integer
01392 
01393 
01394 
01395 // Sum of two integers, uniform rti api 
01396 void IntegerSum(const Integer& arg1, const Integer& arg2, Integer& res); 
01397 
01398 /*
01399 ********************************************************************
01400 ********************************************************************
01401 ********************************************************************
01402 
01403 Elementary type, representing a string value.
01404 
01405 ********************************************************************
01406 ********************************************************************
01407 ********************************************************************
01408 */
01409 
01410 /** Elementary type */
01411 class String : public Type{
01412 
01413  public:
01414   /** Constructor */
01415   String(void);
01416 
01417   /**
01418    * Constructor provided with initial value.
01419    *
01420    * @param val
01421    *  Initial value.
01422    */
01423   String(std::string val);
01424 
01425   /** Destructor */
01426   ~String(void){}
01427 
01428   /**
01429    * Construct on heap.
01430    * Create new String instance and return pointer.
01431    *
01432    * NOTE:
01433    * Calling function takes control.
01434    *
01435    * @return
01436    *  Pointer to String instance.
01437    */
01438   virtual Type* New(void) const;
01439 
01440   /**
01441    * Construct copy on heap.
01442    * Create new String instance and return pointer.
01443    *
01444    * @return
01445    *  Pointer to Integer instance.
01446    *
01447    */
01448   virtual Type* Copy(void) const;
01449 
01450   /**
01451    * Set value.
01452    *
01453    * @param val
01454    *  Value to be set. (std::string)
01455    */
01456   void CValue(std::string val);
01457 
01458   /**
01459    * Get value
01460    *
01461    * @return
01462    *  Value of object. (std::string)
01463    */
01464   std::string CValue(void) const;
01465 
01466   /**
01467    * Get reference.
01468    *
01469    * @return
01470    *  Reference to c value.
01471    */
01472   std::string* CReference(void);
01473 
01474   /**
01475    * Assignment operator.
01476    */
01477   String& operator= (const String& costr){
01478     CValue(costr.CValue());
01479     return(*this);
01480   }
01481 
01482   /*
01483    * Assignment operator, std::string source
01484    */
01485   String& operator= (const std::string& cstr){
01486     CValue(cstr);
01487     return(*this);
01488   }
01489 
01490   /**
01491    * Conversion to std::string
01492    */
01493   operator std::string() const { return CValue();};
01494 
01495 
01496   /**
01497    * Write data to Tokenwriter.
01498    *
01499    * @param rTw
01500    *  Reference to TokenWriter.
01501    * @param rLabel
01502    *  Label of section to write.
01503    * @param pContext
01504    *    Write context to provide contextual information (ignored)
01505    *
01506    * @exception Exception
01507    *  - IO Error
01508    */
01509   void DoWrite(TokenWriter& rTw, const std::string& rLabel = "", const Type* pContext=0) const;
01510 
01511 
01512   /**
01513    * Read data from TokenReader.
01514    *
01515    * @param rTr
01516    *  Reference to TokenReader.
01517    * @param rLabel
01518    *  Section to read.
01519    * @param pContext
01520    *   Read context to provide contextual information (ignored)
01521    *
01522    * @exception Exception
01523    *  - Token mismatch
01524    *  - IO Error
01525    */
01526   void DoRead(TokenReader& rTr,  const std::string& rLabel = "", const Type* pContext=0);
01527 
01528  protected:
01529   /** Variable to store current value. */
01530   std::string mCString;
01531 
01532 }; // String
01533 
01534 
01535 
01536 
01537 /*
01538 ********************************************************************
01539 ********************************************************************
01540 ********************************************************************
01541 
01542 Elementary type, representing a boolean value.
01543 
01544 ********************************************************************
01545 ********************************************************************
01546 ********************************************************************
01547 */
01548 
01549 /** Elementary type */
01550 class Boolean : public Type{
01551 
01552  public:
01553   /** Constructor */
01554   Boolean(void);
01555 
01556   /**
01557    * Constructor provided with initial value.
01558    *
01559    * @param val
01560    *  Initial value. (bool)
01561    */
01562   Boolean(bool val);
01563 
01564   /** Destructor */
01565   ~Boolean(void){}
01566 
01567   /**
01568    * Construct on heap.
01569    * Create new Boolean instance and return pointer.
01570    *
01571    * NOTE:
01572    * Calling function takes control.
01573    *
01574    * @return
01575    *  Pointer to Boolean instance.
01576    */
01577   virtual Type* New(void) const;
01578 
01579   /**
01580    * Construct copy on heap.
01581    * Create new Boolean instance and return pointer.
01582    *
01583    * @return
01584    *  Pointer to Integer instance.
01585    *
01586    */
01587   virtual Type* Copy(void) const;
01588 
01589   /**
01590    * Set value.
01591    *
01592    * @param val
01593    *  Value to be set.
01594    */
01595   void CValue(bool val);
01596 
01597   /**
01598    * Get value.
01599    *
01600    * @return
01601    *  Value of object. (bool)
01602    */
01603   bool CValue(void) const;
01604 
01605   /**
01606    * Get reference.
01607    *
01608    * @return
01609    *  Reference to c value.
01610    */
01611   bool* CReference(void);
01612 
01613   /**
01614    * Assignment operator.
01615    */
01616   Boolean operator= (const bool& bbool){
01617     CValue(bbool);
01618     return(*this);
01619   }
01620 
01621   /**
01622    * Assignment operator.
01623    */
01624   Boolean operator= (const Boolean& cobool){
01625     CValue(cobool.CValue());
01626     return(*this);
01627   }
01628 
01629 
01630   /**
01631    * Conversion to C++ type bool
01632    */
01633   operator bool() const { return CValue();};
01634 
01635   /**
01636    * Write data to Tokenwriter.
01637    *
01638    * NOTE:
01639    * 0 = false
01640    * 1 = true
01641    *
01642    * @param rTw
01643    *  Reference to TokenWriter.
01644    * @param rLabel
01645    *  Label of section to write.
01646    * @param pContext
01647    *    Write context to provide contextual information (ignored)
01648    *
01649    * @exception Exception
01650    *  - IO Error
01651    */
01652   void DoWrite(TokenWriter& rTw, const std::string& rLabel = "", const Type* pContext=0) const;
01653 
01654   /**
01655    * Read data from TokenReader.
01656    *
01657    * NOTE:
01658    * 0 = false
01659    * 1 = true
01660    *
01661    * @param rTr
01662    *  Reference to TokenReader.
01663    * @param rLabel
01664    *  Section to read.
01665    * @param pContext
01666    *   Read context to provide contextual information (ignored)
01667    *
01668    * @exception Exception
01669    *  - Token mismatch
01670    *  - IO Error
01671    */
01672   void DoRead(TokenReader& rTr,  const std::string& rLabel = "", const Type* pContext=0);
01673 
01674  protected:
01675 
01676   /** Variable to store current value. */
01677   bool mCBool;
01678 
01679 }; // Boolean
01680 
01681 
01682 
01683 /**********************************************************************************************
01684 ***********************************************************************************************
01685 ***********************************************************************************************
01686 
01687 Implemention of template members functions
01688 
01689 ***********************************************************************************************
01690 ***********************************************************************************************
01691 **********************************************************************************************/
01692 
01693 
01694 // typedefinition constructor function
01695 template<class T>
01696 TypeDefinition* TypeDefinition::Constructor(const std::string& rTypeName){
01697   FD_DRTI("TypeDefinition::Construct<" << typeid(T).name() << ">()");
01698   return Constructor(new T, rTypeName);
01699 }
01700 
01701 
01702 // type definition constructor function
01703 template<class T>
01704 TypeDefinition* TypeDefinition::FromFile(const std::string& rFileName){
01705   FD_DRTI("TypeDefinition::FromFile<" << typeid(T).name() << ">()");
01706   // construct with fallback name
01707   TypeDefinition* td = Constructor<T>();
01708   // read docu, incl actual name
01709   td->Read(rFileName);
01710   // done
01711   return(td);
01712 }
01713 
01714 
01715 
01716 
01717 
01718 } // namespace
01719 
01720 #endif /* FAUDES_RTITYPES_H */

libFAUDES 2.14g --- 2009-12-3 --- c++ source docu by doxygen 1.5.6