00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CONEXUSMESSAGEQUEUE_H
00020 #define CONEXUSMESSAGEQUEUE_H
00021
00022 #include <mqueue.h>
00023 #include <sys/stat.h>
00024
00025 #include <conexus/endpoint.h>
00026
00037 namespace Conexus
00038 {
00039
00048 class MessageQueue : public Endpoint
00049 {
00050 protected:
00051
00052 MessageQueue( const std::string& name,
00053 unsigned flags,
00054 mode_t mode,
00055 bool close_on_destruction
00056 );
00057
00058 public:
00059
00060 typedef ConexusPointer<MessageQueue> pointer;
00061
00062 static MessageQueue::pointer create( const std::string& name,
00063 unsigned flags=QUEUE_READ|QUEUE_WRITE|QUEUE_CREATE,
00064 mode_t mode = S_IRWXU,
00065 bool close_on_destruction=true
00066 );
00067
00068 virtual ~MessageQueue();
00069
00070 virtual void open() throw ( open_exception );
00071
00072 virtual void close( bool force = false ) throw ( close_exception );
00073
00074 const std::string& name() const;
00075
00076 void set_name( const std::string& name );
00077
00078 unsigned flags() const;
00079
00080 void set_flags(unsigned flags);
00081
00082 bool unlink_on_destruction();
00083
00084 void set_unlink_on_destruction( bool u=true );
00085
00086 long int max_messages();
00087
00088 long int max_message_size();
00089
00090 protected:
00091 std::string m_name;
00092 unsigned m_flags;
00093 bool m_unlink_on_destruction;
00094 long int m_max_messages;
00095 long int m_max_message_size;
00096
00097 mode_t m_mode;
00098
00099 mqd_t m_queue;
00100
00101 virtual ssize_t write_data( long int timeout, const Data data ) throw ( write_exception );
00102
00103 virtual Data read_data( long int timeout, size_t s = 0 ) throw ( read_exception );
00104 };
00105
00106 }
00107
00108 #endif