XrdClientMessage.hh

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////
00002 //                                                                      //
00003 // XrdClientMessage                                                     //
00004 //                                                                      //
00005 // Author: Fabrizio Furano (INFN Padova, 2004)                          //
00006 // Adapted from TXNetFile (root.cern.ch) originally done by             //
00007 //  Alvise Dorigo, Fabrizio Furano                                      //
00008 //          INFN Padova, 2003                                           //
00009 //                                                                      //
00010 // A message coming from a physical connection. I.e. a server response  //
00011 //  or some kind of error                                               //
00012 //                                                                      //
00013 //////////////////////////////////////////////////////////////////////////
00014 
00015 //       $Id: XrdClientMessage.hh 25932 2008-10-23 10:58:11Z ganis $
00016 
00017 #ifndef XRC_MESSAGE_H
00018 #define XRC_MESSAGE_H
00019 
00020 #include "XrdClient/XrdClientProtocol.hh"
00021 #include "XrdClient/XrdClientSock.hh"
00022 #include "XrdSys/XrdSysPthread.hh"
00023 
00024 #ifndef WIN32
00025 #include <netinet/in.h>
00026 #endif
00027 
00028 class XrdClientPhyConnection;
00029 
00030 class XrdClientMessage {
00031 
00032 private:
00033    bool           fAllocated;
00034    void           *fData;
00035    bool           fMarshalled;
00036    short          fStatusCode;
00037    XrdSysRecMutex fMultireadMutex;
00038 
00039 public:
00040 
00041    static kXR_unt16       CharStreamid2Int(kXR_char *charstreamid);
00042    static void            Int2CharStreamid(kXR_char *charstreamid, short intstreamid);
00043 
00044    enum EXrdMSCStatus {             // Some status codes useful
00045       kXrdMSC_ok               = 0,
00046       kXrdMSC_readerr          = 1,
00047       kXrdMSC_writeerr         = 2,
00048       kXrdMSC_timeout          = 3
00049    };
00050 
00051    ServerResponseHeader fHdr;
00052 
00053    XrdClientMessage(ServerResponseHeader header);
00054    XrdClientMessage();
00055 
00056    ~XrdClientMessage();
00057 
00058    bool               CreateData();
00059 
00060    inline int         DataLen() { return fHdr.dlen; }
00061 
00062    void              *DonateData();
00063    inline void       *GetData() {return fData;}
00064    inline int         GetStatusCode() { return fStatusCode; }
00065 
00066    inline int         HeaderStatus() { return fHdr.status; }
00067 
00068    inline kXR_unt16   HeaderSID() { return CharStreamid2Int(fHdr.streamid); }
00069 
00070    bool               IsAttn() { return (HeaderStatus() == kXR_attn); }
00071 
00072    inline bool        IsError() { return (fStatusCode != kXrdMSC_ok); };
00073 
00074    inline bool        IsMarshalled() { return fMarshalled; }
00075    void               Marshall();
00076    inline bool        MatchStreamid(short sid) { return (HeaderSID() == sid);}
00077    int                ReadRaw(XrdClientPhyConnection *phy);
00078    inline void        SetHeaderStatus(kXR_unt16 sts) { fHdr.status = sts; }
00079    inline void        SetMarshalled(bool m) { fMarshalled = m; }
00080    inline void        SetStatusCode(kXR_unt16 status) { fStatusCode = status; }
00081    void               Unmarshall();
00082 
00083 };
00084 
00085 #endif

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