Logo ROOT   6.10/09
Reference Guide
TKeyXML.h
Go to the documentation of this file.
1 // @(#)root/xml:$Id$
2 // Author: Sergey Linev 10.05.2004
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TKeyXML
13 #define ROOT_TKeyXML
14 
15 #include "TXMLEngine.h"
16 #include "TKey.h"
17 
18 class TXMLFile;
19 
20 class TKeyXML : public TKey {
21 
22 private:
23  TKeyXML(const TKeyXML&); // TKeyXML objects are not copiable.
24  TKeyXML& operator=(const TKeyXML&); // TKeyXML objects are not copiable.
25 
26 protected:
27  TKeyXML();
28 
29 public:
30  TKeyXML(TDirectory* mother, Long64_t keyid, const TObject* obj, const char* name = 0, const char* title = 0);
31  TKeyXML(TDirectory* mother, Long64_t keyid, const void* obj, const TClass* cl, const char* name, const char* title = 0);
32  TKeyXML(TDirectory* mother, Long64_t keyid, XMLNodePointer_t keynode);
33  virtual ~TKeyXML();
34 
35  // redefined TKey Methods
36  virtual void Delete(Option_t *option="");
37  virtual void DeleteBuffer() {}
38  virtual void FillBuffer(char *&) {}
39  virtual char *GetBuffer() const { return 0; }
40  virtual Long64_t GetSeekKey() const { return fKeyNode ? 1024 : 0;}
41  virtual Long64_t GetSeekPdir() const { return fKeyNode ? 1024 : 0;}
42  //virtual ULong_t Hash() const { return 0; }
43  virtual void Keep() {}
44  //virtual void ls(Option_t* ="") const;
45  //virtual void Print(Option_t* ="") const {}
46 
47  virtual Int_t Read(TObject* tobj);
48  virtual TObject *ReadObj();
49  virtual TObject *ReadObjWithBuffer(char *bufferRead);
50  virtual void *ReadObjectAny(const TClass *expectedClass);
51 
52  virtual void ReadBuffer(char *&) {}
53  virtual Bool_t ReadFile() { return kTRUE; }
54  virtual void SetBuffer() { fBuffer = 0; }
55  virtual Int_t WriteFile(Int_t =1, TFile* = 0) { return 0; }
56 
57  // TKeyXML specific methods
58 
59  XMLNodePointer_t KeyNode() const { return fKeyNode; }
60  Long64_t GetKeyId() const { return fKeyId; }
61  Bool_t IsSubdir() const { return fSubdir; }
62  void SetSubir() { fSubdir = kTRUE; }
63  void UpdateObject(TObject* obj);
64  void UpdateAttributes();
65 
66 protected:
67  virtual Int_t Read(const char *name) { return TKey::Read(name); }
68  void StoreObject(const void* obj, const TClass* cl, Bool_t check_tobj = kFALSE);
69  void StoreKeyAttributes();
71 
72  void* XmlReadAny(void* obj, const TClass* expectedClass);
73 
74  XMLNodePointer_t fKeyNode; //! node with stored object
75  Long64_t fKeyId; //! unique identifier of key for search methods
76  Bool_t fSubdir; //! indicates that key contains subdirectory
77 
78  ClassDef(TKeyXML,1) // a special TKey for XML files
79 };
80 
81 #endif
void * XmlReadAny(void *obj, const TClass *expectedClass)
read object from key and cast to expected class
Definition: TKeyXML.cxx:324
void SetSubir()
Definition: TKeyXML.h:62
virtual Int_t Read(TObject *tobj)
To read an object from the file.
Definition: TKeyXML.cxx:252
long long Long64_t
Definition: RtypesCore.h:69
Long64_t GetKeyId() const
Definition: TKeyXML.h:60
virtual ~TKeyXML()
TKeyXML destructor.
Definition: TKeyXML.cxx:129
const char Option_t
Definition: RtypesCore.h:62
void StoreKeyAttributes()
Stores keys attributes in key node.
Definition: TKeyXML.cxx:160
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:46
virtual TObject * ReadObjWithBuffer(char *bufferRead)
read object derived from TObject class, from key if it is not TObject or in case of error...
Definition: TKeyXML.cxx:291
XMLNodePointer_t KeyNode() const
Definition: TKeyXML.h:59
Long64_t fKeyId
node with stored object
Definition: TKeyXML.h:75
int Int_t
Definition: RtypesCore.h:41
TXMLEngine * XMLEngine()
return pointer on TXMLEngine object, used for xml conversion
Definition: TKeyXML.cxx:374
bool Bool_t
Definition: RtypesCore.h:59
char * fBuffer
Object buffer.
Definition: TKey.h:44
TKeyXML()
default constructor
Definition: TKeyXML.cxx:33
Bool_t IsSubdir() const
Definition: TKeyXML.h:61
virtual Long64_t GetSeekPdir() const
Definition: TKeyXML.h:41
#define ClassDef(name, id)
Definition: Rtypes.h:297
XMLNodePointer_t fKeyNode
Definition: TKeyXML.h:74
virtual void * ReadObjectAny(const TClass *expectedClass)
read object of any type
Definition: TKeyXML.cxx:316
virtual void Keep()
Set the "KEEP" status.
Definition: TKeyXML.h:43
virtual Int_t WriteFile(Int_t=1, TFile *=0)
Write the encoded object supported by this key.
Definition: TKeyXML.h:55
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:24
virtual void DeleteBuffer()
Delete key buffer(s).
Definition: TKeyXML.h:37
Bool_t fSubdir
unique identifier of key for search methods
Definition: TKeyXML.h:76
virtual TObject * ReadObj()
read object derived from TObject class, from key if it is not TObject or in case of error...
Definition: TKeyXML.cxx:265
virtual char * GetBuffer() const
Definition: TKeyXML.h:39
void UpdateAttributes()
update key attributes in key node
Definition: TKeyXML.cxx:213
void UpdateObject(TObject *obj)
updates object, stored in the node Used for TDirectory data update
Definition: TKeyXML.cxx:227
void StoreObject(const void *obj, const TClass *cl, Bool_t check_tobj=kFALSE)
convert object to xml structure and keep this structure in key
Definition: TKeyXML.cxx:180
virtual void Delete(Option_t *option="")
Delete key from current directory Note: TKeyXML object is not deleted.
Definition: TKeyXML.cxx:146
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:71
void * XMLNodePointer_t
Definition: TXMLEngine.h:17
const Bool_t kFALSE
Definition: RtypesCore.h:92
virtual Int_t Read(const char *name)
Read contents of object with specified name from the current directory.
Definition: TKeyXML.h:67
virtual Bool_t ReadFile()
Read the key structure from the file.
Definition: TKeyXML.h:53
Describe directory structure in memory.
Definition: TDirectory.h:34
TKeyXML & operator=(const TKeyXML &)
virtual Long64_t GetSeekKey() const
Definition: TKeyXML.h:40
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void SetBuffer()
Definition: TKeyXML.h:54
virtual void ReadBuffer(char *&)
Decode input buffer.
Definition: TKeyXML.h:52
virtual Int_t Read(const char *name)
Read contents of object with specified name from the current directory.
Definition: TKey.h:49
const Bool_t kTRUE
Definition: RtypesCore.h:91
virtual void FillBuffer(char *&)
Encode key header into output buffer.
Definition: TKeyXML.h:38