File indexing completed on 2025-09-18 09:34:10
0001
0002
0003
0004 #ifndef ROOT_TSchemaRule
0005 #define ROOT_TSchemaRule
0006
0007 #include "TNamed.h"
0008 #include "TString.h"
0009
0010 #include <vector>
0011 #include <utility>
0012
0013 class TBuffer;
0014 class TVirtualObject;
0015 class TObjArray;
0016 namespace ROOT {
0017 namespace Internal {
0018 struct TSchemaHelper;
0019 }
0020 }
0021
0022 namespace ROOT {
0023
0024 class TSchemaRule : public TObject
0025 {
0026 public:
0027
0028 class TSources : public TNamed {
0029 private:
0030 TString fDimensions;
0031 Int_t fPointerLevel = 0;
0032
0033 public:
0034 TSources(const char *name = nullptr, const char *title = nullptr, const char *dims = nullptr)
0035 : TNamed(name, title), fDimensions(dims)
0036 {
0037 if (fTitle.Length())
0038 while (fTitle[fTitle.Length() - fPointerLevel - 1] == '*')
0039 ++fPointerLevel;
0040 if (fPointerLevel)
0041 fTitle.Remove(fTitle.Length() - fPointerLevel);
0042 }
0043
0044 const char *GetDimensions() const { return fDimensions; }
0045
0046 bool IsPointer() const { return fPointerLevel > 0; }
0047
0048 Int_t GetPointerLevel() const { return fPointerLevel; }
0049
0050 const char *GetUnderlyingTypeName() const { return fTitle; }
0051
0052
0053
0054 TString GetTypeForDeclaration()
0055 {
0056 TString type = fTitle;
0057 for (Int_t s = 0; s < fPointerLevel; ++s)
0058 type.Append('*');
0059 return type;
0060 }
0061
0062 void SetTitle(const char *) override
0063 {
0064 Fatal("SetTitle", "Changing the type represented by a TSources is not supported.");
0065 }
0066
0067 ClassDefOverride(TSources, 3);
0068 };
0069
0070 typedef enum
0071 {
0072 kReadRule = 0,
0073 kReadRawRule = 1,
0074 kNone = 99999
0075 } RuleType_t;
0076
0077 typedef void (*ReadFuncPtr_t)( char*, TVirtualObject* );
0078 typedef void (*ReadRawFuncPtr_t)( char*, TBuffer&);
0079
0080 TSchemaRule();
0081 TSchemaRule(RuleType_t type, const char *targetClass, const ROOT::Internal::TSchemaHelper &helper);
0082 virtual ~TSchemaRule();
0083
0084 TSchemaRule( const TSchemaRule& rhs );
0085 TSchemaRule& operator = ( const TSchemaRule& rhs );
0086 Bool_t operator == ( const TSchemaRule& rhs ) const;
0087
0088
0089 void Clear(Option_t * ="") override;
0090 Bool_t SetFromRule( const char *rule );
0091
0092 const char *GetVersion( ) const;
0093 Bool_t SetVersion( const TString& version );
0094 Bool_t TestVersion( Int_t version ) const;
0095 Bool_t SetChecksum( const TString& checksum );
0096 Bool_t TestChecksum( UInt_t checksum ) const;
0097 void SetSourceClass( const TString& classname );
0098 const char *GetSourceClass() const;
0099 void SetTargetClass( const TString& classname );
0100 const char *GetTargetClass() const;
0101 void SetTarget( const TString& target );
0102 const TObjArray* GetTarget() const;
0103 const char *GetTargetString() const;
0104 void SetSource( const TString& source );
0105 const TObjArray* GetSource() const;
0106 void SetEmbed( Bool_t embed );
0107 Bool_t GetEmbed() const;
0108 Bool_t IsAliasRule() const;
0109 Bool_t IsRenameRule() const;
0110 Bool_t IsValid() const;
0111 void SetCode( const TString& code );
0112 const char *GetCode() const;
0113 void SetAttributes( const TString& attributes );
0114 const char *GetAttributes() const;
0115 Bool_t HasTarget( const TString& target ) const;
0116
0117 Bool_t HasSource( const TString& source ) const;
0118 void SetReadFunctionPointer( ReadFuncPtr_t ptr );
0119 ReadFuncPtr_t GetReadFunctionPointer() const;
0120 void SetReadRawFunctionPointer( ReadRawFuncPtr_t ptr );
0121 ReadRawFuncPtr_t GetReadRawFunctionPointer() const;
0122 void SetInclude( const TString& include );
0123 const TObjArray* GetInclude() const;
0124 void SetRuleType( RuleType_t type );
0125 RuleType_t GetRuleType() const;
0126 Bool_t Conflicts( const TSchemaRule* rule ) const;
0127
0128 void AsString( TString &out, const char *options = "" ) const;
0129 void ls(Option_t *option="") const override;
0130
0131 private:
0132
0133 Bool_t ProcessVersion( const TString& version ) const;
0134 Bool_t ProcessChecksum( const TString& checksum ) const;
0135 UInt_t ParseChecksum( const char* checksum ) const;
0136 static void ProcessList( TObjArray* array, const TString& list );
0137 static void ProcessDeclaration( TObjArray* array, const TString& list );
0138
0139 TString fVersion;
0140 mutable std::vector<std::pair<Int_t, Int_t> >* fVersionVect;
0141 TString fChecksum;
0142 mutable std::vector<UInt_t>* fChecksumVect;
0143 TString fSourceClass;
0144 TString fTargetClass;
0145 TString fTarget;
0146 mutable TObjArray* fTargetVect;
0147 TString fSource;
0148 mutable TObjArray* fSourceVect;
0149 TString fInclude;
0150 mutable TObjArray* fIncludeVect;
0151 TString fCode;
0152 Bool_t fEmbed;
0153 ReadFuncPtr_t fReadFuncPtr;
0154 ReadRawFuncPtr_t fReadRawFuncPtr;
0155 RuleType_t fRuleType;
0156 TString fAttributes;
0157
0158 ClassDefOverride( TSchemaRule, 1 );
0159
0160 };
0161 }
0162
0163 #endif