xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XrdSutBuffer.hh
Go to the documentation of this file.
1 #ifndef __SUT_BUFFER_H__
2 #define __SUT_BUFFER_H__
3 /******************************************************************************/
4 /* */
5 /* X r d S u t B u f f e r . h h */
6 /* */
7 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* Produced by Geri Ganis for CERN */
9 /* */
10 /* This file is part of the XRootD software suite. */
11 /* */
12 /* XRootD is free software: you can redistribute it and/or modify it under */
13 /* the terms of the GNU Lesser General Public License as published by the */
14 /* Free Software Foundation, either version 3 of the License, or (at your */
15 /* option) any later version. */
16 /* */
17 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
18 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
19 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
20 /* License for more details. */
21 /* */
22 /* You should have received a copy of the GNU Lesser General Public License */
23 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
24 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
25 /* */
26 /* The copyright holder's institutional names and contributor's names may not */
27 /* be used to endorse or promote products derived from this software without */
28 /* specific prior written permission of the institution or contributor. */
29 /******************************************************************************/
30 
31 #ifndef __SUT_BUCKLIST_H__
32 #include "XrdSut/XrdSutBuckList.hh"
33 #endif
34 
35 /******************************************************************************/
36 /* */
37 /* Buffer structure for managing exchanged buckets */
38 /* */
39 /******************************************************************************/
40 
41 class XrdOucString;
42 
43 class XrdSutBuffer {
44 
45 private:
46 
51 
52 public:
53  XrdSutBuffer(const char *prot, const char *opts = 0)
54  {fOptions = opts; fProtocol = prot; fStep = 0;}
55  XrdSutBuffer(const char *buffer, kXR_int32 length);
56 
57  virtual ~XrdSutBuffer();
58 
59  int AddBucket(char *bp=0, int sz=0, int ty=0)
60  { XrdSutBucket *b = new XrdSutBucket(bp,sz,ty);
61  if (b) { fBuckets.PushBack(b); return 0;} return -1; }
62  int AddBucket(XrdOucString s, int ty=0)
63  { XrdSutBucket *b = new XrdSutBucket(s,ty);
64  if (b) { fBuckets.PushBack(b); return 0;} return -1; }
66  { if (b) { fBuckets.PushBack(b); return 0;} return -1; }
67 
68  int UpdateBucket(const char *bp, int sz, int ty);
69  int UpdateBucket(XrdOucString s, int ty);
70 
71  // Remove from the list, to avoid destroy by ~XrdSutBuffer
73 
74  void Dump(const char *stepstr = 0, bool all = false);
75  void Message(const char *prepose = 0);
76  int Serialized(char **buffer, char opt = 'n');
77 
78  void Deactivate(kXR_int32 type); // Deactivate bucket (type=-1 for cleanup)
79 
80  // To fill / access buckets containing 4-byte integers (status codes, versions ...)
83 
84  XrdSutBucket *GetBucket(kXR_int32 type, const char *tag = 0);
86  int GetNBuckets() const { return fBuckets.Size(); }
87  const char *GetOptions() const { return fOptions.c_str(); }
88  const char *GetProtocol() const { return fProtocol.c_str(); }
89  int GetStep() const { return (int)fStep; }
90  void SetStep(int s) { fStep = (kXR_int32)s; }
91  void IncrementStep() { fStep++; }
92 };
93 
94 #endif
95 
void IncrementStep()
Definition: XrdSutBuffer.hh:91
int GetStep() const
Definition: XrdSutBuffer.hh:89
kXR_int32 MarshalBucket(kXR_int32 type, kXR_int32 code)
const char * c_str() const
Definition: XrdOucString.hh:280
int Serialized(char **buffer, char opt= 'n')
int AddBucket(XrdSutBucket *b)
Definition: XrdSutBuffer.hh:65
void PushBack(XrdSutBucket *b)
void SetStep(int s)
Definition: XrdSutBuffer.hh:90
void Remove(XrdSutBucket *b)
virtual ~XrdSutBuffer()
int UpdateBucket(const char *bp, int sz, int ty)
Definition: XrdSutBuffer.hh:43
kXR_int32 UnmarshalBucket(kXR_int32 type, kXR_int32 &code)
XrdSutBuckList fBuckets
Definition: XrdSutBuffer.hh:47
void Remove(XrdSutBucket *b)
Definition: XrdSutBuffer.hh:72
XrdSutBucket * GetBucket(kXR_int32 type, const char *tag=0)
void Message(const char *prepose=0)
int Size() const
Definition: XrdSutBuckList.hh:77
int GetNBuckets() const
Definition: XrdSutBuffer.hh:86
int AddBucket(XrdOucString s, int ty=0)
Definition: XrdSutBuffer.hh:62
XrdOucString fProtocol
Definition: XrdSutBuffer.hh:49
XrdOucString fOptions
Definition: XrdSutBuffer.hh:48
XrdSutBuffer(const char *prot, const char *opts=0)
Definition: XrdSutBuffer.hh:53
int AddBucket(char *bp=0, int sz=0, int ty=0)
Definition: XrdSutBuffer.hh:59
const char * GetProtocol() const
Definition: XrdSutBuffer.hh:88
Definition: XrdSutBucket.hh:43
void Deactivate(kXR_int32 type)
int kXR_int32
Definition: XPtypes.hh:89
kXR_int32 fStep
Definition: XrdSutBuffer.hh:50
void Dump(const char *stepstr=0, bool all=false)
Definition: XrdSutBuckList.hh:61
XrdSutBuckList * GetBuckList() const
Definition: XrdSutBuffer.hh:85
Definition: XrdOucString.hh:254
const char * GetOptions() const
Definition: XrdSutBuffer.hh:87