Kernel.h

Go to the documentation of this file.
00001 // @(#)root/reflex:$Id: Kernel.h 32267 2010-02-08 10:24:46Z axel $
00002 // Author: Stefan Roiser 2004
00003 
00004 // Copyright CERN, CH-1211 Geneva 23, 2004-2010, All rights reserved.
00005 //
00006 // Permission to use, copy, modify, and distribute this software for any
00007 // purpose is hereby granted without fee, provided that this copyright and
00008 // permissions notice appear in all copies and derivatives.
00009 //
00010 // This software is provided "as is" without express or implied warranty.
00011 
00012 #ifndef Reflex_Kernel
00013 #define Reflex_Kernel
00014 
00015 // These macros will allow selection on exported symbols
00016 // taken from http://www.nedprod.com/programs/gccvisibility.html
00017 // Shared library support
00018 
00019 #if __GNUC__ >= 4 && !defined(__CINT__)
00020 # define GCC_HASCLASSVISIBILITY
00021 #endif
00022 
00023 #if !defined(REFLEX_DLL_VETO) && !defined(REFLEX_DLL) && !defined(__CINT__)
00024 // we build Reflex as DLL by default, #define REFLEX_DLL_VETO to hide visibility / dllim/export code
00025 # define REFLEX_DLL
00026 #endif
00027 
00028 #ifdef _WIN32
00029 # define RFLX_IMPORT __declspec(dllimport)
00030 # define RFLX_EXPORT __declspec(dllexport)
00031 # define RFLX_DLLLOCAL
00032 # define RFLX_DLLPUBLIC
00033 #else
00034 # ifdef GCC_HASCLASSVISIBILITY
00035 #  define RFLX_EXPORT __attribute__((visibility("default")))
00036 #  define RFLX_DLLLOCAL __attribute__((visibility("hidden")))
00037 #  define RFLX_DLLPUBLIC __attribute__((visibility("default")))
00038 # else
00039 #  define RFLX_EXPORT
00040 #  define RFLX_DLLLOCAL
00041 #  define RFLX_DLLPUBLIC
00042 # endif
00043 # define RFLX_IMPORT
00044 #endif
00045 
00046 // Define RFLX_API for DLL builds
00047 #ifdef REFLEX_DLL
00048 # ifdef REFLEX_BUILD
00049 #  define RFLX_API RFLX_EXPORT
00050 # else
00051 #  define RFLX_API RFLX_IMPORT
00052 # endif  // REFLEX_BUILD
00053 #else
00054 # define RFLX_API
00055 #endif // REFLEX_DLL
00056 
00057 // Throwable classes must always be visible on GCC in all binaries
00058 #ifdef _WIN32
00059 # define RFLX_EXCEPTIONAPI(api) api
00060 #elif defined(GCC_HASCLASSVISIBILITY)
00061 # define RFLX_EXCEPTIONAPI(api) RFLX_EXPORT
00062 #else
00063 # define RFLX_EXCEPTIONAPI(api)
00064 #endif
00065 // end macros for symbol selection
00066 
00067 
00068 // include config.h generated by autoconf
00069 #if defined(HAVE_CONFIG)
00070 # include "config.h"
00071 #endif
00072 
00073 #if defined(_AIX)
00074 # define ANSICPP
00075 # define NEED_STRCASECMP
00076 #endif
00077 
00078 #if defined(__alpha) && !defined(__linux)
00079 # ifndef __USE_STD_IOSTREAM
00080 #  define __USE_STD_IOSTREAM
00081 # endif
00082 #endif
00083 
00084 // windows.h and oracle define CONST
00085 #ifdef CONST
00086 # undef CONST
00087 #endif
00088 
00089 #ifdef _WIN32
00090 // Some pragmas to avoid warnings in MSVisualC
00091 // Disable warning C4786: identifier was truncated to '255' characters in the debug information
00092 # pragma warning ( disable : 4786 )
00093 // Disable warning C4291: no matching operator delete found; memory will not be freed if
00094 // initialization throws an exception
00095 # pragma warning ( disable : 4291 )
00096 // Disable warning C4250: inheritance via dominance
00097 # pragma warning ( disable : 4250 )
00098 #endif
00099 
00100 // some compilers define the macros below in limits
00101 #include <limits>
00102 
00103 #ifndef LONGLONG_MAX
00104 # define LONGLONG_MAX 0x7FFFFFFFFFFFFFFFLL
00105 #endif
00106 #ifndef LONGLONG_MIN
00107 # define LONGLONG_MIN 0x8000000000000000LL
00108 #endif
00109 #ifndef ULONGLONG_MAX
00110 # define ULONGLONG_MAX 0xFFFFFFFFFFFFFFFFLL
00111 #endif
00112 #ifndef ULONGLONG_MIN
00113 # define ULONGLONG_MIN 0x0000000000000000LL
00114 #endif
00115 
00116 
00117 // Include files
00118 #include <stdlib.h>
00119 #include <string.h>
00120 #include <string>
00121 #include <cstring>
00122 #include <vector>
00123 #include <utility>
00124 #include <exception>
00125 
00126 namespace Reflex {
00127 #if 0
00128 // The definition of Reflex::longlong is now removed.
00129 // It is not needed by the Reflex API, and it interfers
00130 // with user code defining its own longlong, because
00131 // the dictionaries pull it in via "using namespace Reflex".
00132 
00133 // Large integer definition depends of the platform
00134 # if defined(_WIN32) && !defined(__CINT__)
00135 typedef __int64 longlong;
00136 typedef unsigned __int64 ulonglong;
00137 # else
00138 typedef long long int longlong;    /* */
00139 typedef unsigned long long int /**/ ulonglong;
00140 # endif
00141 #endif
00142 
00143 // forward declarations
00144 class Any;
00145 class Type;
00146 class Base;
00147 class Scope;
00148 class Object;
00149 class Member;
00150 class PropertyList;
00151 class TypeTemplate;
00152 class MemberTemplate;
00153 
00154 typedef std::vector<std::string> StdString_Cont_Type_t;
00155 typedef StdString_Cont_Type_t::const_iterator StdString_Iterator;
00156 typedef StdString_Cont_Type_t::const_reverse_iterator Reverse_StdString_Iterator;
00157 
00158 typedef std::vector<Type> Type_Cont_Type_t;
00159 typedef Type_Cont_Type_t::const_iterator Type_Iterator;
00160 typedef Type_Cont_Type_t::const_reverse_iterator Reverse_Type_Iterator;
00161 
00162 typedef std::vector<Base> Base_Cont_Type_t;
00163 typedef Base_Cont_Type_t::const_iterator Base_Iterator;
00164 typedef Base_Cont_Type_t::const_reverse_iterator Reverse_Base_Iterator;
00165 
00166 typedef std::vector<Scope> Scope_Cont_Type_t;
00167 typedef Scope_Cont_Type_t::const_iterator Scope_Iterator;
00168 typedef Scope_Cont_Type_t::const_reverse_iterator Reverse_Scope_Iterator;
00169 
00170 typedef std::vector<Object> Object_Cont_Type_t;
00171 typedef Object_Cont_Type_t::const_iterator Object_Iterator;
00172 typedef Object_Cont_Type_t::const_reverse_iterator Reverse_Object_Iterator;
00173 
00174 typedef std::vector<Member> Member_Cont_Type_t;
00175 typedef Member_Cont_Type_t::const_iterator Member_Iterator;
00176 typedef Member_Cont_Type_t::const_reverse_iterator Reverse_Member_Iterator;
00177 
00178 typedef std::vector<TypeTemplate> TypeTemplate_Cont_Type_t;
00179 typedef TypeTemplate_Cont_Type_t::const_iterator TypeTemplate_Iterator;
00180 typedef TypeTemplate_Cont_Type_t::const_reverse_iterator Reverse_TypeTemplate_Iterator;
00181 
00182 typedef std::vector<MemberTemplate> MemberTemplate_Cont_Type_t;
00183 typedef MemberTemplate_Cont_Type_t::const_iterator MemberTemplate_Iterator;
00184 typedef MemberTemplate_Cont_Type_t::const_reverse_iterator Reverse_MemberTemplate_Iterator;
00185 
00186 
00187 namespace Dummy {
00188 RFLX_API const StdString_Cont_Type_t& StdStringCont();
00189 RFLX_API const Type_Cont_Type_t& TypeCont();
00190 RFLX_API const Base_Cont_Type_t& BaseCont();
00191 RFLX_API const Scope_Cont_Type_t& ScopeCont();
00192 RFLX_API const Object_Cont_Type_t& ObjectCont();
00193 RFLX_API const Member_Cont_Type_t& MemberCont();
00194 RFLX_API const TypeTemplate_Cont_Type_t& TypeTemplateCont();
00195 RFLX_API const MemberTemplate_Cont_Type_t& MemberTemplateCont();
00196 RFLX_API Any& Any();
00197 RFLX_API const Object& Object();
00198 RFLX_API const Type& Type();
00199 RFLX_API const TypeTemplate& TypeTemplate();
00200 RFLX_API const Base& Base();
00201 RFLX_API const PropertyList& PropertyList();
00202 RFLX_API const Member& Member();
00203 RFLX_API const MemberTemplate& MemberTemplate();
00204 RFLX_API const Scope& Scope();
00205 template <class T> inline const T&
00206 Get() {
00207    static T t;
00208    return t;
00209 }
00210 
00211 
00212 }
00213 
00214 
00215 /** The Reflex instance ensures the setup of the databases
00216     and provides access to some general information about the Reflex package */
00217 class RFLX_API Instance {
00218 public:
00219    /** default constructor */
00220    Instance();
00221 
00222    /** destructor */
00223    ~Instance();
00224 
00225    enum EState {
00226       kUninitialized, // before instance construction
00227       kInitializing, // the instance is being constructed
00228       kActive, // the instance is running
00229       kTearingDown, // the instance is being destructed
00230       kHasShutDown, // the instance has been destructed
00231       kNumStates
00232    };
00233 
00234    /** return true if Reflex has shutdown (end of process) */
00235    static bool HasShutdown();
00236 
00237    /** return Reflex instance state */
00238    static EState State();
00239 
00240    void Shutdown();
00241 
00242 private:
00243    Instance(Instance * createSingleton);
00244    static Instance& CreateReflexInstance();
00245 
00246    static Instance* fgSingleton; // class singleton
00247    static EState fgState; // singleton's state
00248 };    // struct Reflex
00249 
00250 /** the Name of the package - used for messages */
00251 RFLX_API const std::string& Argv0();     // returns "Reflex";
00252 
00253 // these defines are used for the modifiers they are used in the following
00254 // classes
00255 // BA = BASE
00256 // CL = CLASS
00257 // FU = FUNCTION
00258 // DM = DATAMEMBER
00259 // FM = FUNCTIONMEMBER
00260 // TY = TYPE
00261 // ME = MEMBER
00262 //                                BA  CL  DM  FM  TY  ME
00263 enum ENTITY_DESCRIPTION {
00264    PUBLIC = (1 << 0),            //  X       X   X       X
00265    PROTECTED = (1 << 1),         //  X       X   X       X
00266    PRIVATE = (1 << 2),           //  X       X   X       X
00267    REGISTER = (1 << 3),          //          X   X       X
00268    STATIC = (1 << 4),            //          X   X       X
00269    CONSTRUCTOR = (1 << 5),       //              X       X
00270    DESTRUCTOR = (1 << 6),        //              X       X
00271    EXPLICIT = (1 << 7),          //              X       X
00272    EXTERN = (1 << 8),            //          X   X       X
00273    COPYCONSTRUCTOR = (1 << 9),   //              X       X
00274    OPERATOR = (1 << 10),         //              X       X
00275    INLINE = (1 << 11),           //              X       X
00276    CONVERTER = (1 << 12),        //              X       X
00277    AUTO = (1 << 13),             //          X           X
00278    MUTABLE = (1 << 14),          //          X           X
00279    CONST = (1 << 15),            //          X       X   X
00280    VOLATILE = (1 << 16),         //          X       X   X
00281    REFERENCE = (1 << 17),        //          X           X
00282    ABSTRACT = (1 << 18),         //      X       X   X
00283    VIRTUAL = (1 << 19),          //  X   X           X
00284    TRANSIENT = (1 << 20),        //          X           X
00285    ARTIFICIAL = (1 << 21),       //  X   X   X   X   X   X
00286    // the bits 31 - 28 are reserved for template default arguments
00287    TEMPLATEDEFAULTS1 = (0 << 31) & (0 << 30) & (0 << 29) & (1 << 28),
00288    TEMPLATEDEFAULTS2 = (0 << 31) & (0 << 30) & (1 << 29) & (0 << 28),
00289    TEMPLATEDEFAULTS3 = (0 << 31) & (0 << 30) & (1 << 29) & (1 << 28),
00290    TEMPLATEDEFAULTS4 = (0 << 31) & (1 << 30) & (0 << 29) & (0 << 28),
00291    TEMPLATEDEFAULTS5 = (0 << 31) & (1 << 30) & (0 << 29) & (1 << 28),
00292    TEMPLATEDEFAULTS6 = (0 << 31) & (1 << 30) & (1 << 29) & (0 << 28),
00293    TEMPLATEDEFAULTS7 = (0 << 31) & (1 << 30) & (1 << 29) & (1 << 28),
00294    TEMPLATEDEFAULTS8 = (1 << 31) & (0 << 30) & (0 << 29) & (0 << 28),
00295    TEMPLATEDEFAULTS9 = (1 << 31) & (0 << 30) & (0 << 29) & (1 << 28),
00296    TEMPLATEDEFAULTS10 = (1 << 31) & (0 << 30) & (1 << 29) & (0 << 28),
00297    TEMPLATEDEFAULTS11 = (1 << 31) & (0 << 30) & (1 << 29) & (1 << 28),
00298    TEMPLATEDEFAULTS12 = (1 << 31) & (1 << 30) & (0 << 29) & (0 << 28),
00299    TEMPLATEDEFAULTS13 = (1 << 31) & (1 << 30) & (0 << 29) & (1 << 28),
00300    TEMPLATEDEFAULTS14 = (1 << 31) & (1 << 30) & (1 << 29) & (0 << 28),
00301    TEMPLATEDEFAULTS15 = (1 << 31) & (1 << 30) & (1 << 29) & (1 << 28)
00302 };
00303 
00304 
00305 /** enum for printing names */
00306 enum ENTITY_HANDLING {
00307    FINAL = (1 << 0),
00308    QUALIFIED = (1 << 1),
00309    SCOPED = (1 << 2),
00310    F = (1 << 4),
00311    Q = (1 << 5),
00312    S = (1 << 6)
00313 };
00314 
00315 
00316 /** enum containing all possible types and scopes */
00317 enum TYPE {
00318    CLASS = 0,
00319    STRUCT,
00320    ENUM,
00321    FUNCTION,
00322    ARRAY,
00323    FUNDAMENTAL,
00324    POINTER,
00325    POINTERTOMEMBER,
00326    TYPEDEF,
00327    UNION,
00328    TYPETEMPLATEINSTANCE,
00329    MEMBERTEMPLATEINSTANCE,
00330    NAMESPACE,
00331    DATAMEMBER,
00332    FUNCTIONMEMBER,
00333    UNRESOLVED
00334 };
00335 
00336 /** enum containing all possible 'representation' types */
00337 enum REPRESTYPE {
00338    REPRES_POINTER = 'a' - 'A',                 // To be added to the other value to refer to a pointer to
00339    REPRES_CHAR = 'c',
00340    REPRES_SIGNED_CHAR = 'c',
00341    REPRES_SHORT_INT = 's',
00342    REPRES_INT = 'i',
00343    REPRES_LONG_INT = 'l',
00344    REPRES_UNSIGNED_CHAR = 'b',
00345    REPRES_UNSIGNED_SHORT_INT = 'r',
00346    REPRES_UNSIGNED_INT = 'h',
00347    REPRES_UNSIGNED_LONG_INT = 'k',
00348    REPRES_BOOL = 'g',
00349    REPRES_FLOAT = 'f',
00350    REPRES_DOUBLE = 'd',
00351    REPRES_LONG_DOUBLE = 'q',
00352    REPRES_VOID = 'y',
00353    REPRES_LONGLONG = 'n',
00354    REPRES_ULONGLONG = 'm',
00355    REPRES_STRUCT = 'u',
00356    REPRES_CLASS = 'u',
00357    REPRES_ENUM = 'i',                   // Intentionally equal to REPRES_INT
00358    REPRES_NOTYPE = '\0'
00359                    // '1' is also a value used (for legacy implementation of function pointer)
00360                    // 'E' is also a value used (for legacy implementation of FILE*)
00361                    // 'a', 'j', 'T', 'o', 'O', 'p', 'P', 'z', 'Z', '\011', '\001', 'w' are also a value used (for support of various interpreter types)
00362 };
00363 
00364 enum EMEMBERQUERY {
00365    INHERITEDMEMBERS_DEFAULT,    // NO by default, set to ALSO by UpdateMembers()
00366    INHERITEDMEMBERS_NO,
00367    INHERITEDMEMBERS_ALSO
00368 };
00369 
00370 enum EDELAYEDLOADSETTING {
00371    DELAYEDLOAD_OFF,
00372    DELAYEDLOAD_ON
00373 };
00374 
00375 // Note TYPE and REPRESTYPE are 'small' enums and could be stored as 'char' to save space
00376 
00377 /** the max unsigned int */
00378 size_t NPos();
00379 
00380 
00381 /**
00382  * typedef for function member type (necessary for return value of
00383  * getter function)
00384  */
00385 typedef void (*StubFunction)(void*, void*, const std::vector<void*>&, void*);
00386 
00387 /** typedef for function for Offset calculation */
00388 typedef size_t (*OffsetFunction)(void*);
00389 
00390 /** dummy types for type_info purposes */
00391 class RFLX_API NullType {};
00392 class RFLX_API UnknownType {};
00393 /** place holders for protected types */
00394 class RFLX_API ProtectedClass {};
00395 class RFLX_API ProtectedEnum {};
00396 class RFLX_API ProtectedStruct {};
00397 class RFLX_API ProtectedUnion {};
00398 /** place holders for private types */
00399 class RFLX_API PrivateClass {};
00400 class RFLX_API PrivateEnum {};
00401 class RFLX_API PrivateStruct {};
00402 class RFLX_API PrivateUnion {};
00403 /** place holders for unnamed types (also typeinfo purposes) */
00404 class RFLX_API UnnamedClass {};
00405 class RFLX_API UnnamedEnum {};
00406 class RFLX_API UnnamedNamespace {};
00407 class RFLX_API UnnamedStruct {};
00408 class RFLX_API UnnamedUnion {};
00409 
00410 /** exception classes */
00411 class RFLX_EXCEPTIONAPI(RFLX_API) RuntimeError: public std::exception {
00412 public:
00413    RuntimeError(const std::string & msg): fMsg(Reflex::Argv0() + ": " + msg) {}
00414    ~RuntimeError() throw() {}
00415    virtual const char*
00416    what() const throw() { return fMsg.c_str(); }
00417 
00418    std::string fMsg;
00419 };
00420 
00421 } // namespace Reflex
00422 
00423 namespace ROOT {
00424 namespace Reflex {
00425 using namespace ::Reflex;
00426 }
00427 }
00428 
00429 
00430 //-------------------------------------------------------------------------------
00431 inline size_t
00432 Reflex::NPos() {
00433 //-------------------------------------------------------------------------------
00434    return (size_t) -1;
00435 }
00436 
00437 
00438 #endif // Reflex_Kernel

Generated on Tue Jul 5 14:25:54 2011 for ROOT_528-00b_version by  doxygen 1.5.1