AndroMeta  2.0.0
AndroMeta/include/AndroMeta/MCommunicator.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2009-2012 AndroMeta LLC. All rights reserved.
00003  *
00004  * AndroMeta LLC retains all intellectual property and proprietary 
00005  * rights to this software and related documentation and any modifications 
00006  * thereto.  Any use, reproduction, disclosure, or distribution of this 
00007  * software and related documentation without an express license agreement 
00008  * from AndroMeta LLC is strictly prohibited.
00009  * 
00010  */
00011 
00019 #ifndef ANDROMETA_M_COMMUNICATOR_H
00020 #define ANDROMETA_M_COMMUNICATOR_H
00021 
00022 #include <AndroMeta/MSocket.h>
00023 
00024 namespace Meta{
00025   
00026   class MProcTask;
00027   class MMessageBuffer;
00028   class MMessage;
00029   
00040   class MCommunicator : public MSocket{
00041   public:
00042     
00062     MCommunicator(MProcTask* task,
00063                   MMessageBuffer* sendBuffer=0,
00064                   MMessageBuffer* receiveBuffer=0);
00065     
00069     virtual ~MCommunicator();
00070     
00074     MProcTask* task();
00075     
00080     MMessageBuffer* sendBuffer();
00081     
00086     MMessageBuffer* receiveBuffer();
00087     
00094     void close(bool manual=true);
00095     
00102     virtual void onClose(bool manual);
00103     
00108     virtual void onConnect();
00109     
00113     bool isConnected() const;
00114     
00125     bool send(MMessage* msg);
00126     
00134     bool send(const mvar& header, const mvar& body);
00135     
00143     bool send(const mvar& body);
00144     
00152     bool receive(mvar& header, mvar& body);
00153     
00161     bool receive(mvar& body);
00162     
00170     bool receive(mvar& header, mvar& body, const mtime& timeout);
00171     
00179     bool receive(mvar& body, const mtime& timeout);
00180     
00181   private:  
00182     MCommunicator(const MCommunicator&);
00183     MCommunicator& operator=(const MCommunicator&);
00184     
00185     class MCommunicator_* x_;
00186   };
00187   
00188 } // end namespace Meta
00189 
00190 #endif // ANDROMETA_M_COMMUNICATOR_H