Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:34:10

0001 // @(#)root/core:$Id$
0002 // author: Lukasz Janyst <ljanyst@cern.ch>
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 } // namespace ROOT
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             // The source can be declared with:
0053             //   "%s %s%s;", GetTypeForDeclaration().Data(), GetName(), GetDimensions);
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 * /*option*/ ="") 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;        //  Source version string
0140          mutable std::vector<std::pair<Int_t, Int_t> >* fVersionVect;    //! Source version vector (for searching purposes)
0141          TString                      fChecksum;       //  Source checksum string
0142          mutable std::vector<UInt_t>* fChecksumVect;   //! Source checksum vector (for searching purposes)
0143          TString                      fSourceClass;    //  Source class
0144          TString                      fTargetClass;    //  Target class, this is the owner of this rule object.
0145          TString                      fTarget;         //  Target data mamber string
0146          mutable TObjArray*           fTargetVect;     //! Target data member vector (for searching purposes)
0147          TString                      fSource;         //  Source data member string
0148          mutable TObjArray*           fSourceVect;     //! Source data member vector (for searching purposes)
0149          TString                      fInclude;        //  Includes string
0150          mutable TObjArray*           fIncludeVect;    //! Includes vector
0151          TString                      fCode;           //  User specified code snippet
0152          Bool_t                       fEmbed;          //  Value determining if the rule should be embedded
0153          ReadFuncPtr_t                fReadFuncPtr;    //! Conversion function pointer for read rule
0154          ReadRawFuncPtr_t             fReadRawFuncPtr; //! Conversion function pointer for readraw rule
0155          RuleType_t                   fRuleType;       //  Type of the rule
0156          TString                      fAttributes;     //  Attributes to be applied to the member (like Owner/NotOwner)
0157 
0158       ClassDefOverride( TSchemaRule, 1 );
0159 
0160    };
0161 } // End of namespace ROOT
0162 
0163 #endif // ROOT_TSchemaRule