Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:11

0001 // @(#)root/xml:$Id$
0002 // Author: Sergey Linev  10.05.2004
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TKeyXML
0013 #define ROOT_TKeyXML
0014 
0015 #include "TXMLEngine.h"
0016 #include "TKey.h"
0017 
0018 class TXMLFile;
0019 
0020 class TKeyXML final : public TKey {
0021 
0022 private:
0023    TKeyXML(const TKeyXML &) = delete;            // TKeyXML objects are not copiable.
0024    TKeyXML &operator=(const TKeyXML &) = delete; // TKeyXML objects are not copiable.
0025 
0026 protected:
0027    TKeyXML() {} // NOLINT: not allowed to use = default because of TObject::kIsOnHeap detection, see ROOT-10300
0028 
0029 public:
0030    TKeyXML(TDirectory *mother, Long64_t keyid, const TObject *obj, const char *name = nullptr,
0031            const char *title = nullptr);
0032    TKeyXML(TDirectory *mother, Long64_t keyid, const void *obj, const TClass *cl, const char *name,
0033            const char *title = nullptr);
0034    TKeyXML(TDirectory *mother, Long64_t keyid, XMLNodePointer_t keynode);
0035    ~TKeyXML() override;
0036 
0037    // redefined TKey Methods
0038    void Delete(Option_t *option = "") final;
0039    void DeleteBuffer() final {}
0040    void FillBuffer(char *&) final {}
0041    char *GetBuffer() const final { return nullptr; }
0042    Long64_t GetSeekKey() const final { return fKeyNode ? 1024 : 0; }
0043    Long64_t GetSeekPdir() const final { return fKeyNode ? 1024 : 0; }
0044    // virtual ULong_t   Hash() const { return 0; }
0045    void Keep() final {}
0046    // virtual void      ls(Option_t* ="") const;
0047    // virtual void      Print(Option_t* ="") const {}
0048 
0049    Int_t Read(TObject *tobj) final;
0050    TObject *ReadObj() final;
0051    TObject *ReadObjWithBuffer(char *bufferRead) final;
0052    void *ReadObjectAny(const TClass *expectedClass) final;
0053 
0054    void ReadBuffer(char *&) final {}
0055    Bool_t ReadFile() final { return kTRUE; }
0056    void SetBuffer() final { fBuffer = nullptr; }
0057    Int_t WriteFile(Int_t = 1, TFile * = nullptr) final { return 0; }
0058 
0059    // TKeyXML specific methods
0060 
0061    XMLNodePointer_t KeyNode() const { return fKeyNode; }
0062    Long64_t GetKeyId() const { return fKeyId; }
0063    Bool_t IsSubdir() const { return fSubdir; }
0064    void SetSubir() { fSubdir = kTRUE; }
0065    void UpdateObject(TObject *obj);
0066    void UpdateAttributes();
0067 
0068 protected:
0069    Int_t Read(const char *name) final { return TKey::Read(name); }
0070    void StoreObject(const void *obj, const TClass *cl, Bool_t check_tobj = kFALSE);
0071    void StoreKeyAttributes();
0072    TXMLEngine *XMLEngine();
0073 
0074    void *XmlReadAny(void *obj, const TClass *expectedClass);
0075 
0076    XMLNodePointer_t fKeyNode{nullptr}; //! node with stored object
0077    Long64_t fKeyId{0};                 //! unique identifier of key for search methods
0078    Bool_t fSubdir{kFALSE};             //! indicates that key contains subdirectory
0079 
0080    ClassDefOverride(TKeyXML, 1) // a special TKey for XML files
0081 };
0082 
0083 #endif