namespace saga { namespace messaging { enum state { Unknown = 0, New = 1, Open = 2, Closed = 3, Dropped = 4 }; enum reliability { Any = 0, Unreliable = 1, Consistent = 2, SemiReliable = 2, Reliable = 3 }; enum atomicity { Any = 0, AtMostOnce = 1, AtLeastOnce = 2, ExactlyOnce = 3 }; enum correctness { Any = 0, Verified = 1, Unverified = 2, Signed = 3, Encrypted = 4 }; enum ordering { Any = 0, Unordered = 1, Ordered = 2, GloballyOrdered = 3 }; class message : public saga::buffer { public: message (void); message (int size); message (void * data); message (saga::buffer buf, int size = -1); ~message (void); std::string get_sender (void); std::string get_id (void); }; class pubsub_endpoint : public saga::object , public saga::async , public saga::monitorable { // default properties for the pubsub endpoint are: // Topology : PublishSubscriber // Reliability : Reliable, // Atomicity : ExactlyOnce, // Correctness : Verified, // Ordering : Unordered public: pub_sub_endpoint (void); pub_sub_endpoint (saga::object & obj); pub_sub_endpoint (saga::url url, reliability r, atomicity a, correctness c, ordering o); ~pub_sub_endpoint (void); // inspection saga::url get_url (void); std::list get_receivers (void); // management methods void serve (int n_clients = -1); endpoint serve_once (float timout = -1.0); void connect (float timout = -1.0); void disconnect (void); // I/O methods void send (message m, saga::url client = "", float timout = -1.0); int test (saga::url client = "", float timout = -1.0); message receive (saga::url client = "", float timout = -1.0) }; class point2point_endpoint ... class peer2peer_endpoint ... class multicast_endpoint ... } } ////////////////////////////////////////////////////////////////////// // // application example // class geometry { // ... }; class geometry_message : public saga::messaging::message { // define how the message is serialized into and deserialized from a message // buffer }; void mapper_to_renderer (geometry geom) { // our topology specific endpoint needs slightly different default // property settings, so we specify them (Atomicity is here the // non-default 'AtMostOnce'). saga::messaging::pubsub_endpoint ep ("geom://remote.host.net:1234/renderer/", saga::messaging::Reliable, // Reliability saga::messaging::AtMostOnce, // Atomicity saga::messaging::Verified, // Correctness saga::messaging::Unordered // Ordering ); geometry_message gm (geom); ep.send (gm); }