Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
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#include "TNamed.h"
8#include "TString.h"
9
10#include <vector>
11#include <utility>
12
13class TBuffer;
14class TVirtualObject;
15class TObjArray;
16namespace ROOT {
17namespace Internal {
18struct TSchemaHelper;
19}
20} // namespace ROOT
21
22namespace ROOT {
23
24 class TSchemaRule : public TObject
25 {
26 public:
27
28 class TSources : public TNamed {
29 private:
32
33 public:
34 TSources(const char *name = nullptr, const char *title = nullptr, const char *dims = nullptr)
35 : TNamed(name, title), fDimensions(dims)
36 {
37 if (fTitle.Length())
38 while (fTitle[fTitle.Length() - fPointerLevel - 1] == '*')
41 fTitle.Remove(fTitle.Length() - fPointerLevel);
42 }
43
44 const char *GetDimensions() const { return fDimensions; }
45
46 bool IsPointer() const { return fPointerLevel > 0; }
47
49
50 const char *GetUnderlyingTypeName() const { return fTitle; }
51
52 // The source can be declared with:
53 // "%s %s%s;", GetTypeForDeclaration().Data(), GetName(), GetDimensions);
55 {
57 for (Int_t s = 0; s < fPointerLevel; ++s)
58 type.Append('*');
59 return type;
60 }
61
62 void SetTitle(const char *) override
63 {
64 Fatal("SetTitle", "Changing the type represented by a TSources is not supported.");
65 }
66
68 };
69
70 typedef enum
71 {
74 kNone = 99999
75 } RuleType_t;
76
77 typedef void (*ReadFuncPtr_t)( char*, TVirtualObject* );
78 typedef void (*ReadRawFuncPtr_t)( char*, TBuffer&);
79
81 TSchemaRule(RuleType_t type, const char *targetClass, const ROOT::Internal::TSchemaHelper &helper);
82 virtual ~TSchemaRule();
83
84 TSchemaRule( const TSchemaRule& rhs );
85 TSchemaRule& operator = ( const TSchemaRule& rhs );
86 Bool_t operator == ( const TSchemaRule& rhs ) const;
87
88
89 void Clear(Option_t * /*option*/ ="") override;
90 Bool_t SetFromRule( const char *rule );
91
92 const char *GetVersion( ) const;
93 Bool_t SetVersion( const TString& version );
94 Bool_t TestVersion( Int_t version ) const;
95 Bool_t SetChecksum( const TString& checksum );
96 Bool_t TestChecksum( UInt_t checksum ) const;
97 void SetSourceClass( const TString& classname );
98 const char *GetSourceClass() const;
99 void SetTargetClass( const TString& classname );
100 const char *GetTargetClass() const;
101 void SetTarget( const TString& target );
102 const TObjArray* GetTarget() const;
103 const char *GetTargetString() const;
104 void SetSource( const TString& source );
105 const TObjArray* GetSource() const;
106 void SetEmbed( Bool_t embed );
107 Bool_t GetEmbed() const;
108 Bool_t IsAliasRule() const;
109 Bool_t IsRenameRule() const;
110 Bool_t IsValid() const;
111 void SetCode( const TString& code );
112 const char *GetCode() const;
113 void SetAttributes( const TString& attributes );
114 const char *GetAttributes() const;
115 Bool_t HasTarget( const TString& target ) const;
116
117 Bool_t HasSource( const TString& source ) const;
122 void SetInclude( const TString& include );
123 const TObjArray* GetInclude() const;
125 RuleType_t GetRuleType() const;
126 Bool_t Conflicts( const TSchemaRule* rule ) const;
127
128 void AsString( TString &out, const char *options = "" ) const;
129 void ls(Option_t *option="") const override;
130
131 private:
132
133 Bool_t ProcessVersion( const TString& version ) const;
134 Bool_t ProcessChecksum( const TString& checksum ) const;
135 UInt_t ParseChecksum( const char* checksum ) const;
136 static void ProcessList( TObjArray* array, const TString& list );
137 static void ProcessDeclaration( TObjArray* array, const TString& list );
138
139 TString fVersion; // Source version string
140 mutable std::vector<std::pair<Int_t, Int_t> >* fVersionVect; ///<! Source version vector (for searching purposes)
141 TString fChecksum; // Source checksum string
142 mutable std::vector<UInt_t>* fChecksumVect; ///<! Source checksum vector (for searching purposes)
143 TString fSourceClass; // Source class
144 TString fTargetClass; // Target class, this is the owner of this rule object.
145 TString fTarget; // Target data mamber string
146 mutable TObjArray* fTargetVect; ///<! Target data member vector (for searching purposes)
147 TString fSource; // Source data member string
148 mutable TObjArray* fSourceVect; ///<! Source data member vector (for searching purposes)
149 TString fInclude; // Includes string
150 mutable TObjArray* fIncludeVect; ///<! Includes vector
151 TString fCode; // User specified code snippet
152 Bool_t fEmbed; // Value determining if the rule should be embedded
153 ReadFuncPtr_t fReadFuncPtr; ///<! Conversion function pointer for read rule
154 ReadRawFuncPtr_t fReadRawFuncPtr; ///<! Conversion function pointer for readraw rule
155 RuleType_t fRuleType; // Type of the rule
156 TString fAttributes; // Attributes to be applied to the member (like Owner/NotOwner)
157
159
160 };
161} // End of namespace ROOT
162
163#endif // ROOT_TSchemaRule
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
char name[80]
Definition TGX11.cxx:148
Int_t GetPointerLevel() const
Definition TSchemaRule.h:48
const char * GetUnderlyingTypeName() const
Definition TSchemaRule.h:50
void SetTitle(const char *) override
Set the title of the TNamed.
Definition TSchemaRule.h:62
const char * GetDimensions() const
Definition TSchemaRule.h:44
TSources(const char *name=nullptr, const char *title=nullptr, const char *dims=nullptr)
Definition TSchemaRule.h:34
void SetRuleType(RuleType_t type)
Set the type of the rule.
TObjArray * fSourceVect
! Source data member vector (for searching purposes)
void SetCode(const TString &code)
Set the source code of this rule.
void SetTarget(const TString &target)
Set the target member of this rule (i.e. the in memory data member).
ReadFuncPtr_t fReadFuncPtr
! Conversion function pointer for read rule
TObjArray * fIncludeVect
! Includes vector
void SetReadRawFunctionPointer(ReadRawFuncPtr_t ptr)
Set the pointer to the function to be run for the rule (if it is a raw read rule).
void SetInclude(const TString &include)
Set the comma separated list of header files to include to be able to compile this rule.
void AsString(TString &out, const char *options="") const
Add to the string 'out' the string representation of the 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...
void SetReadFunctionPointer(ReadFuncPtr_t ptr)
Set the pointer to the function to be run for the rule (if it is a read rule).
void ls(Option_t *option="") const override
The ls function lists the contents of a class on stdout.
std::vector< UInt_t > * fChecksumVect
! Source checksum vector (for searching purposes)
UInt_t ParseChecksum(const char *checksum) const
Parse the checksum in the given string.
static void ProcessList(TObjArray *array, const TString &list)
Split the list as a comma separated list into a TObjArray of TObjString.
Bool_t operator==(const TSchemaRule &rhs) const
Return true if the rule have the same effects.
Bool_t SetFromRule(const char *rule)
Set the content fot this object from the rule See TClass::AddRule for details on the syntax.
void Clear(Option_t *="") override
Zero out this rule object.
Bool_t TestVersion(Int_t version) const
Check if given version number is defined in this rule.
Bool_t HasSource(const TString &source) const
Return true if one of the rule's data member source is 'source'.
ReadRawFuncPtr_t GetReadRawFunctionPointer() const
Get the pointer to the function to be run for the rule (if it is a raw read rule).
const TObjArray * GetTarget() const
Get the target data members of this rule (i.e. the in memory data member).
Bool_t ProcessChecksum(const TString &checksum) const
Check if specified checksum string is correct and build checksum vector.
void(* ReadFuncPtr_t)(char *, TVirtualObject *)
Definition TSchemaRule.h:77
void SetEmbed(Bool_t embed)
Set whether this rule should be save in the ROOT file (if true).
RuleType_t GetRuleType() const
Return the type of the rule.
Bool_t Conflicts(const TSchemaRule *rule) const
Check if this rule conflicts with the given one.
TSchemaRule & operator=(const TSchemaRule &rhs)
Copy operator.
void SetTargetClass(const TString &classname)
Set the target class of this rule (i.e. the in memory class).
void(* ReadRawFuncPtr_t)(char *, TBuffer &)
Definition TSchemaRule.h:78
const char * GetSourceClass() const
Get the source class of this rule (i.e. the onfile class).
virtual ~TSchemaRule()
Destructor.
Bool_t TestChecksum(UInt_t checksum) const
Check if given checksum is defined in this rule.
Bool_t SetVersion(const TString &version)
Set the version string - returns kFALSE if the format is incorrect.
TObjArray * fTargetVect
! Target data member vector (for searching purposes)
void SetSource(const TString &source)
Set the list of source members.
Bool_t IsRenameRule() const
Return kTRUE if the rule is a strict renaming of the class to a new name.
void SetAttributes(const TString &attributes)
Set the attributes code of this rule.
Bool_t HasTarget(const TString &target) const
Return true if one of the rule's data member target is 'target'.
const char * GetTargetString() const
Get the target data members of this rule as a simple string (i.e. the in memory data member).
std::vector< std::pair< Int_t, Int_t > > * fVersionVect
! Source version vector (for searching purposes)
ReadRawFuncPtr_t fReadRawFuncPtr
! Conversion function pointer for readraw rule
RuleType_t fRuleType
Bool_t IsValid() const
Return kTRUE if this rule is valid.
ReadFuncPtr_t GetReadFunctionPointer() const
Get the pointer to the function to be run for the rule (if it is a read rule).
const char * GetVersion() const
Get the version string.
const char * GetAttributes() const
Get the attributes code of this rule.
Bool_t GetEmbed() const
Return true if this rule should be saved in the ROOT File.
const char * GetCode() const
Get the source code of this rule.
void SetSourceClass(const TString &classname)
Set the source class of this rule (i.e. the onfile class).
TSchemaRule()
Default Constructor.
Bool_t SetChecksum(const TString &checksum)
Set the checksum string - returns kFALSE if the format is incorrect.
const TObjArray * GetInclude() const
Return the list of header files to include to be able to compile this rule as a TObjArray of TObjStri...
Bool_t IsAliasRule() const
Return kTRUE if the rule is a strict renaming of one of the data member of the class.
const char * GetTargetClass() const
Get the targte class of this rule (i.e. the in memory class).
static void ProcessDeclaration(TObjArray *array, const TString &list)
Split the list as a declaration into as a TObjArray of TNamed(name,type).
Bool_t ProcessVersion(const TString &version) const
Check if specified version string is correct and build version vector.
Buffer base class used for serializing objects.
Definition TBuffer.h:43
TString fTitle
Definition TNamed.h:33
TNamed()
Definition TNamed.h:38
An array of TObjects.
Definition TObjArray.h:31
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1126
TObject()
TObject constructor.
Definition TObject.h:259
Basic string class.
Definition TString.h:138
Wrapper around an object and giving indirect access to its content even if the object is not of a cla...
if(pos!=-1) leafTypeName.Remove(pos)
The namespace of The Lean Mean C++ Option Parser.