XrdSutBuffer.hh

Go to the documentation of this file.
00001 // $Id: XrdSutBuffer.hh 22437 2008-03-04 14:35:16Z rdm $
00002 #ifndef __SUT_BUFFER_H__
00003 #define __SUT_BUFFER_H__
00004 /******************************************************************************/
00005 /*                                                                            */
00006 /*                      X r d S u t B u f f e r . h h                         */
00007 /*                                                                            */
00008 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University  */
00009 /*       All Rights Reserved. See XrdInfo.cc for complete License Terms       */
00010 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00011 /*              DE-AC03-76-SFO0515 with the Department of Energy              */
00012 /******************************************************************************/
00013 
00014 #ifndef __SUT_BUCKLIST_H__
00015 #include <XrdSut/XrdSutBuckList.hh>
00016 #endif
00017 
00018 /******************************************************************************/
00019 /*                                                                            */
00020 /*  Buffer structure for managing exchanged buckets                           */
00021 /*                                                                            */
00022 /******************************************************************************/
00023 
00024 class XrdOucString;
00025 
00026 class XrdSutBuffer {
00027 
00028 private:
00029    
00030    XrdSutBuckList         fBuckets;
00031    XrdOucString           fOptions;
00032    XrdOucString           fProtocol;
00033    kXR_int32              fStep;
00034 
00035 public:
00036    XrdSutBuffer(const char *prot, const char *opts = 0)
00037                  {fOptions = opts; fProtocol = prot; fStep = 0;}
00038    XrdSutBuffer(const char *buffer, kXR_int32 length);
00039 
00040    virtual ~XrdSutBuffer();
00041 
00042    int         AddBucket(char *bp=0, int sz=0, int ty=0) 
00043                  { XrdSutBucket *b = new XrdSutBucket(bp,sz,ty);
00044                    if (b) { fBuckets.PushBack(b); return 0;} return -1; }
00045    int         AddBucket(XrdOucString s, int ty=0) 
00046                  { XrdSutBucket *b = new XrdSutBucket(s,ty);
00047                    if (b) { fBuckets.PushBack(b); return 0;} return -1; }
00048    int         AddBucket(XrdSutBucket *b) 
00049                  { if (b) { fBuckets.PushBack(b); return 0;} return -1; }
00050 
00051    int         UpdateBucket(const char *bp, int sz, int ty); 
00052    int         UpdateBucket(XrdOucString s, int ty);
00053 
00054    // Remove from the list, to avoid destroy by ~XrdSutBuffer
00055    void        Remove(XrdSutBucket *b) { fBuckets.Remove(b); }
00056 
00057    void        Dump(const char *stepstr = 0);
00058    void        Message(const char *prepose = 0);
00059    int         Serialized(char **buffer, char opt = 'n');
00060 
00061    void        Deactivate(kXR_int32 type);  // Deactivate bucket (type=-1 for cleanup)
00062 
00063    // To fill / access buckets containing 4-byte integers (status codes, versions ...)
00064    kXR_int32   MarshalBucket(kXR_int32 type, kXR_int32 code);
00065    kXR_int32   UnmarshalBucket(kXR_int32 type, kXR_int32 &code);
00066 
00067    XrdSutBucket *GetBucket(kXR_int32 type, const char *tag = 0);
00068    XrdSutBuckList *GetBuckList() const { return (XrdSutBuckList *)&fBuckets; }
00069    int         GetNBuckets() const     { return fBuckets.Size(); }
00070    const char *GetOptions() const      { return fOptions.c_str(); }
00071    const char *GetProtocol() const     { return fProtocol.c_str(); }
00072    int         GetStep() const         { return (int)fStep; }
00073    void        SetStep(int s)   { fStep = (kXR_int32)s; }
00074    void        IncrementStep()  { fStep++; }
00075 };
00076 
00077 #endif
00078 

Generated on Tue Jul 5 14:47:02 2011 for ROOT_528-00b_version by  doxygen 1.5.1