Back to index

nordugrid-arc-nox  1.1.0~rc6
PayloadStream.h
Go to the documentation of this file.
00001 #ifndef __ARC_PAYLOADSTREAM_H__
00002 #define __ARC_PAYLOADSTREAM_H__
00003 
00004 #include <string>
00005 
00006 #include "Message.h"
00007 
00008 namespace Arc {
00009 
00011 
00015 class PayloadStreamInterface: virtual public MessagePayload {
00016  public:
00017   // Avoid defining size of int - just use biggest possible
00018   typedef signed long long int Size_t;
00019   PayloadStreamInterface(void) { };
00020   virtual ~PayloadStreamInterface(void) { };
00024   virtual bool Get(char* buf,int& size) = 0;
00026   virtual bool Get(std::string& buf) = 0;
00028   virtual std::string Get(void) = 0;
00031   virtual bool Put(const char* buf,Size_t size) = 0;
00034   virtual bool Put(const std::string& buf) = 0;
00037   virtual bool Put(const char* buf) = 0;
00039   virtual operator bool(void) = 0;
00041   virtual bool operator!(void) = 0;
00043   virtual int Timeout(void) const = 0;
00045   virtual void Timeout(int to) = 0;
00047   virtual Size_t Pos(void) const = 0;
00049   virtual Size_t Size(void) const = 0;
00053   virtual Size_t Limit(void) const = 0;
00054 };
00055 
00057 
00058 class PayloadStream: virtual public PayloadStreamInterface {
00059  protected:
00060   int timeout_;   
00061   int handle_;    
00062   bool seekable_; 
00063  public:
00066   PayloadStream(int h = -1);
00068   virtual ~PayloadStream(void) { };
00069   virtual bool Get(char* buf,int& size);
00070   virtual bool Get(std::string& buf);
00071   virtual std::string Get(void) { std::string buf; Get(buf); return buf; };
00072   virtual bool Put(const char* buf,Size_t size);
00073   virtual bool Put(const std::string& buf) { return Put(buf.c_str(),buf.length()); };
00074   virtual bool Put(const char* buf) { return Put(buf,buf?strlen(buf):0); };
00075   virtual operator bool(void) { return (handle_ != -1); };
00076   virtual bool operator!(void) { return (handle_ == -1); };
00077   virtual int Timeout(void) const { return timeout_; };
00078   virtual void Timeout(int to) { timeout_=to; };
00079   virtual Size_t Pos(void) const { return 0; };
00080   virtual Size_t Size(void) const { return 0; };
00081   virtual Size_t Limit(void) const { return 0; };
00082 };
00083 }
00084 #endif /* __ARC_PAYLOADSTREAM_H__ */