xrootd
XrdCksManager.hh
Go to the documentation of this file.
00001 #ifndef __XRDCKSMANAGER_HH__
00002 #define __XRDCKSMANAGER_HH__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                      X r d C k s M a n a g e r . h h                       */
00006 /*                                                                            */
00007 /* (c) 2011 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*                            All Rights Reserved                             */
00009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012 
00013 #include "XrdCks/XrdCks.hh"
00014 #include "XrdCks/XrdCksData.hh"
00015 
00016 /* This class defines the checksum management interface. It may also be used
00017    as the base class for a plugin. This allows you to replace selected methods
00018    which may be needed for handling certain filesystems (see protected ones).
00019 */
00020 
00021 class XrdCksCalc;
00022 class XrdSysError;
00023   
00024 class XrdCksManager : public XrdCks
00025 {
00026 public:
00027 virtual int         Calc( const char *Pfn, XrdCksData &Cks, int doSet=1);
00028 
00029 virtual int         Config(const char *Token, char *Line);
00030 
00031 virtual int         Del(  const char *Pfn, XrdCksData &Cks);
00032 
00033 virtual int         Get(  const char *Pfn, XrdCksData &Cks);
00034 
00035 virtual int         Init(const char *ConfigFN, const char *AddCalc=0);
00036 
00037 virtual char       *List(const char *Pfn, char *Buff, int Blen, char Sep=' ');
00038 
00039 virtual const char *Name(int seqNum=0);
00040 
00041 virtual int         Size( const char  *Name=0);
00042 
00043 virtual int         Set(  const char *Pfn, XrdCksData &Cks, int myTime=0);
00044 
00045 virtual int         Ver(  const char *Pfn, XrdCksData &Cks);
00046 
00047                     XrdCksManager(XrdSysError *erP, int iosz=0);
00048 virtual            ~XrdCksManager();
00049 
00050 protected:
00051 
00052 /* Calc()     returns 0 if the checksum was successfully calculated using the
00053               supplied CksObj and places the file's modification time in MTime.
00054               Otherwise, it returns -errno. The default implementation uses
00055               open(), fstat(), mmap(), and unmap() to calculate the results.
00056 */
00057 virtual int         Calc(const char *Pfn, time_t &MTime, XrdCksCalc *CksObj);
00058 
00059 /* ModTime()  returns 0 and places file's modification time in MTime. Otherwise,
00060               it return -errno. The default implementation uses stat().
00061 */
00062 virtual int         ModTime(const char *Pfn, time_t &MTime);
00063 
00064 private:
00065 
00066 struct csInfo
00067       {char          Name[XrdCksData::NameSize];
00068        XrdCksCalc   *Obj;
00069        char         *Path;
00070        char         *Parms;
00071        XrdSysPlugin *Plugin;
00072        int           Len;
00073                      csInfo() : Obj(0), Path(0), Parms(0), Plugin(0), Len(0)
00074                                 {memset(Name, 0, sizeof(Name));}
00075       };
00076 
00077 int     Config(const char *cFN, csInfo &Info);
00078 csInfo *Find(const char *Name);
00079 
00080 static const int csMax = 4;
00081 csInfo           csTab[csMax];
00082 int              csLast;
00083 int              segSize;
00084 };
00085 #endif