OutputPortInterface.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Thu Oct 22 11:59:07 CEST 2009 OutputPortInterface.cpp
3 
4  OutputPortInterface.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 "OutputPortInterface.hpp"
41 #include "InputPortInterface.hpp"
42 #include "../internal/ConnFactory.hpp"
43 #include <exception>
44 #include <stdexcept>
45 #include "../os/traces.h"
46 
47 using namespace RTT;
48 using namespace RTT::detail;
49 using namespace std;
50 
51 
53  : PortInterface(name) { }
54 
56 {
58 }
59 
62 {
63  return getEndpoint()->connected();
64 }
65 
67 {
68  return cmanager.disconnect(port);
69 }
70 
72 {
74 }
75 
77 {
78  if ( this->connectionAdded(channel_input, policy) ) {
79  return cmanager.addConnection(port_id, channel_input, policy);
80  }
81  return false;
82 }
83 
85 { throw std::runtime_error("calling default OutputPortInterface::write(datasource) implementation"); }
86 
88 { return createConnection( input, ConnPolicy::data(lock_policy) ); }
89 
90 bool OutputPortInterface::createBufferConnection( InputPortInterface& input, int size, int lock_policy )
91 { return createConnection( input, ConnPolicy::buffer(size, lock_policy) ); }
92 
94 { return createConnection(input, input.getDefaultPolicy()); }
95 
97 {
98  return internal::ConnFactory::createSharedConnection(this, 0, shared_connection, policy);
99 }
100 
102 {
103  InputPortInterface* input = dynamic_cast<InputPortInterface*>(other);
104  if (! input)
105  return false;
106  return createConnection(*input, policy);
107 }
108 
110 {
111  InputPortInterface* input = dynamic_cast<InputPortInterface*>(other);
112  if (! input)
113  return false;
114  return createConnection(*input);
115 }
116 
118 {
119  tracepoint(orocos_rtt, OutputPort_write, getFullName().c_str());
120 }
121 
static ConnPolicy data(int lock_policy=LOCK_FREE, bool init_connection=true, bool pull=false)
Definition: ConnPolicy.cpp:99
bool createDataConnection(InputPortInterface &sink, int lock_policy=ConnPolicy::LOCK_FREE)
boost::intrusive_ptr< SharedConnectionBase > shared_ptr
ConnPolicy getDefaultPolicy() const
Definition: mystd.hpp:163
#define tracepoint(provider, tracepoint,...)
Definition: traces.h:9
static bool createSharedConnection(base::OutputPortInterface *output_port, base::InputPortInterface *input_port, SharedConnectionBase::shared_ptr shared_connection, ConnPolicy const &policy)
virtual WriteStatus write(DataSourceBase::shared_ptr source)
virtual ChannelElementBase * getEndpoint() const =0
bool createConnection(InputPortInterface &sink)
virtual bool connectTo(PortInterface *other, ConnPolicy const &policy)
static ConnPolicy buffer(int size, int lock_policy=LOCK_FREE, bool init_connection=false, bool pull=false)
Definition: ConnPolicy.cpp:77
virtual bool addConnection(internal::ConnID *port_id, ChannelElementBase::shared_ptr channel_input, ConnPolicy const &policy)
boost::intrusive_ptr< ChannelElementBase > shared_ptr
internal::ConnectionManager cmanager
bool addConnection(ConnID *port_id, base::ChannelElementBase::shared_ptr channel, ConnPolicy policy)
boost::intrusive_ptr< DataSourceBase > shared_ptr
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
const std::string & getFullName() const
virtual bool connectionAdded(ChannelElementBase::shared_ptr channel_input, ConnPolicy const &policy)=0
bool createBufferConnection(InputPortInterface &sink, int size, int lock_policy=ConnPolicy::LOCK_FREE)
OutputPortInterface(OutputPortInterface const &orig)
WriteStatus
Definition: FlowStatus.hpp:66


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