namespace saga { namespace messaging { enum state { Unknown = 0, New = 1, Open = 2, Closed = 3, Dropped = 4 }; enum topology { Any = 0, PointToPoint = 1, Multicast = 2, PublishSubscribe = 3, PeerToPeer = 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 endpoint; class endpoint : public saga::object , public saga::async , public saga::monitorable { public: endpoint (void); endpoint (saga::object & obj); endpoint (saga::url url, topology t, reliability r, atomicity a, correctness c, ordering o); ~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) }; } } ////////////////////////////////////////////////////////////////////// // // 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) { // The generic endpoint class has all properties defaulting to // 'Any', so we need to specify the properties (unless we are // happy with Any, which we aren't in this use case). saga::messaging::endpoint ep ("geom://remote.host.net:1234/renderer/", saga::messaging::PublishSubscriber, // Topology saga::messaging::Reliable, // Reliability saga::messaging::AtMostOnce, // Atomicity saga::messaging::Verified, // Correctness saga::messaging::Unordered // Ordering ); geometry_message gm (geom); ep.send (gm); }