// @(#)root/sql:$Id$
// Author: Sergey Linev  20/11/2005

/*************************************************************************
 * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/


#ifndef ROOT_TKeySQL
#define ROOT_TKeySQL


/////////////////////////////////////////////////////////////////////////
//                                                                     //
// TKeySQL is TKey class from TSQLFile                                 //
//                                                                     //
/////////////////////////////////////////////////////////////////////////


#ifndef ROOT_TKey
#include "TKey.h"
#endif

class TSQLFile;

class TKeySQL : public TKey {

private:
   TKeySQL(const TKeySQL&);            // TKeySQL objects are not copiable.
   TKeySQL& operator=(const TKeySQL&); // TKeySQL objects are not copiable.

protected:
   TKeySQL();

   virtual Int_t     Read(const char *name) { return TKey::Read(name); }
   void              StoreKeyObject(const void* obj, const TClass* cl);
   void*             ReadKeyObject(void* obj, const TClass* expectedClass);

   Long64_t          fKeyId;    //!  key identifier in KeysTables
   Long64_t          fObjId;    //!  stored object identifer

public:
   TKeySQL(TDirectory* mother, const TObject* obj, const char* name, const char* title = 0);
   TKeySQL(TDirectory* mother, const void* obj, const TClass* cl, const char* name, const char* title = 0);
   TKeySQL(TDirectory* mother, Long64_t keyid, Long64_t objid,
           const char* name, const char* title,
           const char* keydatetime, Int_t cycle, const char* classname);
   virtual ~TKeySQL();

   Bool_t            IsKeyModified(const char* keyname, const char* keytitle, const char* keydatime, Int_t cycle, const char* classname);

   Long64_t          GetDBKeyId() const { return fKeyId; }
   Long64_t          GetDBObjId() const { return fObjId; }
   Long64_t          GetDBDirId() const;

   // redefined TKey Methods
   virtual void      Delete(Option_t *option="");
   virtual void      DeleteBuffer() {}
   virtual void      FillBuffer(char *&) {}
   virtual char     *GetBuffer() const { return 0; }
   virtual Long64_t  GetSeekKey() const  { return GetDBObjId() > 0 ? GetDBObjId() : 0; }
   virtual Long64_t  GetSeekPdir() const { return GetDBDirId() > 0 ? GetDBDirId() : 0; }
   virtual void      Keep() {}

   virtual Int_t     Read(TObject* obj);
   virtual TObject  *ReadObj();
   virtual TObject  *ReadObjWithBuffer(char *bufferRead);
   virtual void     *ReadObjectAny(const TClass *expectedClass);

   virtual void      ReadBuffer(char *&) {}
   virtual Bool_t    ReadFile() { return kTRUE; }
   virtual void      SetBuffer() { fBuffer = 0; }
   virtual Int_t     WriteFile(Int_t =1, TFile* = 0) { return 0; }

   ClassDef(TKeySQL,1) // a special TKey for SQL data base
};

#endif
 TKeySQL.h:1
 TKeySQL.h:2
 TKeySQL.h:3
 TKeySQL.h:4
 TKeySQL.h:5
 TKeySQL.h:6
 TKeySQL.h:7
 TKeySQL.h:8
 TKeySQL.h:9
 TKeySQL.h:10
 TKeySQL.h:11
 TKeySQL.h:12
 TKeySQL.h:13
 TKeySQL.h:14
 TKeySQL.h:15
 TKeySQL.h:16
 TKeySQL.h:17
 TKeySQL.h:18
 TKeySQL.h:19
 TKeySQL.h:20
 TKeySQL.h:21
 TKeySQL.h:22
 TKeySQL.h:23
 TKeySQL.h:24
 TKeySQL.h:25
 TKeySQL.h:26
 TKeySQL.h:27
 TKeySQL.h:28
 TKeySQL.h:29
 TKeySQL.h:30
 TKeySQL.h:31
 TKeySQL.h:32
 TKeySQL.h:33
 TKeySQL.h:34
 TKeySQL.h:35
 TKeySQL.h:36
 TKeySQL.h:37
 TKeySQL.h:38
 TKeySQL.h:39
 TKeySQL.h:40
 TKeySQL.h:41
 TKeySQL.h:42
 TKeySQL.h:43
 TKeySQL.h:44
 TKeySQL.h:45
 TKeySQL.h:46
 TKeySQL.h:47
 TKeySQL.h:48
 TKeySQL.h:49
 TKeySQL.h:50
 TKeySQL.h:51
 TKeySQL.h:52
 TKeySQL.h:53
 TKeySQL.h:54
 TKeySQL.h:55
 TKeySQL.h:56
 TKeySQL.h:57
 TKeySQL.h:58
 TKeySQL.h:59
 TKeySQL.h:60
 TKeySQL.h:61
 TKeySQL.h:62
 TKeySQL.h:63
 TKeySQL.h:64
 TKeySQL.h:65
 TKeySQL.h:66
 TKeySQL.h:67
 TKeySQL.h:68
 TKeySQL.h:69
 TKeySQL.h:70
 TKeySQL.h:71
 TKeySQL.h:72
 TKeySQL.h:73
 TKeySQL.h:74
 TKeySQL.h:75
 TKeySQL.h:76
 TKeySQL.h:77
 TKeySQL.h:78
 TKeySQL.h:79
 TKeySQL.h:80
 TKeySQL.h:81
 TKeySQL.h:82