InputPortInterface.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Thu Oct 22 11:59:07 CEST 2009 InputPortInterface.cpp
3 
4  InputPortInterface.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 "InputPortInterface.hpp"
41 #include "OutputPortInterface.hpp"
42 #include "DataFlowInterface.hpp"
43 #include "../internal/ConnInputEndPoint.hpp"
44 #include "../internal/ConnFactory.hpp"
45 #include "../Logger.hpp"
46 #include <exception>
47 #include <stdexcept>
48 #include <../os/traces.h>
49 
50 using namespace RTT;
51 using namespace RTT::detail;
52 using namespace std;
53 
54 InputPortInterface::InputPortInterface(std::string const& name, ConnPolicy const& default_policy)
55 : PortInterface(name)
56  , default_policy( default_policy )
57 #ifdef ORO_SIGNALLING_PORTS
58  , new_data_on_port_event(0)
59 #else
60  , msignal_interface(false)
61 #endif
62 {}
63 
64 InputPortInterface::~InputPortInterface()
65 {
66  cmanager.disconnect();
67 #ifdef ORO_SIGNALLING_PORTS
68  if ( new_data_on_port_event) {
69  delete new_data_on_port_event;
70  }
71 #endif
72 }
73 
74 ConnPolicy InputPortInterface::getDefaultPolicy() const
75 { return default_policy; }
76 
77 #ifdef ORO_SIGNALLING_PORTS
78 InputPortInterface::NewDataOnPortEvent* InputPortInterface::getNewDataOnPortEvent()
79 {
80  if (!new_data_on_port_event)
81  new_data_on_port_event = new NewDataOnPortEvent();
82  return new_data_on_port_event;
83 }
84 #endif
85 
86 bool InputPortInterface::connectTo(PortInterface* other, ConnPolicy const& policy)
87 {
88  OutputPortInterface* output = dynamic_cast<OutputPortInterface*>(other);
89  if (! output) {
90  log(Error) << "InputPort "<< getName() <<" could not connect to "<< other->getName() << ": not an Output port." <<endlog();
91  return false;
92  }
93  return output->createConnection(*this, policy);
94 }
95 
96 bool InputPortInterface::connectTo(PortInterface* other)
97 {
98  return connectTo(other, default_policy);
99 }
100 
101 bool InputPortInterface::addConnection(ConnID* cid, ChannelElementBase::shared_ptr channel, const ConnPolicy& policy)
102 {
103  // input ports don't check the connection policy.
104  return cmanager.addConnection( cid, channel, policy);
105 }
106 
107 #ifndef ORO_SIGNALLING_PORTS
108 void InputPortInterface::signal()
109 {
110  if (iface && msignal_interface)
111  iface->dataOnPort(this);
112 }
113 
114 void InputPortInterface::signalInterface(bool true_false)
115 {
116  msignal_interface = true_false;
117 }
118 #endif
119 
120 FlowStatus InputPortInterface::read(DataSourceBase::shared_ptr source, bool copy_old_data)
121 { throw std::runtime_error("calling default InputPortInterface::read(datasource) implementation"); }
122 
124 bool InputPortInterface::connected() const
125 {
126  return getEndpoint()->connected();
127 }
128 
129 void InputPortInterface::traceRead(RTT::FlowStatus status)
130 {
131  tracepoint(orocos_rtt, InputPort_read, status, getFullName().c_str());
132 }
133 
134 void InputPortInterface::disconnect()
135 {
136  cmanager.disconnect();
137 }
138 
139 bool InputPortInterface::disconnect(PortInterface* port)
140 {
141  return cmanager.disconnect(port);
142 }
143 
144 bool InputPortInterface::createConnection( internal::SharedConnectionBase::shared_ptr shared_connection, ConnPolicy const& policy )
145 {
146  return internal::ConnFactory::createSharedConnection(0, this, shared_connection, policy);
147 }
148 
149 base::ChannelElementBase::shared_ptr InputPortInterface::buildRemoteChannelOutput(
150  base::OutputPortInterface& output_port,
151  types::TypeInfo const* type_info,
152  base::InputPortInterface& input, const ConnPolicy& policy)
153 {
155 }
boost::intrusive_ptr< SharedConnectionBase > shared_ptr
InputPortInterface(const InputPortInterface &orig)
FlowStatus
Definition: FlowStatus.hpp:56
Definition: mystd.hpp:163
const std::string & getName() const
#define tracepoint(provider, tracepoint,...)
Definition: traces.h:9
bool createConnection(InputPortInterface &sink)
boost::intrusive_ptr< ChannelElementBase > shared_ptr
boost::intrusive_ptr< DataSourceBase > shared_ptr
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
InputPort_read
Definition: lttng_ust.h:67
static Logger & log()
Definition: Logger.hpp:350
static Logger::LogFunction endlog()
Definition: Logger.hpp:362


rtt
Author(s): RTT Developers
autogenerated on Fri Oct 25 2019 03:59:33