ROOT  6.06/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 #ifndef ROOT_TXMLEngine
16 #include "TXMLEngine.h"
17 #endif
18 #ifndef ROOT_TKey
19 #include "TKey.h"
20 #endif
21 
22 class TXMLFile;
23 
24 class TKeyXML : public TKey {
25 
26 private:
27  TKeyXML(const TKeyXML&); // TKeyXML objects are not copiable.
28  TKeyXML& operator=(const TKeyXML&); // TKeyXML objects are not copiable.
29 
30 protected:
31  TKeyXML();
32 
33 public:
34  TKeyXML(TDirectory* mother, Long64_t keyid, const TObject* obj, const char* name = 0, const char* title = 0);
35  TKeyXML(TDirectory* mother, Long64_t keyid, const void* obj, const TClass* cl, const char* name, const char* title = 0);
36  TKeyXML(TDirectory* mother, Long64_t keyid, XMLNodePointer_t keynode);
37  virtual ~TKeyXML();
38 
39  // redefined TKey Methods
40  virtual void Delete(Option_t *option="");
41  virtual void DeleteBuffer() {}
42  virtual void FillBuffer(char *&) {}
43  virtual char *GetBuffer() const { return 0; }
44  virtual Long64_t GetSeekKey() const { return fKeyNode ? 1024 : 0;}
45  virtual Long64_t GetSeekPdir() const { return fKeyNode ? 1024 : 0;}
46  //virtual ULong_t Hash() const { return 0; }
47  virtual void Keep() {}
48  //virtual void ls(Option_t* ="") const;
49  //virtual void Print(Option_t* ="") const {}
50 
51  virtual Int_t Read(TObject* tobj);
52  virtual TObject *ReadObj();
53  virtual TObject *ReadObjWithBuffer(char *bufferRead);
54  virtual void *ReadObjectAny(const TClass *expectedClass);
55 
56  virtual void ReadBuffer(char *&) {}
57  virtual Bool_t ReadFile() { return kTRUE; }
58  virtual void SetBuffer() { fBuffer = 0; }
59  virtual Int_t WriteFile(Int_t =1, TFile* = 0) { return 0; }
60 
61  // TKeyXML specific methods
62 
63  XMLNodePointer_t KeyNode() const { return fKeyNode; }
64  Long64_t GetKeyId() const { return fKeyId; }
65  Bool_t IsSubdir() const { return fSubdir; }
66  void SetSubir() { fSubdir = kTRUE; }
67  void UpdateObject(TObject* obj);
68  void UpdateAttributes();
69 
70 protected:
71  virtual Int_t Read(const char *name) { return TKey::Read(name); }
72  void StoreObject(const void* obj, const TClass* cl);
73  void StoreKeyAttributes();
75 
76  void* XmlReadAny(void* obj, const TClass* expectedClass);
77 
78  XMLNodePointer_t fKeyNode; //! node with stored object
79  Long64_t fKeyId; //! unique identifier of key for search methods
80  Bool_t fSubdir; //! indicates that key contains subdirectory
81 
82  ClassDef(TKeyXML,1) // a special TKey for XML files
83 };
84 
85 #endif
void * XmlReadAny(void *obj, const TClass *expectedClass)
read object from key and cast to expected class
Definition: TKeyXML.cxx:316
void SetSubir()
Definition: TKeyXML.h:66
virtual Int_t Read(TObject *tobj)
To read an object from the file.
Definition: TKeyXML.cxx:244
long long Long64_t
Definition: RtypesCore.h:69
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:45
virtual Long64_t GetSeekKey() const
Definition: TKeyXML.h:44
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:283
Long64_t fKeyId
node with stored object
Definition: TKeyXML.h:79
int Int_t
Definition: RtypesCore.h:41
TXMLEngine * XMLEngine()
return pointer on TXMLEngine object, used for xml conversion
Definition: TKeyXML.cxx:366
bool Bool_t
Definition: RtypesCore.h:59
char * fBuffer
Object buffer.
Definition: TKey.h:50
TKeyXML()
default constructor
Definition: TKeyXML.cxx:33
virtual Long64_t GetSeekPdir() const
Definition: TKeyXML.h:45
XMLNodePointer_t fKeyNode
Definition: TKeyXML.h:78
virtual void * ReadObjectAny(const TClass *expectedClass)
read object of any type
Definition: TKeyXML.cxx:308
virtual void Keep()
Set the "KEEP" status.
Definition: TKeyXML.h:47
ClassDef(TKey, 4)
virtual Int_t WriteFile(Int_t=1, TFile *=0)
Write the encoded object supported by this key.
Definition: TKeyXML.h:59
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:30
virtual void DeleteBuffer()
Delete key buffer(s).
Definition: TKeyXML.h:41
Bool_t fSubdir
unique identifier of key for search methods
Definition: TKeyXML.h:80
virtual TObject * ReadObj()
read object derived from TObject class, from key if it is not TObject or in case of error...
Definition: TKeyXML.cxx:257
void UpdateAttributes()
update key attributes in key node
Definition: TKeyXML.cxx:205
void UpdateObject(TObject *obj)
updates object, stored in the node Used for TDirectory data update
Definition: TKeyXML.cxx:219
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:81
void * XMLNodePointer_t
Definition: TXMLEngine.h:19
virtual Int_t Read(const char *name)
Read contents of object with specified name from the current directory.
Definition: TKeyXML.h:71
virtual Bool_t ReadFile()
Read the key structure from the file.
Definition: TKeyXML.h:57
void StoreObject(const void *obj, const TClass *cl)
convert object to xml structure and keep this structure in key
Definition: TKeyXML.cxx:180
Describe directory structure in memory.
Definition: TDirectory.h:41
TKeyXML & operator=(const TKeyXML &)
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
virtual void SetBuffer()
Definition: TKeyXML.h:58
XMLNodePointer_t KeyNode() const
Definition: TKeyXML.h:63
Long64_t GetKeyId() const
Definition: TKeyXML.h:64
Bool_t IsSubdir() const
Definition: TKeyXML.h:65
virtual void ReadBuffer(char *&)
Decode input buffer.
Definition: TKeyXML.h:56
virtual Int_t Read(const char *name)
Read contents of object with specified name from the current directory.
Definition: TKey.h:55
const Bool_t kTRUE
Definition: Rtypes.h:91
TObject * obj
virtual void FillBuffer(char *&)
Encode key header into output buffer.
Definition: TKeyXML.h:42
virtual char * GetBuffer() const
Definition: TKeyXML.h:43