Sirikata
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType > Class Template Reference

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>

Inheritance diagram for Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >:
Collaboration diagram for Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >:

List of all members.

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 Endpointendpoint () 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

DelegateServicemParent
Endpoint mEndpoint
SendFunction mSendFunc
ReceiveFromHandlers mFromHandlers
bool mInvalidated

Detailed Description

template<typename EndpointType, typename DelegateServiceType, typename PortType = Sirikata::XDP::Port<EndpointType>>
class Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >

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.


Member Typedef Documentation

template<typename EndpointType , typename DelegateServiceType , typename PortType = Sirikata::XDP::Port<EndpointType>>
typedef DelegateServiceType Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::DelegateService
template<typename EndpointType , typename DelegateServiceType , typename PortType = Sirikata::XDP::Port<EndpointType>>
typedef EndpointType Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::Endpoint
template<typename EndpointType , typename DelegateServiceType , typename PortType = Sirikata::XDP::Port<EndpointType>>
typedef DelegateServiceType::MessageHandler Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::MessageHandler
template<typename EndpointType , typename DelegateServiceType , typename PortType = Sirikata::XDP::Port<EndpointType>>
typedef PortType Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::Port
template<typename EndpointType , typename DelegateServiceType , typename PortType = Sirikata::XDP::Port<EndpointType>>
typedef std::tr1::unordered_map<Endpoint, MessageHandler, typename Endpoint::Hasher> Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::ReceiveFromHandlers [private]
template<typename EndpointType , typename DelegateServiceType , typename PortType = Sirikata::XDP::Port<EndpointType>>
typedef std::tr1::function<bool(const Endpoint&, MemoryReference payload)> Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::SendFunction

Constructor & Destructor Documentation

template<typename EndpointType , typename DelegateServiceType , typename PortType = Sirikata::XDP::Port<EndpointType>>
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.

Parameters:
parentthe parent DelegateService that manages this port
epthe endpoint identifier for this port, must be fully qualified
send_funcfunctor to invoke to send messages
template<typename EndpointType , typename DelegateServiceType , typename PortType = Sirikata::XDP::Port<EndpointType>>
virtual Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::~DelegatePort ( ) [inline, virtual]

Member Function Documentation

template<typename EndpointType , typename DelegateServiceType , typename PortType = Sirikata::XDP::Port<EndpointType>>
bool Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::deliver ( const Endpoint src,
const Endpoint dst,
MemoryReference  data 
) const [inline]
template<typename EndpointType , typename DelegateServiceType , typename PortType = Sirikata::XDP::Port<EndpointType>>
virtual const Endpoint& Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::endpoint ( ) const [inline, virtual]
template<typename EndpointType , typename DelegateServiceType , typename PortType = Sirikata::XDP::Port<EndpointType>>
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().

template<typename EndpointType , typename DelegateServiceType , typename PortType = Sirikata::XDP::Port<EndpointType>>
virtual void Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::receiveFrom ( const Endpoint from,
const MessageHandler cb 
) [inline, virtual]
template<typename EndpointType , typename DelegateServiceType , typename PortType = Sirikata::XDP::Port<EndpointType>>
virtual bool Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::send ( const Endpoint to,
MemoryReference  payload 
) [inline, virtual]
template<typename EndpointType , typename DelegateServiceType , typename PortType = Sirikata::XDP::Port<EndpointType>>
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]

Member Data Documentation

template<typename EndpointType , typename DelegateServiceType , typename PortType = Sirikata::XDP::Port<EndpointType>>
Endpoint Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::mEndpoint [private]
template<typename EndpointType , typename DelegateServiceType , typename PortType = Sirikata::XDP::Port<EndpointType>>
ReceiveFromHandlers Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::mFromHandlers [private]
template<typename EndpointType , typename DelegateServiceType , typename PortType = Sirikata::XDP::Port<EndpointType>>
bool Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::mInvalidated [private]
template<typename EndpointType , typename DelegateServiceType , typename PortType = Sirikata::XDP::Port<EndpointType>>
DelegateService* Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::mParent [private]
template<typename EndpointType , typename DelegateServiceType , typename PortType = Sirikata::XDP::Port<EndpointType>>
SendFunction Sirikata::XDP::DelegatePort< EndpointType, DelegateServiceType, PortType >::mSendFunc [private]

The documentation for this class was generated from the following file: