Sirikata
|
An implementation of XDP::Port, templatized on an Endpoint type, that handles all the bookkeeping and sanity checking, but delegates real operations to the user of the class via some callback functions registered at creation. More...
#include <DelegatePort.hpp>
Public Types | |
typedef EndpointType | Endpoint |
typedef PortType | Port |
typedef DelegateServiceType | DelegateService |
typedef DelegateServiceType::MessageHandler | MessageHandler |
typedef std::tr1::function < bool(const Endpoint &, MemoryReference payload)> | SendFunction |
Public Member Functions | |
DelegatePort (DelegateService *parent, const Endpoint &ep, SendFunction send_func) | |
Create a new DelegatePort with the given properties which handles sends via send_func. | |
virtual | ~DelegatePort () |
virtual const Endpoint & | endpoint () const |
virtual bool | send (const Endpoint &to, MemoryReference payload) |
virtual void | receiveFrom (const Endpoint &from, const MessageHandler &cb) |
bool | deliver (const Endpoint &src, const Endpoint &dst, MemoryReference data) const |
Deliver a message via this port. | |
void | invalidate () |
Invalidate this port. | |
Private Types | |
typedef std::tr1::unordered_map < Endpoint, MessageHandler, typename Endpoint::Hasher > | ReceiveFromHandlers |
Private Member Functions | |
bool | tryDeliver (const Endpoint &src_match_ep, const Endpoint &src_real_ep, const Endpoint &dst, MemoryReference data) const |
Private Attributes | |
DelegateService * | mParent |
Endpoint | mEndpoint |
SendFunction | mSendFunc |
ReceiveFromHandlers | mFromHandlers |
bool | mInvalidated |
An implementation of XDP::Port, templatized on an Endpoint type, that handles all the bookkeeping and sanity checking, but delegates real operations to the user of the class via some callback functions registered at creation.
This class works in conjunction with DelegateService.
typedef DelegateServiceType Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::DelegateService |
typedef EndpointType Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::Endpoint |
typedef DelegateServiceType::MessageHandler Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::MessageHandler |
typedef PortType Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::Port |
typedef std::tr1::unordered_map<Endpoint, MessageHandler, typename Endpoint::Hasher> Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::ReceiveFromHandlers [private] |
typedef std::tr1::function<bool(const Endpoint&, MemoryReference payload)> Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::SendFunction |
Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::DelegatePort | ( | DelegateService * | parent, |
const Endpoint & | ep, | ||
SendFunction | send_func | ||
) | [inline] |
Create a new DelegatePort with the given properties which handles sends via send_func.
parent | the parent DelegateService that manages this port |
ep | the endpoint identifier for this port, must be fully qualified |
send_func | functor to invoke to send messages |
virtual Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::~DelegatePort | ( | ) | [inline, virtual] |
bool Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::deliver | ( | const Endpoint & | src, |
const Endpoint & | dst, | ||
MemoryReference | data | ||
) | const [inline] |
Deliver a message via this port.
Returns true if a receiver was found for the message, false if none was found and it was ignored.
References Sirikata::XDP::PortID::any(), Sirikata::SpaceID::any(), Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::mInvalidated, and Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::tryDeliver().
Referenced by Sirikata::OHDP::DelegateService::deliver(), and Sirikata::ODP::DelegateService::deliver().
virtual const Endpoint& Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::endpoint | ( | ) | const [inline, virtual] |
void Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::invalidate | ( | ) | [inline] |
Invalidate this port.
This effectively disables the port. This is used by the parent DelegateService to stop the Port from doing anything dangerous after the parent is deleted, but doesn't actually delete this port since others might still hold a pointer to it.
References Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::mInvalidated, and Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::mParent.
Referenced by Sirikata::OHDP::DelegateService::~DelegateService(), and Sirikata::ODP::DelegateService::~DelegateService().
virtual void Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::receiveFrom | ( | const Endpoint & | from, |
const MessageHandler & | cb | ||
) | [inline, virtual] |
virtual bool Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::send | ( | const Endpoint & | to, |
MemoryReference | payload | ||
) | [inline, virtual] |
bool Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::tryDeliver | ( | const Endpoint & | src_match_ep, |
const Endpoint & | src_real_ep, | ||
const Endpoint & | dst, | ||
MemoryReference | data | ||
) | const [inline, private] |
Endpoint Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::mEndpoint [private] |
ReceiveFromHandlers Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::mFromHandlers [private] |
bool Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::mInvalidated [private] |
Referenced by Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::deliver(), Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::invalidate(), Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::send(), and Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::~DelegatePort().
DelegateService* Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::mParent [private] |
SendFunction Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::mSendFunc [private] |