PortInterface.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Thu Oct 22 11:59:07 CEST 2009 PortInterface.cpp
3 
4  PortInterface.cpp - description
5  -------------------
6  begin : Thu October 22 2009
7  copyright : (C) 2009 Sylvain Joyeux
8  email : sylvain.joyeux@m4x.org
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 
39 #include "PortInterface.hpp"
40 #include "../Service.hpp"
41 #include "../OperationCaller.hpp"
42 #include "../internal/ConnFactory.hpp"
43 #include "../TaskContext.hpp"
44 #include <cstring>
45 
46 using namespace RTT;
47 using namespace RTT::detail;
48 using namespace std;
49 
50 PortInterface::PortInterface(const std::string& name)
51  : name(name), fullName(name), iface(0), cmanager(this) {}
52 
54 
55 bool PortInterface::setName(const std::string& name) {
56  if ( !connected() ) {
57  this->name = name;
59  return true;
60  }
61  return false;
62 }
63 
65  DataFlowInterface* dataflow = getInterface();
66  if (dataflow && dataflow->getOwner())
67  fullName = dataflow->getOwner()->getName() + "." + getName();
68  else
69  fullName = getName();
70 }
71 
72 PortInterface& PortInterface::doc(const std::string& desc) {
73  mdesc = desc;
74  if (iface)
76  return *this;
77 }
78 
80  return cmanager.connectedTo(port);
81 }
82 
84 { return serverProtocol() == 0; }
86 { return 0; }
87 
89 { return new LocalConnID(this); }
90 
92 {
93 #ifndef ORO_EMBEDDED
94  Service* to = new Service( this->getName(), iface->getOwner() );
95  to->addSynchronousOperation( "name",&PortInterface::getName, this).doc(
96  "Returns the port name.");
97  to->addSynchronousOperation("connected", &PortInterface::connected, this).doc("Check if this port is connected and ready for use.");
98 
99  typedef void (PortInterface::*disconnect_all)();
100  to->addSynchronousOperation("disconnect", static_cast<disconnect_all>(&PortInterface::disconnect), this).doc("Disconnects this port from any connection it is part of.");
101  return to;
102 #else
103  return 0;
104 #endif
105 }
106 
108 {
109  return cmanager.removeConnection(conn);
110 }
111 
113  iface = dfi;
114  updateFullName();
115 }
116 
118 {
119  return iface;
120 }
121 
123 {
124  return cmanager.getSharedConnection();
125 }
boost::intrusive_ptr< SharedConnectionBase > shared_ptr
virtual bool isLocal() const
bool removeConnection(ConnID *port_id, bool disconnect=true)
virtual internal::SharedConnectionBase::shared_ptr getSharedConnection() const
PortInterface(const std::string &name)
Definition: mystd.hpp:163
bool connectedTo(base::PortInterface *port)
const std::string & getName() const
DataFlowInterface * getInterface() const
virtual void disconnect()=0
Operation< Signature > & addSynchronousOperation(Operation< Signature > &op)
Definition: Service.hpp:379
virtual bool removeConnection(internal::ConnID *cid)
virtual Service * createPortObject()
virtual bool connectedTo(PortInterface *port)
bool setName(const std::string &name)
virtual int serverProtocol() const
bool setPortDescription(const std::string &name, const std::string description)
internal::ConnectionManager cmanager
void setInterface(DataFlowInterface *iface)
DataFlowInterface * iface
virtual internal::ConnID * getPortID() const
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
PortInterface & doc(const std::string &desc)
virtual bool connected() const =0
virtual const std::string & getName() const
TaskContext * getOwner() const
internal::SharedConnectionBase::shared_ptr getSharedConnection() const


rtt
Author(s): RTT Developers
autogenerated on Tue Jun 25 2019 19:33:26