lmsg/TransportMsg.hh

00001 /* -*- mode: c++; c-basic-offset: 4; -*- */
00002 #ifndef LMSG_TRANSPORTMSG_HH
00003 #define LMSG_TRANSPORTMSG_HH
00004 
00005 #include "lmsg/MsgTypes.hh"
00006 
00007 namespace lmsg {
00008   class Buffer;
00009   class BufferPool;
00010   class Message;
00011   class MsgAddr;
00012   class MsgHeader;
00013   class Socket;
00014   class SocketPool;
00015 
00024   class TransportMsg {
00025   public:
00026 
00029     enum openflags {o_none, o_client=1, o_async=2};
00030 
00034     TransportMsg(void);
00035 
00039     ~TransportMsg(void);
00040 
00045     MsgAddr getAddr(void) const;
00046 
00049     MsgAddr getReplyAddr(void) const;
00050 
00055     bool    isConnected(void) const;
00056 
00061     bool    isOpen(void) const;
00062 
00067     index_type getDebug(void) const;
00068 
00077     error_type open(long flags, const MsgAddr* addr=0);
00078 
00082     void    close(void);
00083 
00091     error_type connect(const MsgAddr& addr);
00092 
00097     error_type disconnect(void);
00098 
00113     error_type receive(MsgHeader& from, char* b, size_type maxlen, 
00114                     wtime_type timeout=-1.0);
00115 
00128     error_type receive(MsgHeader& from, Message& msg, wtime_type timeout=-1.0);
00129 
00142     error_type receive(Buffer** Data, wtime_type timeout=-1.0);
00143 
00153     error_type send(const MsgHeader& to, const char* b);
00154 
00163     error_type send(const MsgHeader& to, const Message& b);
00164 
00170     error_type waitMsg(wtime_type Timeout) const;
00171 
00179     static error_type waitAny(wtime_type Timeout, int N, const TransportMsg* list[]);
00180 
00185     void Purge(void);
00186 
00191     void setSocketPool(SocketPool* pool);
00192 
00198     void setBufferPool(BufferPool* pool);
00199 
00204     void setDebug(index_type level);
00205 
00210     void setReplyAddr(const MsgAddr& ad);
00211 
00212   private:
00213     error_type send(Buffer* b);
00214 
00215   private:
00216     SocketPool* mSockPool;
00217     Socket*     mSocket;
00218     BufferPool* mBuffPool;
00219     index_type     mDebug;
00220     MsgAddr     mReplyAddr;
00221   };
00222 
00223 } // namespace lmsg
00224 
00225 //======================================  Inline methods
00226 inline bool
00227 lmsg::TransportMsg::isOpen(void) const {
00228     return (mSocket != 0);
00229 }
00230 
00231 inline lmsg::index_type
00232 lmsg::TransportMsg::getDebug(void) const {
00233     return mDebug;
00234 }
00235 
00236 inline lmsg::MsgAddr
00237 lmsg::TransportMsg::getReplyAddr(void) const {
00238     return mReplyAddr;
00239 }
00240 
00241 #endif // LMSG_SOCKET_HH

Generated on Sun Mar 8 19:20:51 2009 for dmt by  doxygen 1.5.4