Sirikata
libcore/include/sirikata/core/xdp/Port.hpp
Go to the documentation of this file.
00001 // Copyright (c) 2011 Sirikata Authors. All rights reserved.
00002 // Use of this source code is governed by a BSD-style license that can
00003 // be found in the LICENSE file.
00004 
00005 #ifndef _SIRIKATA_LIBCORE_XDP_PORT_HPP_
00006 #define _SIRIKATA_LIBCORE_XDP_PORT_HPP_
00007 
00008 #include <sirikata/core/xdp/Defs.hpp>
00009 
00010 namespace Sirikata {
00011 namespace XDP {
00012 
00047 template<typename EndpointType>
00048 class Port {
00049 public:
00050     typedef EndpointType Endpoint;
00051     typedef typename Endpoint::MessageHandler MessageHandler;
00052 
00053     virtual ~Port() {}
00054 
00059     virtual const Endpoint& endpoint() const = 0;
00060 
00068     virtual bool send(const Endpoint& to, MemoryReference payload) = 0;
00069 
00075     void receive(const MessageHandler& cb) {
00076         receiveFrom(Endpoint::any(), cb);
00077     }
00078 
00083     virtual void receiveFrom(const Endpoint& from, const MessageHandler& cb) = 0;
00084 
00085 }; // class Port
00086 
00087 } // namespace XDP
00088 } // namespace Sirikata
00089 
00090 #endif //_SIRIKATA_LIBCORE_XDP_PORT_HPP_