00001 /*************************************************************************** 00002 tag: Peter Soetens Thu Mar 2 08:30:18 CET 2006 PortInterface.hpp 00003 00004 PortInterface.hpp - description 00005 ------------------- 00006 begin : Thu March 02 2006 00007 copyright : (C) 2006 Peter Soetens 00008 email : peter.soetens@fmtc.be 00009 00010 *************************************************************************** 00011 * This library is free software; you can redistribute it and/or * 00012 * modify it under the terms of the GNU General Public * 00013 * License as published by the Free Software Foundation; * 00014 * version 2 of the License. * 00015 * * 00016 * As a special exception, you may use this file as part of a free * 00017 * software library without restriction. Specifically, if other files * 00018 * instantiate templates or use macros or inline functions from this * 00019 * file, or you compile this file and link it with other files to * 00020 * produce an executable, this file does not by itself cause the * 00021 * resulting executable to be covered by the GNU General Public * 00022 * License. This exception does not however invalidate any other * 00023 * reasons why the executable file might be covered by the GNU General * 00024 * Public License. * 00025 * * 00026 * This library is distributed in the hope that it will be useful, * 00027 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00028 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00029 * Lesser General Public License for more details. * 00030 * * 00031 * You should have received a copy of the GNU General Public * 00032 * License along with this library; if not, write to the Free Software * 00033 * Foundation, Inc., 59 Temple Place, * 00034 * Suite 330, Boston, MA 02111-1307 USA * 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 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
1.5.8