ConnectionInterface.hpp

00001 /***************************************************************************
00002   tag: Peter Soetens  Thu Mar 2 08:30:17 CET 2006  ConnectionInterface.hpp
00003 
00004                         ConnectionInterface.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_CONNECTION_INTERFACE_HPP
00040 #define ORO_EXECUTION_CONNECTION_INTERFACE_HPP
00041 
00042 #include <boost/intrusive_ptr.hpp>
00043 #include "os/Atomic.hpp"
00044 #include "DataSourceBase.hpp"
00045 #include "BufferBase.hpp"
00046 #include <vector>
00047 
00048 namespace RTT
00049 {
00050     class ConnectionInterface;
00051 }
00052 
00053 void RTT_API intrusive_ptr_add_ref( RTT::ConnectionInterface* p );
00054 void RTT_API intrusive_ptr_release( RTT::ConnectionInterface* p );
00055 
00056 namespace RTT
00057 {
00058     class PortInterface;
00059 
00101     class RTT_API ConnectionInterface
00102     {
00103     protected:
00104         friend void ::intrusive_ptr_add_ref( ConnectionInterface* p );
00105         friend void ::intrusive_ptr_release( ConnectionInterface* p );
00106         OS::AtomicInt refcount;
00107 
00108         typedef std::vector<PortInterface*> PList;
00109         PList ports;
00110         bool mconnected;
00111 
00112         std::string connectionName;
00113     public:
00114         typedef boost::intrusive_ptr<ConnectionInterface> shared_ptr;
00115 
00116         ConnectionInterface();
00117         virtual ~ConnectionInterface();
00118 
00123         virtual DataSourceBase::shared_ptr getDataSource() const = 0;
00124 
00130         virtual BufferBase::shared_ptr getBuffer() const = 0;
00131 
00139         virtual bool connect();
00140 
00144         virtual bool connected() const;
00145 
00149         virtual bool disconnect();
00150 
00161         virtual bool addPort(PortInterface* p);
00162 
00172         virtual bool removePort(PortInterface* p);
00173 
00177         virtual const TypeInfo* getTypeInfo() const = 0;
00178 
00182         virtual int serverProtocol() const {
00183             return 0;
00184         }
00185 
00192         void signal();
00193 
00199         std::string getConnectionName();
00200 
00206         void setConnectionName(std::string newConnectionName);
00207 
00213         PList getPortList();
00214     };
00215 }
00216 
00217 #endif
Generated on Thu Dec 23 13:22:36 2010 for Orocos Real-Time Toolkit by  doxygen 1.6.3