Logo ROOT   6.12/07
Reference Guide
TSchemaRule.h
Go to the documentation of this file.
1 // @(#)root/core:$Id$
2 // author: Lukasz Janyst <ljanyst@cern.ch>
3 
4 #ifndef ROOT_TSchemaRule
5 #define ROOT_TSchemaRule
6 
7 class TBuffer;
8 class TVirtualObject;
9 class TObjArray;
10 
11 #include "TObject.h"
12 #include "TNamed.h"
13 #include "Rtypes.h"
14 #include "TString.h"
15 
16 #include <vector>
17 #include <utility>
18 
19 namespace ROOT {
20 
21  class TSchemaRule: public TObject
22  {
23  public:
24 
25  class TSources : public TNamed {
26  private:
28  public:
29  TSources(const char *name = 0, const char *title = 0, const char *dims = 0) : TNamed(name,title),fDimensions(dims) {}
30  const char *GetDimensions() { return fDimensions; }
31 
32  ClassDef(TSources,2);
33  };
34 
35  typedef enum
36  {
37  kReadRule = 0,
39  kNone = 99999
40  } RuleType_t;
41 
42  typedef void (*ReadFuncPtr_t)( char*, TVirtualObject* );
43  typedef void (*ReadRawFuncPtr_t)( char*, TBuffer&);
44 
45  TSchemaRule();
46  virtual ~TSchemaRule();
47 
48  TSchemaRule( const TSchemaRule& rhs );
49  TSchemaRule& operator = ( const TSchemaRule& rhs );
50  Bool_t operator == ( const TSchemaRule& rhs ) const;
51 
52 
53  void Clear(Option_t * /*option*/ ="");
54  Bool_t SetFromRule( const char *rule );
55 
56  const char *GetVersion( ) const;
57  Bool_t SetVersion( const TString& version );
58  Bool_t TestVersion( Int_t version ) const;
59  Bool_t SetChecksum( const TString& checksum );
60  Bool_t TestChecksum( UInt_t checksum ) const;
61  void SetSourceClass( const TString& classname );
62  const char *GetSourceClass() const;
63  void SetTargetClass( const TString& classname );
64  const char *GetTargetClass() const;
65  void SetTarget( const TString& target );
66  const TObjArray* GetTarget() const;
67  const char *GetTargetString() const;
68  void SetSource( const TString& source );
69  const TObjArray* GetSource() const;
70  void SetEmbed( Bool_t embed );
71  Bool_t GetEmbed() const;
72  Bool_t IsAliasRule() const;
73  Bool_t IsRenameRule() const;
74  Bool_t IsValid() const;
75  void SetCode( const TString& code );
76  const char *GetCode() const;
77  void SetAttributes( const TString& attributes );
78  const char *GetAttributes() const;
79  Bool_t HasTarget( const TString& target ) const;
80 
81  Bool_t HasSource( const TString& source ) const;
86  void SetInclude( const TString& include );
87  const TObjArray* GetInclude() const;
88  void SetRuleType( RuleType_t type );
89  RuleType_t GetRuleType() const;
90  Bool_t Conflicts( const TSchemaRule* rule ) const;
91 
92  void AsString( TString &out, const char *options = "" ) const;
93  void ls(Option_t *option="") const;
94 
95  ClassDef( TSchemaRule, 1 );
96 
97  private:
98 
99  Bool_t ProcessVersion( const TString& version ) const;
100  Bool_t ProcessChecksum( const TString& checksum ) const;
101  static void ProcessList( TObjArray* array, const TString& list );
102  static void ProcessDeclaration( TObjArray* array, const TString& list );
103 
104  TString fVersion; // Source version string
105  mutable std::vector<std::pair<Int_t, Int_t> >* fVersionVect; //! Source version vector (for searching purposes)
106  TString fChecksum; // Source checksum string
107  mutable std::vector<UInt_t>* fChecksumVect; //! Source checksum vector (for searching purposes)
108  TString fSourceClass; // Source class
109  TString fTargetClass; // Target class, this is the owner of this rule object.
110  TString fTarget; // Target data mamber string
111  mutable TObjArray* fTargetVect; //! Target data member vector (for searching purposes)
112  TString fSource; // Source data member string
113  mutable TObjArray* fSourceVect; //! Source data member vector (for searching purposes)
114  TString fInclude; // Includes string
115  mutable TObjArray* fIncludeVect; //! Includes vector
116  TString fCode; // User specified code snippet
117  Bool_t fEmbed; // Value determining if the rule should be embedded
118  ReadFuncPtr_t fReadFuncPtr; //! Conversion function pointer for read rule
119  ReadRawFuncPtr_t fReadRawFuncPtr; //! Conversion function pointer for readraw rule
120  RuleType_t fRuleType; // Type of the rule
121  TString fAttributes; // Attributes to be applied to the member (like Owner/NotOwner)
122  };
123 } // End of namespace ROOT
124 
125 #endif // ROOT_TSchemaRule
Bool_t IsValid() const
Return kTRUE if this rule is valid.
const TObjArray * GetInclude() const
Return the list of header files to include to be able to compile this rule as a TObjArray of TObjStri...
TString fCode
Includes vector.
Definition: TSchemaRule.h:116
const char * GetSourceClass() const
Get the source class of this rule (i.e. the onfile class).
Bool_t HasTarget(const TString &target) const
Return true if one of the rule&#39;s data member target is &#39;target&#39;.
void(* ReadRawFuncPtr_t)(char *, TBuffer &)
Definition: TSchemaRule.h:43
An array of TObjects.
Definition: TObjArray.h:37
Bool_t IsRenameRule() const
Return kTRUE if the rule is a strict renaming of the class to a new name.
const char * GetAttributes() const
Get the attributes code of this rule.
void SetReadRawFunctionPointer(ReadRawFuncPtr_t ptr)
Set the pointer to the function to be run for the rule (if it is a raw read rule).
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
Bool_t TestChecksum(UInt_t checksum) const
Check if given checksum is defined in this rule.
TSources(const char *name=0, const char *title=0, const char *dims=0)
Definition: TSchemaRule.h:29
ReadRawFuncPtr_t fReadRawFuncPtr
Conversion function pointer for read rule.
Definition: TSchemaRule.h:119
const char Option_t
Definition: RtypesCore.h:62
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
Basic string class.
Definition: TString.h:125
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual ~TSchemaRule()
Destructor.
Definition: TSchemaRule.cxx:99
TSchemaRule()
Default Constructor.
Definition: TSchemaRule.cxx:88
Bool_t SetVersion(const TString &version)
Set the version string - returns kFALSE if the format is incorrect.
TObjArray * fTargetVect
Definition: TSchemaRule.h:111
TString fSourceClass
Source checksum vector (for searching purposes)
Definition: TSchemaRule.h:108
void SetTargetClass(const TString &classname)
Set the target class of this rule (i.e. the in memory class).
RuleType_t fRuleType
Conversion function pointer for readraw rule.
Definition: TSchemaRule.h:120
virtual void Clear(Option_t *option="")
Set name and title to empty strings ("").
Definition: TNamed.cxx:64
void SetAttributes(const TString &attributes)
Set the attributes code of this rule.
#define ClassDef(name, id)
Definition: Rtypes.h:320
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
Bool_t ProcessChecksum(const TString &checksum) const
Check if specified checksum string is correct and build checksum vector.
std::vector< std::pair< Int_t, Int_t > > * fVersionVect
Definition: TSchemaRule.h:105
Bool_t Conflicts(const TSchemaRule *rule) const
Check if this rule conflicts with the given one.
void AsString(TString &out, const char *options="") const
Add to the string &#39;out&#39; the string representation of the rule.
const char * GetVersion() const
Get the version string.
Bool_t operator==(const TSchemaRule &rhs) const
Return true if the rule have the same effects.
void SetSource(const TString &source)
Set the list of source members.
RuleType_t GetRuleType() const
Return the type of the rule.
TObjArray * fSourceVect
Definition: TSchemaRule.h:113
void SetSourceClass(const TString &classname)
Set the source class of this rule (i.e. the onfile class).
ReadFuncPtr_t fReadFuncPtr
Definition: TSchemaRule.h:118
void SetInclude(const TString &include)
Set the comma separated list of header files to include to be able to compile this rule...
const TObjArray * GetSource() const
Get the list of source members as a TObjArray of TNamed object, with the name being the member name a...
virtual void ls(Option_t *option="") const
List TNamed name and title.
Definition: TNamed.cxx:113
TNamed & operator=(const TNamed &rhs)
TNamed assignment operator.
Definition: TNamed.cxx:51
const char * GetCode() const
Get the source code of this rule.
const char * GetTargetClass() const
Get the targte class of this rule (i.e. the in memory class).
std::vector< UInt_t > * fChecksumVect
Definition: TSchemaRule.h:107
void SetTarget(const TString &target)
Set the target member of this rule (i.e. the in memory data member).
unsigned int UInt_t
Definition: RtypesCore.h:42
void SetCode(const TString &code)
Set the source code of this rule.
const TObjArray * GetTarget() const
Get the target data members of this rule (i.e. the in memory data member).
static void ProcessList(TObjArray *array, const TString &list)
Split the list as a comma separated list into a TObjArray of TObjString.
Bool_t SetChecksum(const TString &checksum)
Set the checksum string - returns kFALSE if the format is incorrect.
TString fInclude
Source data member vector (for searching purposes)
Definition: TSchemaRule.h:114
Bool_t ProcessVersion(const TString &version) const
Check if specified version string is correct and build version vector.
TString fSource
Target data member vector (for searching purposes)
Definition: TSchemaRule.h:112
const char * GetTargetString() const
Get the target data members of this rule as a simple string (i.e. the in memory data member)...
static void ProcessDeclaration(TObjArray *array, const TString &list)
Split the list as a declaration into as a TObjArray of TNamed(name,type).
Wrapper around an object and giving indirect access to its content even if the object is not of a cla...
void(* ReadFuncPtr_t)(char *, TVirtualObject *)
Definition: TSchemaRule.h:42
void SetReadFunctionPointer(ReadFuncPtr_t ptr)
Set the pointer to the function to be run for the rule (if it is a read rule).
Bool_t GetEmbed() const
Return true if this rule should be saved in the ROOT File.
Bool_t HasSource(const TString &source) const
Return true if one of the rule&#39;s data member source is &#39;source&#39;.
int type
Definition: TGX11.cxx:120
void SetEmbed(Bool_t embed)
Set whether this rule should be save in the ROOT file (if true)
TString fTargetClass
Definition: TSchemaRule.h:109
Mother of all ROOT objects.
Definition: TObject.h:37
typedef void((*Func_t)())
TString fChecksum
Source version vector (for searching purposes)
Definition: TSchemaRule.h:106
Bool_t TestVersion(Int_t version) const
Check if given version number is defined in this rule.
ReadRawFuncPtr_t GetReadRawFunctionPointer() const
Get the pointer to the function to be run for the rule (if it is a raw read rule).
Bool_t IsAliasRule() const
Return kTRUE if the rule is a strict renaming of one of the data member of the class.
TObjArray * fIncludeVect
Definition: TSchemaRule.h:115
void SetRuleType(RuleType_t type)
Set the type of the rule.
char name[80]
Definition: TGX11.cxx:109
ReadFuncPtr_t GetReadFunctionPointer() const
Get the pointer to the function to be run for the rule (if it is a read rule).
Bool_t SetFromRule(const char *rule)
Set the content fot this object from the rule See TClass::AddRule for details on the syntax...
const char * GetDimensions()
Definition: TSchemaRule.h:30