Adapters.h

Go to the documentation of this file.
00001 #ifndef PYROOT_ADAPTERS_H
00002 #define PYROOT_ADAPTERS_H
00003 
00004 // ROOT
00005 #include "TClassRef.h"
00006 class TBaseClass;
00007 class TDictionary;
00008 class TMethod;
00009 class TFunction;
00010 class TDataMember;
00011 class TMethodArg;
00012 
00013 #ifdef PYROOT_USE_REFLEX
00014 #include "Reflex/Kernel.h"
00015 #else
00016 namespace ROOT {
00017    namespace Reflex {
00018 
00019    /** enum for printing names */
00020       enum ENTITY_HANDLING {
00021          FINAL     = (1<<0),
00022          QUALIFIED = (1<<1),
00023          SCOPED    = (1<<2),
00024          F         = (1<<4),
00025          Q         = (1<<5),
00026          S         = (1<<6)
00027       };
00028 
00029    } // namespace Reflex
00030 } // namespace ROOT
00031 #endif
00032 
00033 // Standard
00034 #include <string>
00035 
00036 
00037 namespace PyROOT {
00038 
00039 class TScopeAdapter;
00040 
00041 
00042 class TReturnTypeAdapter {
00043 public:
00044    TReturnTypeAdapter( const std::string& name ) : fName( name ) {}
00045 
00046    std::string Name( unsigned int mod = 0 ) const;
00047 
00048 private:
00049    std::string fName;
00050 };
00051 
00052 
00053 class TMemberAdapter {
00054 public:
00055    TMemberAdapter( TMethod* meth );
00056    operator TMethod*() const;
00057 
00058    TMemberAdapter( TFunction* func );
00059    operator TFunction*() const;
00060 
00061    TMemberAdapter( TDataMember* mb );
00062    operator TDataMember*() const;
00063 
00064    TMemberAdapter( TMethodArg* ma );
00065    operator TMethodArg*() const;
00066 
00067    operator bool() const { return fMember != 0; }
00068 
00069 public:
00070    std::string Name( unsigned int mod = 0 ) const;
00071 
00072    Bool_t IsEnum() const;
00073    Bool_t IsPublic() const;
00074    Bool_t IsStatic() const;
00075 
00076    size_t FunctionParameterSize( bool required = false ) const;
00077    TMemberAdapter FunctionParameterAt( size_t nth ) const;
00078    std::string FunctionParameterNameAt( size_t nth ) const;
00079    std::string FunctionParameterDefaultAt( size_t nth ) const;
00080 
00081    TReturnTypeAdapter ReturnType() const;
00082    TScopeAdapter DeclaringScope() const;
00083 
00084    TMemberAdapter TypeOf() const { return *this; }
00085 
00086 private:
00087    TDictionary* fMember;
00088 };
00089 
00090 
00091 class TBaseAdapter {
00092 public:
00093    TBaseAdapter( TBaseClass* base ) : fBase( base ) {}
00094    operator bool() const { return fBase != 0; }
00095 
00096 public:
00097    std::string Name() const;
00098 
00099 private:
00100    TBaseClass* fBase;
00101 };
00102 
00103 
00104 class TScopeAdapter {
00105 public:
00106    TScopeAdapter( TClass* klass );
00107    TScopeAdapter( const std::string& name );
00108    TScopeAdapter( const TMemberAdapter& );
00109    operator TClass*() const { return fClass.GetClass(); }
00110    operator bool() const;
00111 
00112 public:
00113    static TScopeAdapter ByName( const std::string & name );
00114 
00115 public:
00116    std::string Name( unsigned int mod = 0 ) const;
00117 
00118    TBaseAdapter BaseAt( size_t nth ) const;
00119    size_t BaseSize() const;
00120 
00121    TMemberAdapter FunctionMemberAt( size_t nth ) const;
00122    size_t FunctionMemberSize() const;
00123 
00124    TMemberAdapter DataMemberAt( size_t nth ) const;
00125    size_t DataMemberSize() const;
00126 
00127 public:
00128    Bool_t IsComplete() const;
00129 
00130    Bool_t IsClass() const;
00131    Bool_t IsStruct() const;
00132    Bool_t IsNamespace() const;
00133 
00134 // note: in Reflex, part of Type, not Scope
00135    Bool_t IsAbstract() const;
00136 
00137    void* Id() const { return fClass.GetClass(); }
00138 
00139 private:
00140    TClassRef fClass;
00141    std::string fName;
00142 };
00143 
00144 } // namespace PyROOT
00145 
00146 #endif // !PYROOT_ADAPTERS_H

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