Logo ROOT   6.16/01
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
18class TXMLFile;
19
20class TKeyXML : public TKey {
21
22private:
23 TKeyXML(const TKeyXML &); // TKeyXML objects are not copiable.
24 TKeyXML &operator=(const TKeyXML &); // TKeyXML objects are not copiable.
25
26protected:
27 TKeyXML();
28
29public:
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,
32 const char *title = 0);
33 TKeyXML(TDirectory *mother, Long64_t keyid, XMLNodePointer_t keynode);
34 virtual ~TKeyXML();
35
36 // redefined TKey Methods
37 virtual void Delete(Option_t *option = "");
38 virtual void DeleteBuffer() {}
39 virtual void FillBuffer(char *&) {}
40 virtual char *GetBuffer() const { return 0; }
41 virtual Long64_t GetSeekKey() const { return fKeyNode ? 1024 : 0; }
42 virtual Long64_t GetSeekPdir() const { return fKeyNode ? 1024 : 0; }
43 // virtual ULong_t Hash() const { return 0; }
44 virtual void Keep() {}
45 // virtual void ls(Option_t* ="") const;
46 // virtual void Print(Option_t* ="") const {}
47
48 virtual Int_t Read(TObject *tobj);
49 virtual TObject *ReadObj();
50 virtual TObject *ReadObjWithBuffer(char *bufferRead);
51 virtual void *ReadObjectAny(const TClass *expectedClass);
52
53 virtual void ReadBuffer(char *&) {}
54 virtual Bool_t ReadFile() { return kTRUE; }
55 virtual void SetBuffer() { fBuffer = 0; }
56 virtual Int_t WriteFile(Int_t = 1, TFile * = 0) { return 0; }
57
58 // TKeyXML specific methods
59
60 XMLNodePointer_t KeyNode() const { return fKeyNode; }
61 Long64_t GetKeyId() const { return fKeyId; }
62 Bool_t IsSubdir() const { return fSubdir; }
63 void SetSubir() { fSubdir = kTRUE; }
64 void UpdateObject(TObject *obj);
65 void UpdateAttributes();
66
67protected:
68 virtual Int_t Read(const char *name) { return TKey::Read(name); }
69 void StoreObject(const void *obj, const TClass *cl, Bool_t check_tobj = kFALSE);
70 void StoreKeyAttributes();
72
73 void *XmlReadAny(void *obj, const TClass *expectedClass);
74
75 XMLNodePointer_t fKeyNode; //! node with stored object
76 Long64_t fKeyId; //! unique identifier of key for search methods
77 Bool_t fSubdir; //! indicates that key contains subdirectory
78
79 ClassDef(TKeyXML, 1) // a special TKey for XML files
80};
81
82#endif
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
long long Long64_t
Definition: RtypesCore.h:69
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:324
void * XMLNodePointer_t
Definition: TXMLEngine.h:17
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
Describe directory structure in memory.
Definition: TDirectory.h:34
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:48
virtual void ReadBuffer(char *&)
Decode input buffer.
Definition: TKeyXML.h:53
void UpdateObject(TObject *obj)
updates object, stored in the node Used for TDirectory data update
Definition: TKeyXML.cxx:223
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
Long64_t GetKeyId() const
Definition: TKeyXML.h:61
XMLNodePointer_t KeyNode() const
Definition: TKeyXML.h:60
virtual void Delete(Option_t *option="")
Delete key from current directory Note: TKeyXML object is not deleted.
Definition: TKeyXML.cxx:136
virtual Int_t Read(TObject *tobj)
To read an object from the file.
Definition: TKeyXML.cxx:250
XMLNodePointer_t fKeyNode
Definition: TKeyXML.h:75
Bool_t IsSubdir() const
Definition: TKeyXML.h:62
TXMLEngine * XMLEngine()
return pointer on TXMLEngine object, used for xml conversion
Definition: TKeyXML.cxx:394
virtual void * ReadObjectAny(const TClass *expectedClass)
read object of any type
Definition: TKeyXML.cxx:317
virtual void FillBuffer(char *&)
Encode key header into output buffer.
Definition: TKeyXML.h:39
virtual Long64_t GetSeekKey() const
Definition: TKeyXML.h:41
virtual Int_t Read(const char *name)
Read contents of object with specified name from the current directory.
Definition: TKeyXML.h:68
void * XmlReadAny(void *obj, const TClass *expectedClass)
read object from key and cast to expected class
Definition: TKeyXML.cxx:339
virtual ~TKeyXML()
TKeyXML destructor.
Definition: TKeyXML.cxx:119
virtual Long64_t GetSeekPdir() const
Definition: TKeyXML.h:42
virtual TObject * ReadObj()
read object derived from TObject class, from key if it is not TObject or in case of error,...
Definition: TKeyXML.cxx:264
TKeyXML & operator=(const TKeyXML &)
virtual char * GetBuffer() const
Definition: TKeyXML.h:40
virtual Int_t WriteFile(Int_t=1, TFile *=0)
Write the encoded object supported by this key.
Definition: TKeyXML.h:56
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:171
virtual void DeleteBuffer()
Delete key buffer(s).
Definition: TKeyXML.h:38
virtual void Keep()
Set the "KEEP" status.
Definition: TKeyXML.h:44
void UpdateAttributes()
update key attributes in key node
Definition: TKeyXML.cxx:208
TKeyXML()
default constructor
Definition: TKeyXML.cxx:32
void StoreKeyAttributes()
Stores keys attributes in key node.
Definition: TKeyXML.cxx:150
virtual Bool_t ReadFile()
Read the key structure from the file.
Definition: TKeyXML.h:54
Long64_t fKeyId
node with stored object
Definition: TKeyXML.h:76
void SetSubir()
Definition: TKeyXML.h:63
virtual void SetBuffer()
Definition: TKeyXML.h:55
TKeyXML(const TKeyXML &)
Bool_t fSubdir
unique identifier of key for search methods
Definition: TKeyXML.h:77
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:24
virtual Int_t Read(const char *name)
Read contents of object with specified name from the current directory.
Definition: TKey.h:49
char * fBuffer
Object buffer.
Definition: TKey.h:44
Mother of all ROOT objects.
Definition: TObject.h:37