PortInterface.hpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef ORO_EXECUTION_PORT_INTERFACE_HPP
00040 #define ORO_EXECUTION_PORT_INTERFACE_HPP
00041
00042 #include <string>
00043 #include "ConnectionTypes.hpp"
00044 #include "ConnectionInterface.hpp"
00045 #include "Event.hpp"
00046
00047 namespace RTT
00048 {
00049 class TaskObject;
00050
00056 class RTT_API PortInterface
00057 {
00058 public:
00059 typedef Event<void(PortInterface*)> NewDataOnPortEvent;
00060 protected:
00061 friend class ConnectionInterface;
00062 std::string portname;
00063 NewDataOnPortEvent* new_data_on_port_event;
00064 PortInterface(const std::string& name);
00065
00071 virtual bool connect(ConnectionInterface::shared_ptr conn) = 0;
00072 public:
00077 enum PortType { ReadPort, WritePort, ReadWritePort };
00078
00083 enum ConnectionModel { Buffered, Data };
00084
00085 virtual ~PortInterface();
00086
00090 const std::string& getName() const { return portname;}
00091
00098 bool setName(const std::string& name);
00099
00103 bool ready() const;
00104
00108 void signal();
00109
00114 NewDataOnPortEvent* getNewDataOnPortEvent();
00115
00119 virtual ConnectionModel getConnectionModel() const = 0;
00120
00124 virtual PortType getPortType() const = 0;
00125
00129 virtual const TypeInfo* getTypeInfo() const = 0;
00130
00134 virtual bool connected() const = 0;
00135
00144 virtual ConnectionInterface::shared_ptr connection() const = 0;
00145
00153 virtual bool connectTo( ConnectionInterface::shared_ptr conn ) = 0;
00154
00164 virtual bool connectTo( PortInterface* other );
00165
00169 virtual void disconnect() = 0;
00170
00174 virtual PortInterface* clone() const = 0;
00175
00181 virtual PortInterface* antiClone() const = 0;
00182
00186 virtual ConnectionInterface::shared_ptr createConnection(ConnectionTypes::ConnectionType con_type = ConnectionTypes::lockfree);
00187
00193 virtual ConnectionInterface::shared_ptr createConnection( BufferBase::shared_ptr buf );
00194
00200 virtual ConnectionInterface::shared_ptr createConnection( DataSourceBase::shared_ptr data );
00201
00206 virtual TaskObject* createPortObject();
00207
00211 virtual int serverProtocol() const;
00212 };
00213
00214 }
00215
00216 #endif