Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: provide a way to manage RTT component networks when hosts "disappear" (on top of #15) #16

Open
wants to merge 6 commits into
base: corba_multi_dispatcher
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rtt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ OPTION(OS_HAVE_STREAMS "Use C++ streams library." ON)
OPTION(OS_HAVE_MAIN "Provide main() function in rtt library, which sets up the OS. The user implements ORO_main()." ON)
OPTION(ORO_OS_USE_BOOST_THREAD "Use the Boost.Thread library. Currently only the mutex implementation is used." OFF)
set(ROCK_USE_SANITIZERS "" CACHE STRING "Which sanitizers to enable during the build (comma separated, compiler specific)")
option(ORO_NO_DISCONNECT_DATAFLOW_ON_DESTRUCTION "Disable disconnecting dataflow on task context or port destruction" OFF)

if (ROCK_USE_SANITIZERS)
add_compile_options("-fsanitize=${ROCK_USE_SANITIZERS}")
Expand Down
3 changes: 3 additions & 0 deletions rtt/base/OutputPortInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
***************************************************************************/


#include "../rtt-config.h"
#include "PortInterface.hpp"
#include "OutputPortInterface.hpp"
#include "InputPortInterface.hpp"
Expand All @@ -52,7 +53,9 @@ OutputPortInterface::OutputPortInterface(std::string const& name)

OutputPortInterface::~OutputPortInterface()
{
#ifndef ORO_NO_DISCONNECT_DATAFLOW_ON_DESTRUCTION
cmanager.disconnect();
#endif
}

/** Returns true if this port is connected */
Expand Down
3 changes: 3 additions & 0 deletions rtt/internal/ConnectionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
* Author: kaltan
*/

#include "../rtt-config.h"
#include "ConnectionManager.hpp"
#include <boost/bind.hpp>
#include <boost/scoped_ptr.hpp>
Expand All @@ -66,7 +67,9 @@ namespace RTT

ConnectionManager::~ConnectionManager()
{
#ifndef ORO_NO_DISCONNECT_DATAFLOW_ON_DESTRUCTION
this->disconnect();
#endif
}

/**
Expand Down
1 change: 1 addition & 0 deletions rtt/rtt-config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#define RTT_HAS_STATE_CHANGE_HOOK

#cmakedefine ORO_DISABLE_PORT_DATA_SCRIPTING
#cmakedefine ORO_NO_DISCONNECT_DATAFLOW_ON_DESTRUCTION

// if not defined, show an error
#ifndef OROCOS_TARGET
Expand Down
55 changes: 54 additions & 1 deletion rtt/transports/corba/DataFlow.idl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ module RTT
*/
void remoteDisconnect(in boolean writer_to_reader);

/** Disconnect the local channel that includes this element
*
* Unlike disconnect, which calls the remote side internally, this
* method explicitly restricts itself to the local part of the channel
* The caller will be responsible to cleanup the other side.
*/
void disconnectHalf();

};

/** Emitted when information is requested on a port that does not exist */
Expand All @@ -100,6 +108,13 @@ module RTT
* for the data type of the given ports
*/
exception CNoCorbaTransport {};
/** Emitted when the system is expected to create a local connection, but one
* of the ports is remote
*/
exception CNotLocalConnection {};
/** Emitted when a call refers to a corba channel that we can't find internally
*/
exception CNoSuchCorbaChannel {};

enum CPortType { CInput, COutput };

Expand Down Expand Up @@ -169,6 +184,34 @@ module RTT
CChannelElement buildChannelOutput(in string input_port, inout CConnPolicy policy)
raises(CNoCorbaTransport,CNoSuchPortException);

/**
* Create the half of a connection, from an output port to a CORBA channel element
*
* Unlike with buildChannelInput, the channel is not yet connected to the output
* port. You need to call connectChannelInputHalf to do so, once the whole channel
* is fully setup.
*/
CChannelElement buildChannelInputHalf(in string output_port, inout CConnPolicy policy)
raises(CNoCorbaTransport,CNoSuchPortException);

/**
* Connect the input half of the channel to its port
*/
boolean connectChannelInputHalf(in string output_port, in CChannelElement channel, in CConnPolicy policy)
raises(CNoCorbaTransport, CNoSuchPortException, CNoSuchCorbaChannel);

/**
* Create the output half of a channel, not yet connected to the input port
*/
CChannelElement buildChannelOutputHalf(in string input_port, in CConnPolicy policy)
raises(CNoCorbaTransport,CNoSuchPortException);

/**
* Create the output half of a channel, not yet connected to the input port
*/
boolean connectChannelOutputHalf(in string input_port, in CChannelElement channel, in CConnPolicy policy)
raises(CNoCorbaTransport,CNoSuchPortException);

/**
* Use this to read from an output port with
* the given policy.
Expand All @@ -178,6 +221,16 @@ module RTT
CChannelElement buildChannelInput(in string output_port, inout CConnPolicy policy)
raises(CNoCorbaTransport,CNoSuchPortException);

/**
* Connect two ports when they are both within the same process
*
* The local port needs to be the output, while the remote port is the
* input.
*/
boolean createLocalConnection(in string local_port, in CDataFlowInterface remote_ports,
in string remote_port, inout CConnPolicy policy)
raises(CNoSuchPortException, CNotLocalConnection);

/**
* Connect the given named port to the given remote port.
* Use this method to connect two Orocos data flow ports.
Expand Down Expand Up @@ -235,7 +288,7 @@ module RTT
* @return false if the connection could not be used.
*/
boolean channelReady(in string input_port,in CChannelElement channel, in CConnPolicy cp)
raises(CNoSuchPortException);
raises(CNoSuchPortException, CNoSuchCorbaChannel);
};
};
};
Expand Down
Loading