libFAUDES

Sections

Index

cfl_types.h

Go to the documentation of this file.
00001 /** @file cfl_types.h Runtime interface, faudes types */
00002 
00003 /* FAU Discrete Event Systems Library (libfaudes)
00004 
00005 Copyright (C) 2009 Ruediger Berndt
00006 Copyright (C) 2010 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 "cfl_definitions.h"
00037 #include "cfl_token.h"
00038 #include "cfl_tokenreader.h"
00039 #include "cfl_tokenwriter.h"
00040 #include "cfl_exception.h"
00041 
00042 
00043 
00044 namespace faudes {
00045 
00046 
00047 /************************************************
00048  ************************************************
00049  ************************************************/
00050 
00051 
00052 /** @defgroup RunTimeInterface  Run-Time Interface
00053 
00054 The libFAUDES run-time interface (RTI) facilitates the development 
00055 of applications that are transparent to libFAUDES extensions, e.g.
00056 the libFAUDES version of the Lua interpreter luafaudes and the 
00057 graphical user interface  DESTool.
00058 
00059 The run-time interface  provides a TypeRegistry for the application 
00060 to instantiate objects by specifying their type as a std::string. 
00061 The TypeRegistry is accompanied by the FunctionRegistry for 
00062 the application to execute functions by their name. Thus, a libFAUDES
00063 application can query both registries and provide the 
00064 supported types and functions to the user. 
00065 The <a href="../registry/index.html">libFAUDES user-reference</a> 
00066 is set up by the build system to represent the contents of both
00067 registries.
00068 
00069 The run-time interface is implemented
00070 by the following components:
00071 - base class faudes::Type for RTI enabled classes (faudes-types)
00072 - documentation class faudes::TypeDefinition to accompany faudes-types;
00073 - container class faudes::TypeRegistry to hold faudes::TypeDefintiion objects;
00074 - base class faudes::Function for RTI enabled function wrappers (faudes-functions);
00075 - documentation class faudes::FunctionDefinition to accompany faudes-functions;
00076 - container class faudes::FunctionRegistry to hold FunctionDefintiion objects.
00077 
00078 @section RunTimeInterfaceSec2 Faudes-Types
00079 
00080 Classes that participate in the run-time interface are referred to
00081 as faudes-types, instances are so called faudes-objects. Any faudes-type must
00082 be derived from the base class faudes::Type. A faudes-type inherits
00083 the convenience interface for token io from Type, and, most relevent for the run-time 
00084 interface, the factory function New(): each faudes-types must reimplement New() 
00085 to allocate a new object of their respective type on heap. For a fully functional
00086 faudes-type, also an appropriate assignment operator and a copy constructor
00087 are required.
00088 
00089 
00090 @section RunTimeInterfaceSec3 Faudes-Type Definitions
00091 
00092 A faudes-type is accompanied by an instance of faudes::TypeDefinition. It holds
00093 a name (std::string) to identify the faudes-type,
00094 documentation (short text and html reference), 
00095 and one faudes-object of the respective faudes-type.
00096 The latter is referred to as the prototype object and its New() method is used to construct 
00097 new faudes-objects of the respective faudes-type. Thus, given a TypeDefinition,
00098 one can instantiate a corresponding faudes-object. To setup a
00099 TypeDefinition, you are meant to provide the faudes-type name, the protototype
00100 and a file from which to read the documentation.
00101 
00102 
00103 @section RunTimeInterfaceSec4 Faudes-Functions and Faudes-Function Definitions
00104 
00105 Functions that participate in the run-time interface are organized similar
00106 to faudes-types. There is a base class faudes::Function from which to derive 
00107 particular faudes-functions. The base class provides an interface to set
00108 function parameter values and to actually  execute the function on the parameters. 
00109 To derive a class from Function, you must reimplement the methods New(), DoTypeCheck(), 
00110 and DoExecute(). The DoTypeCheck method is supposed to use a dynamic cast
00111 to initialize typed references to the function parameters. The DoExecute method
00112 then executes the function, typically by invoking a function via its
00113 C++ API. Each Function class is accompanied by a faudes::FunctionDefinition instance
00114 which holds a prototype, basic documentation and a list of valid signatures. Each signature
00115 represents a valid parameter type configurations in terms of faudes-types. 
00116 
00117 @section RunTimeInterfaceSec5 Type- and Function-Registry 
00118 
00119 The faudes::TypeRegistry and the faudes::FunctionRegistry are containers for TypeDefinition
00120 and FunctionDefinition instances, respectively. Applications access the registries via
00121 faudes-type names and faudes-function names, see e.g. the global functions NewObject() and
00122 NewFunction(). There is also in interface to iterate through the regsitries and
00123 to test for the existence of an entry. However, while both registries inherit the std token-io
00124 interface, neither registry can be fully configured by reading from file. This is because
00125 each entry requires not only data (documentation, signature, etc) but also a prototype
00126 instance. The std C++ run-time type information (RTTI) does not provide a mechanism
00127 to instantiate an object of a class that is specified at runtime. Thus, each protototype
00128 must be defined at compiletime. The global function LoadRegistry() is automatically
00129 set-up by the build system to gather all relevant prototypes, insert them in the 
00130 registries and to subsequently read further documentation from a configuration 
00131 file.
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-functions 
00140   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 "libfaudes.rti" 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 public default constructor and a public copy constructor;
00151 -# use the provided macros to reimplement the virtual functions New(), Copy(), Cast(), Assign(),
00152    Equal(), and the acording operators =, == and !=;
00153 -# reimplement the virtual functions DoAssign(), DoEqual(), DoRead(), DoWrite() and Clear();
00154 -# optionally, reimplement the alternative output formats DoDWrite(), DoSWrite(),
00155  # provide an .rti file for the formal TypeDefinition; 
00156 -# supplement your .rti file by an html formated documentation text;  
00157  
00158 You will need to inspect and edit the main Makefile or your plugin's Makefile
00159 to advertise your additional sources. A <tt>make configure</tt> will then
00160 assemble all the bits and pieces.
00161 
00162 To have your C++ function participate in the libFAUDES run-time interface:
00163 
00164 -# Make sure all your parameters are faudes-types;
00165 -# Provide an .rti file for the formal FunctionDefinition, advertise this file;
00166    either in the main Makefile or in the Makefile of your plugin;
00167 -# supplement yout .rti file by an html formated documentation text;  
00168 
00169 
00170 */
00171 
00172 /**
00173  * Base class of all libFAUDES objects that participate in
00174  * the run.time interface. Eg, generator, alphabet, attributes etc.
00175  * The class is designed to impose as little overhead as possible, and
00176  * hence, does not hold any data. It does, however, provide a
00177  * uniform interface for assignment, factory functions, and token IO.
00178  *
00179  * We think of a faudes-typed object to be configured by defining
00180  * data and, in due course, manipulated via its public interface 
00181  * by faudes-functions. Any faudes-type must provide a Clear() method that
00182  * resets the object configuration to a unique default value.
00183  * It is the configuration data that can be read from and written to token
00184  * streams, and it is the configuration data that is used for assigments.
00185  * Any additional data a faudes-typed object may host, is ignored by the
00186  * interface provided inherited from the the base faudes::Type. Examples for such
00187  * additional data is the unique id of a Generator, and the deferred copy
00188  * pointers in faudes sets derived from faudes::TBaseSet.
00189  *
00190  * The faudes::Type assignment semantics are not meant to create exact copies
00191  * of a given source object. Thogether with the uniquely defined default value,
00192  * we can have assignments by both up- and downcasts. A faudes::Generator can be
00193  * assigned from the derived faudes::System (a Generator with controllability 
00194  * attributes) by dropping the extra features. Vice versa, when a System is assigned
00195  * from a plain Generator, any extra features take their respective default values.
00196  * This relaxed interpretation of assignments is implemented by the method
00197  * Assign().  The token format for file IO is organised in a similar fashion: any generator 
00198  * derivate can be configured from the token stream produced by any other generator class. 
00199  * In contrast, faudes-typed objects also implement an assignment operator
00200  * that uses the standard C++ conventions.
00201  *
00202  * The follwoing methods are used to implement the faudes::Type interface:
00203  * 
00204  * - DoRead() to read the defining data from a token stream
00205  * - DoWrite() to write the defining data to a token stream
00206  * - DoSWrite() and DoDWrite for alternative output formats (statistical summary and debugging)
00207  *
00208  * - Clear() to reset all configuration data,
00209  * - Name() to get/set the name of an optional (and purely cosmetic) object name
00210  * - New() to construct an object of identical type on heap (factory method),
00211  * - Copy() to construct an object of identical type and configuration on heap (factory method),
00212  * - Cast() to dynamically cast another object to this type (type check method)
00213  * - Assign() to do an assignment from any castable Type derivate
00214  * - DoAssign(), or the operator "=", to assign from an object with identical type.
00215  * - Equal() to test relaxed equality with any castable Type derivate
00216  * - DoEqual(), or the operators "==" and "!=", to test exact equality of configuration data
00217  * 
00218  * In most cases, only DoRead(), DoWrite(), DoAssign() and DoEqual() need to me implemented
00219  * manualy. the other methods can be declared and implemented by macros
00220  * FAUDES_TYPE_DELARATION and FAUDES_TYPE_IMPLEMENTATION, respectively. The various
00221  * Attribute classes illustrate their ussage.
00222  *
00223  * @ingroup RunTimeInterface
00224  */
00225    
00226 class Type {
00227 
00228  public:
00229 
00230   /** Constructor */
00231   Type(void);
00232 
00233   /** Copy constructor */
00234   Type(const Type& rType);
00235 
00236   /** Destructor */
00237   virtual ~Type(void);
00238 
00239   /**
00240    * Construct on heap. 
00241    * Technically not a constructor, this function creates an object with the
00242    * same type Type. New() is defined as a virtual function and derived
00243    * classes are meant to re-implement with the appropiate constructor.
00244    * This can be done via the provided macros FAUDES_TYPE_DECLARATION and
00245    * FAUDES_TYPE_IMPLEMENTATION.
00246    * As with new, it is the callers reponsabilty to delete the object when no longer needed.
00247    *
00248    * @return 
00249    *   Pointer to new Type object
00250    */
00251   virtual Type* New(void) const;
00252 
00253   /**
00254    * Construct on heap. 
00255    * Technically not a constructor, this function creates an object with the
00256    * same type Type and the same configuration. Copy() is defined as a virtual function and derived
00257    * classes are meant to re-implement with the appropiate copy constructor.
00258    * This can be done via the provided macros FAUDES_TYPE_DECLARATION and
00259    * FAUDES_TYPE_IMPLEMENTATION.
00260    * As with new, it is the callers reponsabilty to delete the object when no longer needed.
00261    *
00262    * @return 
00263    *   Pointer to new Type object
00264    */
00265   virtual Type* Copy(void) const;
00266 
00267   /**
00268    * Cast other object to this type.
00269    * Enables the run-time interface to test whether pObject is derived
00270    * from this object. This feature is used e.g. in the faudes container
00271    * classes to test attributes. Derived classes must reimplement this
00272    * function using the appropriate dynamic cast.
00273    *
00274    * Re-implementation can be done via the convenience macros
00275    * FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.
00276    *
00277    * @return 
00278    *   Typed pointer object
00279    */
00280   virtual const Type* Cast(const Type* pOther) const;
00281 
00282   /**
00283    * Clear configuration data.  Derived classes should re-implement this
00284    * method to ensure some consistent configuration data.
00285    */
00286   virtual void Clear(void);
00287 
00288   /**
00289    * Assign configuration data from other object. 
00290    * Derived classes should reimplement this method to first try to cast
00291    * the source to the respective class. If successful, the protected 
00292    * function DoAssign is invoked to perform the actual assignment. If the cast fails,
00293    * the Assign method of the parent class is called. Thus, faudes
00294    * objects are up- and downcatsed for assignment, maintaining as much of
00295    * the source data as digestable by the destination object. On the downside,
00296    * there is no sensible typechecking at compile-time.
00297    *
00298    * Re-implementation can be done via the convenience macros
00299    * FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.
00300    * 
00301    * @param rSrc 
00302    *    Source to copy from
00303    * @return Reference to this object.
00304    */
00305   virtual Type& Assign(const Type& rSrc);
00306 
00307 
00308   /**
00309    * Assign configurationdata from other object. 
00310    * Derived classes should implement the operator form for the assignment
00311    * for each source type which allows for a non-trivial assignment. This includes
00312    * the particular case were the source and destination types match exactly. In the
00313    * latter case the DoAssign method should be invoked. In contrast to
00314    * the Assign function, the operator form must not be reimplemented for
00315    * missmatched source types: the operator form only accepts sensible source types.
00316    * This allows for compiletime typeckecking. However, the downside is that
00317    * when the type is not known at compiletime, configuration is not properly
00318    * assigned.
00319    *
00320    * Re-implementation can be done via the convenience macros
00321    * FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.
00322    * 
00323    * @param rSrc 
00324    *    Source to copy from
00325    * @return Reference to this object.
00326    */
00327   virtual Type& operator=(const Type& rSrc);
00328 
00329   /**
00330    * Test equality of configuration data.
00331    * Derived classes should reimplement this method to return true
00332    * if both actual types and configuration data match.
00333    * The object name or id  (if any) is not considered in the test.
00334    *
00335    * This method calls the virtual method DoEqual(). Re-implementation can 
00336    * be done via the convenience macros
00337    * FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.
00338    * 
00339    * @param rOther 
00340    *    Other object to compare with.
00341    * @return 
00342    *   True on match.
00343    */
00344   virtual bool Equal(const Type& rOther) const;
00345 
00346   /**
00347    * Test equality of configuration data.
00348    * The operator form of the equality test is only defined for matching
00349    * types, no cast will be performed. Thus, the test will be optimistic
00350    * if the type is not known at compiletime.
00351    * The object name or id  is not considered in the test.
00352    *
00353    * This methoc calls the virtual method DoEqual(). Re-implementation can 
00354    * be done via the convenience macros
00355    * FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.
00356    * 
00357    * @param rOther 
00358    *    Other object to compare with.
00359    * @return 
00360    *   True on match.
00361    */
00362   virtual bool operator==(const Type& rOther) const;
00363 
00364 
00365   /**
00366    * Test equality of configuration data.
00367    * See operator==(const Type&).
00368    *
00369    * This method calls the virtual method DoEqual(). Re-implementation can 
00370    * be done via the convenience macros
00371    * FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.
00372    * 
00373    * @param rOther 
00374    *    Other objevt to compare with.
00375    * @return 
00376    *   True on mismatch.
00377    */
00378   virtual bool operator!=(const Type& rOther) const;
00379 
00380 
00381   /** 
00382    * Set the objects's name.
00383    *
00384    * The base class Type does not implement an object name,
00385    * derivatives usually do so, except for attributes. 
00386    *
00387    * @param rName
00388    *   Name
00389    */
00390   virtual void Name(const std::string& rName);
00391 
00392   /** 
00393    * Get objects's name 
00394    *
00395    * The base class Type does not implement an object name,
00396    * derivatives usually do so, except for attributes. 
00397    * @return 
00398    *   Name of generator
00399    */
00400   virtual const std::string& Name(void) const;
00401 
00402 
00403   /**
00404    * Write configuration data to console.
00405    * Note: this write function uses the virtual function DoWrite(), to be 
00406    * reimplemented by derived classes.
00407    *
00408    * @param pContext
00409    *   Write context to provide contextual information
00410    *
00411    */
00412   void Write(const Type* pContext=0) const;
00413 
00414   /**
00415    * Write configuration data to a file. 
00416    * Note: this write function uses the virtual function DoWrite(), to be 
00417    * reimplemented by derived classes.
00418    *
00419    * @param pFileName
00420    *   Name of file
00421    * @param rLabel
00422    *   Label of section to write
00423    * @param pContext
00424    *   Write context to provide contextual information
00425    * @param openmode
00426    *   ios::openmode 
00427    *
00428    * @exception Exception
00429    *   - IO errors (id 2)
00430    */
00431   void Write(const std::string& pFileName, const std::string& rLabel="",
00432        const Type* pContext=0, std::ios::openmode openmode = std::ios::out|std::ios::trunc) const;
00433 
00434   /**
00435    * Write configuration data to a file. 
00436    * Note: this write function uses the virtual function DoWrite(), to be 
00437    * reimplemented by derived classes.
00438    *
00439    * @param pFileName
00440    *   Name of file
00441    * @param openmode
00442    *   ios::openmode 
00443    *
00444    * @exception Exception
00445    *   - IO errors (id 2)
00446    */
00447   void Write(const std::string& pFileName, std::ios::openmode openmode) const;
00448 
00449   /**
00450    * Write configuration data to TokenWriter.
00451    * Note: this write function uses the virtual function DoWrite(), to be 
00452    * reimplemented by derived classes.
00453    *
00454    * @param rTw
00455    *   Reference to TokenWriter
00456    * @param rLabel
00457    *   Label of section to write
00458    * @param pContext
00459    *   Write context to provide contextual information
00460    *
00461    * @exception Exception 
00462    *   - IO errors (id 2)
00463    */
00464   void Write(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const;
00465 
00466   /**
00467    * Write configuration data to a string.
00468    * Note: this write function uses the virtual function DoWrite(), to be 
00469    * reimplemented by derived classes.
00470    *
00471    * @param rLabel
00472    *   Label of section to write
00473    * @param pContext
00474    *   Write context to provide contextual information
00475    * @return
00476    *   output string
00477    * @exception Exception
00478    *   - IO errors (id 2)
00479    */
00480   std::string ToString(const std::string& rLabel="", const Type* pContext=0) const;
00481 
00482   /**
00483    * Write configuration data to a formated string.
00484    * In contrast to ToString, ToText does not suppress comments and
00485    * End-Of-Line marks. 
00486    * Note: this write function uses the virtual function DoWrite(), to be 
00487    * reimplemented by derived classes.
00488    *
00489    * @param rLabel
00490    *   Label of section to write
00491    * @param pContext
00492    *   Write context to provide contextual information
00493    * @return
00494    *   output string
00495    * @exception Exception
00496    *   - IO errors (id 2)
00497    */
00498   std::string ToText(const std::string& rLabel="", const Type* pContext=0) const;
00499 
00500   /**
00501    * Write configuration data to console, debugging format.
00502    * Note: this write function uses the virtual function DoDWrite(), to be 
00503    * reimplemented by derived classes.
00504    *
00505    * @param pContext
00506    *   Write context to provide contextual information
00507    *
00508    */
00509   void DWrite(const Type* pContext=0) const;
00510 
00511   /**
00512    * Write configuration data to a file, debugging format. 
00513    * Note: this write function uses the virtual function DoDWrite(), to be 
00514    * reimplemented by derived classes.
00515    *
00516    * @param pFileName
00517    *   Name of file
00518    * @param rLabel
00519    *   Label of section to write
00520    * @param pContext
00521    *   Write context to provide contextual information
00522    * @param openmode
00523    *   ios::openmode 
00524    *
00525    * @exception Exception
00526    *   - IO errors (id 2)
00527    */
00528   void DWrite(const std::string& pFileName, const std::string& rLabel="",
00529         const Type* pContext=0, std::ios::openmode openmode = std::ios::out|std::ios::trunc) const;
00530 
00531   /**
00532    * Write configuration data in debug format to TokenWriter.
00533    * Note: this write function uses the virtual function DoWrite(), to be 
00534    * reimplemented by derived classes.
00535    *
00536    * @param rTw
00537    *   Reference to TokenWriter
00538    * @param rLabel
00539    *   Label of section to write
00540    * @param pContext
00541    *   Write context to provide contextual information
00542    *
00543    * @exception Exception 
00544    *   - IO errors (id 2)
00545    */
00546   void DWrite(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const;
00547 
00548   /**
00549    * Write statistics comment to TokenWriter.
00550    * Note: this write function use the virtual function DoSWrite(), to be 
00551    * reimplemented by derived classes.
00552    *
00553    * @param rTw
00554    *   Reference to TokenWriter
00555    *
00556    * @exception Exception 
00557    *   - IO errors (id 2)
00558    */
00559   void SWrite(TokenWriter& rTw) const;
00560 
00561   /**
00562    * Write statistics comment to console.
00563    * Note: this write function uses the virtual function DoSWrite(), to be 
00564    * reimplemented by derived classes.
00565    *
00566    */
00567   void SWrite(void) const;
00568 
00569   /**
00570    * Write statistics to a string.
00571    * Note: this write function uses the virtual function DoSWrite(), to be 
00572    * reimplemented by derived classes.
00573    *
00574    * @return
00575    *   output string
00576    * @exception Exception
00577    *   - IO errors (id 2)
00578    */
00579   std::string ToSText(void) const;
00580 
00581   /**
00582    * Read configuration data from file with label specified.
00583    * Note: all read functions use the virtual function DoRead(), to be 
00584    * reimplemented for by derived classes.
00585    *
00586    * @param rFileName
00587    *   Name of file
00588    * @param rLabel
00589    *   Section to read from 
00590    * @param pContext
00591    *   Read context to provide contextual information
00592    *
00593    * @exception Exception
00594    *   - IO errors (id 1)
00595    *   - token mismatch from DoRead()
00596    */
00597   void Read(const std::string& rFileName, const std::string& rLabel = "", const Type* pContext=0);
00598 
00599   /**
00600    * Write configuration data to a string.
00601    * Note: this write function uses the virtual function DoWrite(), to be 
00602    * reimplemented by derived classes.
00603    *
00604    * @param rString
00605    *   String to read from
00606    * @param rLabel
00607    *   Section to read
00608    * @param pContext
00609    *   Read context to provide contextual information
00610    * @exception Exception
00611    *   - IO errors (id 1)
00612    *   - token mismatch from DoRead()
00613    */
00614   void FromString(const std::string& rString, const std::string& rLabel="", const Type* pContext=0);
00615 
00616   /**
00617    * Read configuration data from TokenReader with label sepcified.
00618    * Note: all read functions use the virtual function DoRead(), to be 
00619    * reimplemented for by derived classes.
00620    *
00621    * @param rTr
00622    *   Reference to tokenreader
00623    * @param rLabel
00624    *   Section to read
00625    * @param pContext
00626    *   Read context to provide contextual information
00627    *
00628    * @exception Exception
00629    *   - IO errors (id 1)
00630    *   - token mismatch from DoRead()
00631    */
00632   void Read(TokenReader& rTr, const std::string& rLabel = "", const Type* pContext=0);
00633 
00634 
00635  protected:
00636 
00637   /**
00638    * Assign configuration data from other object. 
00639    *
00640    * Reimplement this function to copy all configuration data from
00641    * another faudes object. Typically, you will first call the base class'
00642    * DoAssign, which includes a Clear(). Then, you will set up any additional members.
00643    *
00644    * @param rSrc 
00645    *    Source to copy from
00646    * @return Reference to this object.
00647    */
00648   virtual Type& DoAssign(const Type& rSrc);
00649 
00650   /**
00651    * Test equality of configuration data.
00652    * Derived classes should reimplement this method to compare all relevant 
00653    * configuration, except the name.
00654    * 
00655    * @param rOther 
00656    *    Other object to compare with.
00657    * @return 
00658    *   True on match.
00659    */
00660   virtual bool DoEqual(const Type& rOther) const;
00661 
00662 
00663   /**
00664    * Read configuration data of this object from TokenReader.
00665    *
00666    * Reimplement this method in derived classes to provide the std token io
00667    * interface defined in the public section of Type.
00668    *
00669    * @param rTr
00670    *   TokenReader to read from
00671    * @param rLabel
00672    *   Section to read
00673    * @param pContext
00674    *   Read context to provide contextual information
00675    *
00676    * @exception Exception
00677    *   - IO error (id 1)
00678    */
00679   virtual void DoRead(TokenReader& rTr,  const std::string& rLabel = "", const Type* pContext=0);
00680  
00681   /**
00682    * Write configuration data of this object to TokenWriter.
00683    *
00684    * Reimplement this method in derived classes to provide the std token io
00685    * interface defined in the public section of Type.
00686    *
00687    * @param rTw
00688    *   Reference to TokenWriter
00689    * @param rLabel
00690    *   Label of section to write
00691    * @param pContext
00692    *   Write context to provide contextual information
00693    *
00694    * @exception Exception 
00695    *   - IO errors (id 2)
00696    */
00697   virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const;
00698 
00699   /**
00700    * Write configuration data in debugging format to TokenWriter.
00701    *
00702    * Reimplement this method in derived classes to provide the std token io
00703    * interface defined in the public section of Type.
00704    *
00705    * @param rTw
00706    *   Reference to TokenWriter
00707    * @param rLabel
00708    *   Label of section to write
00709    * @param pContext
00710    *   Write context to provide contextual information
00711    *
00712    * @exception Exception 
00713    *   - IO errors (id 2)
00714    */
00715   virtual void DoDWrite(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const;
00716 
00717   /**
00718    * Write statistical data as a comment to TokenWriter.
00719    *
00720    * Reimplement this method in derived classes to provide the std token io
00721    * interface defined in the public section of Type.
00722    *
00723    * @param rTw
00724    *   Reference to TokenWriter
00725    *
00726    * @exception Exception 
00727    *   - IO errors (id 2)
00728    */
00729   virtual void DoSWrite(TokenWriter& rTw) const;
00730 
00731   /** static default name */
00732   const static std::string mName;
00733 
00734 };
00735 
00736 
00737 
00738 
00739 /** faudes type declaration macro */
00740 #define FAUDES_TYPE_DECLARATION(ftype,fbase)    \
00741   public: \
00742   virtual ftype* New(void) const; \
00743   virtual ftype* Copy(void) const; \
00744   virtual const ftype* Cast(const Type* pOther) const; \
00745   virtual ftype& Assign(const Type& rSrc); \
00746   virtual bool Equal(const Type& rOther) const; \
00747   virtual ftype& operator=(const ftype& rSrc); \
00748   virtual bool operator==(const ftype& rOther) const; \
00749   virtual bool operator!=(const ftype& rOther) const;
00750 
00751 /** faudes type implementation macros, individual */
00752 #define FAUDES_TYPE_IMPLEMENTATION_NEW(ftype,fbase) \
00753   ftype* ftype::New(void) const {     \
00754     return new ftype(); } 
00755 #define FAUDES_TYPE_IMPLEMENTATION_COPY(ftype,fbase)  \
00756   ftype* ftype::Copy(void) const {      \
00757     return new ftype(*this); } 
00758 #define FAUDES_TYPE_IMPLEMENTATION_CAST(ftype,fbase)  \
00759   const ftype* ftype::Cast(const Type* pOther) const { \
00760     return dynamic_cast<const ftype*>(pOther);} 
00761 #define FAUDES_TYPE_IMPLEMENTATION_ASSIGN(ftype,fbase)  \
00762   ftype& ftype::Assign(const Type& rSrc) { \
00763     if(const ftype* csattr=dynamic_cast<const ftype*>(&rSrc)) { \
00764       this->Clear(); return DoAssign(*csattr);} \
00765     fbase::Assign(rSrc); \
00766     return *this;} \
00767   ftype& ftype::operator=(const ftype& rSrc) { this->Clear(); return DoAssign(rSrc); }
00768 #define FAUDES_TYPE_IMPLEMENTATION_EQUAL(ftype,fbase) \
00769   bool ftype::Equal(const Type& rOther) const { \
00770     if(&rOther==this) return true; \
00771     if(typeid(rOther) != typeid(*this)) return false; \
00772     const ftype* csattr=dynamic_cast<const ftype*>(&rOther); \
00773     if(!csattr) return false; \
00774     if(!DoEqual(*csattr)) return false;   \
00775     return true;} \
00776     bool ftype::operator==(const ftype& rOther) const { return DoEqual(rOther); } \
00777     bool ftype::operator!=(const ftype& rOther) const { return !DoEqual(rOther); }
00778 
00779 
00780 /** faudes type implementation macros, overall */
00781 #define FAUDES_TYPE_IMPLEMENTATION(ftype,fbase) \
00782   ftype* ftype::New(void) const {     \
00783     return new ftype(); }  \
00784   ftype* ftype::Copy(void) const {      \
00785     return new ftype(*this); }      \
00786   const ftype* ftype::Cast(const Type* pOther) const { \
00787     return dynamic_cast<const ftype*>(pOther);} \
00788   ftype& ftype::Assign(const Type& rSrc) { \
00789     if(const ftype* csattr=dynamic_cast<const ftype*>(&rSrc)) \
00790        { this->Clear(); return DoAssign(*csattr);} \
00791     fbase::Assign(rSrc); \
00792     return *this;} \
00793   ftype& ftype::operator=(const ftype& rSrc) { this->Clear(); return DoAssign(rSrc); } \
00794   bool ftype::Equal(const Type& rOther) const { \
00795     if(&rOther==this) return true; \
00796     if(typeid(rOther) != typeid(*this)) return false; \
00797     const ftype* csattr=dynamic_cast<const ftype*>(&rOther);  \
00798     if(!csattr) return false; \
00799     if(!DoEqual(*csattr)) return false;   \
00800     return true;} \
00801   bool ftype::operator==(const ftype& rOther) const { return DoEqual(rOther); } \
00802   bool ftype::operator!=(const ftype& rOther) const { return !DoEqual(rOther); }
00803 
00804 
00805 /** faudes type implementation macros, individual, template version */
00806 #define FAUDES_TYPE_TIMPLEMENTATION_NEW(ftype,fbase,ftemp)  \
00807   ftemp ftype* ftype::New(void) const {     \
00808     return new ftype(); } 
00809 #define FAUDES_TYPE_TIMPLEMENTATION_COPY(ftype,fbase,ftemp) \
00810   ftemp ftype* ftype::Copy(void) const {      \
00811     return new ftype(*this); } 
00812 #define FAUDES_TYPE_TIMPLEMENTATION_CAST(ftype,fbase,ftemp) \
00813   ftemp const ftype* ftype::Cast(const Type* pOther) const { \
00814     return dynamic_cast<const ftype*>(pOther);} 
00815 #define FAUDES_TYPE_TIMPLEMENTATION_ASSIGN(ftype,fbase,ftemp) \
00816   ftemp ftype& ftype::Assign(const Type& rSrc) { \
00817     if(const ftype* csattr=dynamic_cast<const ftype*>(&rSrc)) { \
00818       this->Clear(); return DoAssign(*csattr);} \
00819     fbase::Assign(rSrc); \
00820     return *this;} \
00821   ftemp ftype& ftype::operator=(const ftype& rSrc) { this->Clear(); return DoAssign(rSrc); }
00822 #define FAUDES_TYPE_TIMPLEMENTATION_EQUAL(ftype,fbase,ftemp)  \
00823   ftemp bool ftype::Equal(const Type& rOther) const { \
00824     if(&rOther==this) return true; \
00825     if(typeid(rOther) != typeid(*this)) return false; \
00826     const ftype* csattr=dynamic_cast<const ftype*>(&rOther); \
00827     if(!csattr) return false; \
00828     if(!DoEqual(*csattr)) return false;   \
00829     return true;} \
00830     ftemp bool ftype::operator==(const ftype& rOther) const { return DoEqual(rOther); } \
00831     ftemp bool ftype::operator!=(const ftype& rOther) const { return !DoEqual(rOther); }
00832 
00833 
00834 /** faudes type implementation macros, overall, template version */
00835 #define FAUDES_TYPE_TIMPLEMENTATION(ftype,fbase,ftemp)  \
00836   ftemp ftype* ftype::New(void) const {     \
00837     return new ftype(); }  \
00838   ftemp ftype* ftype::Copy(void) const {      \
00839     return new ftype(*this); }  \
00840   ftemp const ftype* ftype::Cast(const Type* pOther) const { \
00841     return dynamic_cast<const ftype*>(pOther);} \
00842   ftemp ftype& ftype::Assign(const Type& rSrc) { \
00843     if(const ftype* csattr=dynamic_cast<const ftype*>(&rSrc)) \
00844        { this->Clear(); return DoAssign(*csattr);} \
00845     fbase::Assign(rSrc); \
00846     return *this;} \
00847   ftemp ftype& ftype::operator=(const ftype& rSrc) { this->Clear(); return DoAssign(rSrc); } \
00848   ftemp bool ftype::Equal(const Type& rOther) const { \
00849     if(&rOther==this) return true; \
00850     if(typeid(rOther) != typeid(*this)) return false; \
00851     const ftype* csattr=dynamic_cast<const ftype*>(&rOther);  \
00852     if(!csattr) return false; \
00853     if(!DoEqual(*csattr)) return false;   \
00854     return true;} \
00855   ftemp bool ftype::operator==(const ftype& rOther) const { return DoEqual(rOther); } \
00856   ftemp bool ftype::operator!=(const ftype& rOther) const { return !DoEqual(rOther); }
00857 
00858 
00859 /** faudes type implementation macros, overall, debug version */
00860 /*
00861 #define FAUDES_TYPE_IMPLEMENTATION(ftype,fbase,ftemp) \
00862   ftemp ftype* ftype::New(void) const {     \
00863     return new ftype(); }  \
00864   ftemp const ftype* ftype::Cast(const Type* pOther) const { \
00865     return dynamic_cast<const ftype*>(pOther);} \
00866   ftemp ftype& ftype::Assign(const Type& rSrc) { \
00867     FD_WARN("RTI "<< typeid(ftype).name() << "::ASSIGN() V: " << typeid(*this).name() << \
00868       " from " << typeid(rSrc).name()); \
00869     if(const ftype* csattr=dynamic_cast<const ftype*>(&rSrc)) { this->Clear(); return DoAssign(*csattr);} \
00870     fbase::Assign(rSrc); \
00871     return *this;} \
00872   ftemp ftype& ftype::operator=(const ftype& rSrc) { \
00873     FD_WARN("RTI "<< typeid(ftype).name() << "::ASSIGN() O: " << typeid(*this).name() << \
00874       " from " << typeid(rSrc).name()); \
00875     this->Clear(); \
00876     return DoAssign(rSrc); }
00877 */
00878 
00879 
00880 
00881 /**
00882  * Structure to hold documentation data relating to a faudes-type or -function. 
00883  * This class is the common base for faudes::TypeDefinition and faudes::FunctionDefinition. 
00884  * It supports token io as demonstrated by the follwoing example for a type defintion:
00885  *
00886  * @code
00887  *  <TypeDefinition>
00888  *      % name of this faudes-type, incl. colon separated plugin name
00889  *  "CoreFaudes::Generator"
00890  *
00891  *      % corresponding C++ type (optional)
00892  *      +faudes::cGenerator+
00893  *
00894  *      % short docu
00895  *  <TextDoc> "The common 5 tuple G=(Sigma, Q, delta, Qo, Qm)."
00896  *
00897  *      % html reference for documentation
00898  *  <HtmlDoc> "generators.html#plain" </HtmlDoc>
00899  *
00900  *      % relevant keywords 
00901  *  <Keywords> "generator" "language" </Keywords>
00902  *
00903  *  </TypeDefinition>
00904  * @endcode
00905  *
00906  * Technical detail: Documentation is derived from Type for the purpose of token IO. We
00907  * still implement the faudes type interface to make it a fully qualified faudes data type.
00908  *
00909  * Technical detail: To facilitate inheritance, token io of member data and token io of
00910  * the section tags is separated.
00911  */
00912 
00913 class Documentation : public Type {
00914 
00915   // std faudes type interface
00916   FAUDES_TYPE_DECLARATION(Documentation,Type)
00917   
00918 public:
00919   /** Constructor */
00920   Documentation(void);
00921 
00922   /** Copy constructor */
00923   Documentation(const Documentation& rOther);
00924 
00925   /** Destructor */
00926   virtual ~Documentation(void){};
00927 
00928   /**
00929    * Clear 
00930    */
00931   void Clear(void);
00932 
00933   /**
00934    * Get name of the entety to document (aka faudes-type or faudes-function).
00935    *
00936    * @return
00937    *  Name
00938    */
00939   const std::string& Name(void) const;
00940 
00941   /**
00942    * Get name of plugin.
00943    * The plugin name defaults to CoreFaudes.
00944    *
00945    * @return
00946    *  Name
00947    */
00948   const std::string& PlugIn(void) const;
00949 
00950   /**
00951    * Get corresponding C++ type
00952    *
00953    * @return
00954    *  CType, or "" if no such
00955    */
00956   const std::string& CType(void) const;
00957 
00958   /**
00959    * @return
00960    *  Short textual documentation.
00961    */
00962   const std::string& TextDoc(void) const;
00963 
00964   /**
00965    * @return
00966    *  Filename pointing to the html documentation.
00967    */
00968   const std::string& HtmlDoc(void) const;
00969 
00970   /**
00971    * @return
00972    *  CSV-string containing keywords.
00973    */
00974   const std::string& Keywords(void) const;
00975 
00976   /**
00977    * Search comma-seperated keywords for a substring. This should be
00978    * extended to regular expressions in a future release.
00979    *
00980    * @param rPattern
00981    *  String-pattern.
00982    *
00983    * @return
00984    *  Matching keyword or "" if no match
00985    */
00986   std::string MatchKeyword(const std::string& rPattern) const;
00987 
00988   /**
00989    * Not implemented
00990    * @return
00991    *  Number of keywords.
00992    */
00993   int KeywordsSize(void) const;
00994 
00995   /**
00996    * @param pos
00997    *   Position of keyword
00998    * @return
00999    *  Keyword at specified position (or "" if pos out of range)
01000    */
01001   std::string KeywordAt(int pos) const;
01002 
01003   /**
01004    * Merge documentation and from token stream.
01005    * This member reads the body of a Documentation from token format
01006    * and sets the documentation accordingly. An exception is
01007    * thrown if the current type name differs from the one in the documentation.
01008    *
01009    * @param rTr
01010    *  TokenReader to read from.
01011    *
01012    * @exception Exception
01013    *  - Type mismatch (id )
01014    *  - Token mismatch (id 50, 51, 52)
01015    *  - IO Error (id 1)
01016    */
01017   virtual void MergeDocumentationBody(TokenReader& rTr);
01018 
01019 
01020 
01021  protected:
01022 
01023   /**
01024    * Set name.
01025    *
01026    * @param name
01027    *  New name.
01028    */
01029   void Name(const std::string& name);
01030 
01031   /**
01032    * Set name of plugin
01033    *
01034    * @param plugin
01035    *  New name.
01036    */
01037   void PlugIn(const std::string& plugin);
01038 
01039   /**
01040    * Set C++ type
01041    *
01042    * @param name
01043    *  New ctype.
01044    */
01045   void CType(const std::string& name);
01046 
01047   /**
01048    * Set a short textual documentation.
01049    *
01050    * @param textdoc
01051    *  New textual documentation.
01052    */
01053   void TextDoc(const std::string& textdoc);
01054 
01055   /**
01056    * Set name of file pointing to the html documentation.
01057    *
01058    * @param fname
01059    *  Filename
01060    */
01061   void HtmlDoc(const std::string& fname);
01062 
01063   /**
01064    * Append keyword.
01065    *
01066    * @param rKeyword
01067    *  Keyword
01068    */
01069   void AddKeyword(const std::string& rKeyword);
01070 
01071   /**
01072    * Std faudes type interface: assignment.
01073    *
01074    * @param rSrc 
01075    *    Source to copy from
01076    * @return Reference to this object.
01077    */
01078   virtual Documentation& DoAssign(const Documentation& rSrc);
01079 
01080   /**
01081    * Std faudes type interface: test equality
01082    * 
01083    * @param rOther 
01084    *    Other object to compare with.
01085    * @return 
01086    *   True on match.
01087    */
01088   virtual bool DoEqual(const Documentation& rOther) const;
01089 
01090   /**
01091    * Read configuration data of this object from TokenReader.
01092    *
01093    * This virtual function reads documentation from a token stream. 
01094    * The section defaults to Documentation. It invokes DoReadCore to
01095    * do the member data token reading. 
01096    *
01097    * @param rTr
01098    *   TokenReader to read from
01099    * @param rLabel
01100    *   Section to read
01101    * @param pContext
01102    *   Read context to provide contextual information (ignored)
01103    *
01104    * @exception Exception
01105    *  - Token mismatch (id 50, 51, 52)
01106    *  - IO Error (id 1)
01107    */
01108   virtual void DoRead(TokenReader& rTr,  const std::string& rLabel = "", const Type* pContext=0);
01109  
01110   /**
01111    * Read configuration data of this object from TokenReader.
01112    *
01113    * This virtual function reads documentation member data only. 
01114    * It does NOT read the enclosing begin and end tokens.
01115    *
01116    * @param rTr
01117    *   TokenReader to read from
01118    *
01119    * @exception Exception
01120    *  - Token mismatch (id 50, 51, 52)
01121    *  - IO Error (id 1)
01122    */
01123   virtual void DoReadCore(TokenReader& rTr);
01124  
01125 
01126 
01127   /**
01128    * Write configuration data of this object to TokenWriter.
01129    *
01130    * This virtual function writes documentation to a token stream. 
01131    * The section defaults to Documentation. It invokes DoWriteCore to
01132    * do the actual member data writing. 
01133    *
01134    * @param rTw
01135    *   Reference to TokenWriter
01136    * @param rLabel
01137    *   Label of section to write
01138    * @param pContext
01139    *   Write context to provide contextual information
01140    *
01141    * @exception Exception 
01142    *   - IO errors (id 2)
01143    */
01144   virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const;
01145 
01146 
01147   /**
01148    * Write configuration data of this object to TokenWriter.
01149    *
01150    * This virtual function reads documentation members only. 
01151    * It does NOT write enclosing begin and end tokens.
01152    *
01153    * @param rTw
01154    *   Reference to TokenWriter
01155    *
01156    * @exception Exception 
01157    *   - IO errors (id 2)
01158    */
01159   virtual void DoWriteCore(TokenWriter& rTw) const;
01160 
01161 
01162   /** Faudes name. */
01163   std::string mName;
01164 
01165   /** Faudes plugin. */
01166   std::string mPlugIn;
01167 
01168   /** Corresponing C++ type, or "" if no such. */
01169   std::string mCType;
01170 
01171   /** String containing the text-documentation. */
01172   std::string mTextDoc;
01173 
01174   /** String containing the filename of the corresponding html-documentation. */
01175   std::string mHtmlDoc;
01176 
01177   /** Comma-seperated string containing all keywords. */
01178   std::string mKeywords;
01179 
01180   /** Constant characted used to seperate keywords */
01181   static const char mDelim = ';';
01182 
01183 }; // Documentation
01184 
01185 
01186 
01187 /**
01188  * A TypeDefinition defines a faudes-type in that it specifies
01189  * a faudes-type name to identify the type and a method
01190  * NewObject() to instantiate objects of the respective type. 
01191  * In this sense, TypeDefinition is a so called factory class.
01192  * Technically, the TypeDefinition holds one instance of the faude type,
01193  * the so called prototype object, and NewObject() invokes the New() method
01194  * of the prototype. Notebly, there is only one class TypeDefinition that by
01195  * parametrisation defins all derivates of Type.
01196  * 
01197  * TypeDefinition is derived from faudes::Documentation and therefore additional
01198  * documentation-data can be associated.
01199  *
01200  * Technical note: currently, we use only the token io facilities from the faudes type
01201  * interface. Assignement, Case, and factory methods ae not ikmplemented.
01202  *
01203  * @ingroup RunTimeInterface
01204  */
01205 
01206 class TypeDefinition : public Documentation {
01207 
01208  public:
01209 
01210   /** 
01211    * Constructor 
01212    *
01213    * The default constructor instantiates an invalid type definition
01214    * without prototype. To construct
01215    * a valid type definition, use the static Constructor() template
01216    * function.
01217    */
01218   TypeDefinition(const std::string& name="") : Documentation(), mpType(NULL) {Name(name);};
01219 
01220   /**
01221    * Destructor.
01222    *
01223    * Delete prototype object.
01224    */
01225   virtual ~TypeDefinition(void){ Prototype(NULL); };
01226 
01227   /**
01228    * Construct empty TypeDefinition object.
01229    * The given template parameter denotes any libFAUDES class derived from faudes::Type
01230    * A new instance of this class is assigned to member variable (pType)
01231    * whereas the name is set as specified.
01232    *
01233    * @tparam T
01234    *   Actual c class, derived from Type
01235    * @param rTypeName
01236    *   Name to identify this faudes-type<; defaults to the plattform
01237    *   dependand typeid from the c++ runtime type information system.
01238    * @return
01239    *   Newly constructed type definition.
01240    *
01241    */
01242   template<class T>
01243   static TypeDefinition* Constructor(const std::string& rTypeName="");
01244 
01245   /**
01246    * Construct empty TypeDefinition object.
01247    * The given prototype is assigned to the member variable pType,
01248    *
01249    * @param pProto
01250    *   Prototype, derived from Type
01251    * @param rTypeName
01252    *   Name to identify this faudes-type<; defaults to the plattform
01253    *   dependand typeid from the c++ runtime type information system.
01254    * @return
01255    *   Newly constructed type definition.
01256    *
01257    */
01258   static TypeDefinition* Constructor(Type* pProto, const std::string& rTypeName="");
01259 
01260   /**
01261    * Construct TypeDefinition object and read name and
01262    * documentation-data from TokenReader.
01263    *
01264    * @tparam T
01265    *   Actual c class, derived from Type
01266    * @param rFileName
01267    *   Name of file to read.
01268    * @return
01269    *   Newly constructed type definition.
01270    *
01271    * @exception Exception
01272    *  - Token mismatch (id 50, 51, 52)
01273    *  - IO Error (id 1)
01274    */
01275   template<class T>
01276   static TypeDefinition* FromFile(const std::string& rFileName);
01277 
01278 
01279   /**
01280    * Return pointer to faudes-object prototype 
01281    *
01282    * Note: this method is meant for inspection only, control over
01283    * the prototype remains with the TypeDefinition. Use
01284    * NewObject() to instantiate a new faudes-object.
01285    *
01286    * @return
01287    *   Reference to prototype object
01288    */
01289   const Type* Prototype(void) const;
01290 
01291 
01292   /**
01293    * Construct faudes-object on heap.
01294    * Return pointer to new instance of assigned Type class.
01295    *
01296    * Note: If no prototype is installed, NULL is returned.
01297    *
01298    * @return
01299    *  Pointer to new Type instance.
01300    */
01301   Type* NewObject(void) const;
01302 
01303  protected:
01304 
01305 
01306   /** Disable copy constructor */
01307  TypeDefinition(const TypeDefinition& rOther) : Documentation(rOther) {}; // todo: implement ?? for stl maps ?
01308 
01309   /**
01310    * Clear documentation-data; do *NOT* delete prototype  (this is for using Read to 
01311    * merge/overwrite documentation)
01312    */
01313   void Clear(void);
01314 
01315   /**
01316    * Use given object as prototype.
01317    *
01318    * The TypeDefinition takes ownership of the
01319    * provided object.
01320    *
01321    * @param pType
01322    *  Any class that inherits Type.
01323    */
01324   virtual void Prototype(Type* pType);
01325 
01326   /**
01327    * Read configuration data of this object from TokenReader.
01328    *
01329    * The section defaults to "TypeDefinition", context ignored.
01330    * Actual reading is done by DoReadCore.
01331    *
01332    * @param rTr
01333    *   TokenReader to read from
01334    * @param rLabel
01335    *   Section to read
01336    * @param pContext
01337    *   Read context to provide contextual information (ignored)
01338    *
01339    * @exception Exception
01340    *   - Token mismatch (id 50, 51, 52)
01341    *   - IO error (id 1)
01342    */
01343   virtual void DoRead(TokenReader& rTr,  const std::string& rLabel = "", const Type* pContext=0);
01344  
01345   /**
01346    * Read configuration data of this object from TokenReader.
01347    *
01348    * This method reads members only, it does not read the section.
01349    *
01350    * @param rTr
01351    *   TokenReader to read from
01352    *
01353    * @exception Exception
01354    *   - Token mismatch (id 50, 51, 52)
01355    *   - IO error (id 1)
01356    */
01357   virtual void DoReadCore(TokenReader& rTr);
01358  
01359   /**
01360    * Write configuration data of this object to TokenWriter.
01361    *
01362    * The section defaults to "TypeDefinition", context ignored.
01363    * Actual writing is done by DoWriteCore.
01364    *
01365    * @param rTw
01366    *   Reference to TokenWriter
01367    * @param rLabel
01368    *   Label of section to write
01369    * @param pContext
01370    *   Write context to provide contextual information
01371    *
01372    * @exception Exception 
01373    *   - IO errors (id 2)
01374    */
01375   virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const;
01376 
01377   /**
01378    * Write configuration data of this object to TokenWriter.
01379    *
01380    * This method wrtite plain member data, the section lables are not
01381    * written.
01382    *
01383    * @param rTw
01384    *   Reference to TokenWriter
01385    *
01386    * @exception Exception 
01387    *   - IO errors (id 2)
01388    */
01389   virtual void DoWriteCore(TokenWriter& rTw) const;
01390 
01391   /** Type-pointer to store address of libFAUDES-Type instance */
01392   Type* mpType;
01393 
01394 }; //TypeDefinition
01395 
01396 
01397 
01398 
01399 /**********************************************************************************************
01400 ***********************************************************************************************
01401 ***********************************************************************************************
01402 
01403 Implemention of template members functions
01404 
01405 ***********************************************************************************************
01406 ***********************************************************************************************
01407 **********************************************************************************************/
01408 
01409 
01410 // typedefinition constructor function
01411 template<class T>
01412 TypeDefinition* TypeDefinition::Constructor(const std::string& rTypeName){
01413   FD_DRTI("TypeDefinition::Construct<" << typeid(T).name() << ">()");
01414   return Constructor(new T, rTypeName);
01415 }
01416 
01417 
01418 // type definition constructor function
01419 template<class T>
01420 TypeDefinition* TypeDefinition::FromFile(const std::string& rFileName){
01421   FD_DRTI("TypeDefinition::FromFile<" << typeid(T).name() << ">()");
01422   // construct with fallback name
01423   TypeDefinition* td = Constructor<T>();
01424   // read docu, incl actual name
01425   td->Read(rFileName);
01426   // done
01427   return(td);
01428 }
01429 
01430 
01431 
01432 
01433 
01434 } // namespace
01435 
01436 #endif /* FAUDES_RTITYPES_H */

libFAUDES 2.16b --- 2010-9-8 --- c++ source docu by doxygen 1.6.3