source: finroc_plugins_composite_ports/auto_connect.h

tip
Last change on this file was 12:35b3eecd8d06, checked in by Max Reichardt <max.reichardt@…>, 18 months ago

Adds parameter to ConnectUnconnectedMatchingInterfaces convenience function

File size: 4.9 KB
Line 
1//
2// You received this file as part of Finroc
3// A framework for intelligent robot control
4//
5// Copyright (C) Finroc GbR (finroc.org)
6//
7// This program is free software; you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation; either version 2 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License along
18// with this program; if not, write to the Free Software Foundation, Inc.,
19// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20//
21//----------------------------------------------------------------------
22/*!\file    plugins/composite_ports/auto_connect.h
23 *
24 * \author  Max Reichardt
25 *
26 * \date    2020-02-18
27 *
28 * Utility functions in particular for convenient auto-connecting
29 *
30 */
31//----------------------------------------------------------------------
32#ifndef __plugins__composite_ports__auto_connect_h__
33#define __plugins__composite_ports__auto_connect_h__
34
35//----------------------------------------------------------------------
36// External includes (system with <>, local with "")
37//----------------------------------------------------------------------
38#include "core/port/tPortGroup.h"
39
40//----------------------------------------------------------------------
41// Internal includes with ""
42//----------------------------------------------------------------------
43
44//----------------------------------------------------------------------
45// Namespace declaration
46//----------------------------------------------------------------------
47namespace finroc
48{
49namespace composite_ports
50{
51
52//----------------------------------------------------------------------
53// Forward declarations / typedefs / enums
54//----------------------------------------------------------------------
55
56//----------------------------------------------------------------------
57// Function declarations
58//----------------------------------------------------------------------
59
60/*!
61 * Connects all port composite interfaces of type TInterface found in composite component's child components
62 * to composite component's interface.
63 * One port composite interface is created for each not already connected child component port composite interface.
64 * The created port composite interface instances are added to interfaces_variable.
65 *
66 * \param composite_component Composite component to check
67 * \param interfaces_variable Created port composite interfaces in composite component interface are added to this vector.
68 * \param common_prefix Common prefix of all ports names (see port naming above; add a pending space if you like to have a space between prefix and index)
69 * \param start_index Number in name of first port in vector (incremented for each further port)
70 * \param common_postfix Common postfix of all ports names (see port naming above; could be e.g. ']')
71 * \return Error message if connecting fails - otherwise empty string.
72 */
73template <typename TComponent, typename TInterface>
74std::string ConnectChildComponentInterfaces(TComponent& composite_component, std::vector<TInterface>& interfaces_variable, const std::string& common_prefix, size_t start_index = 1, const std::string& common_postfix = "");
75
76/*!
77 * Connects first composite interfaces of type TInterface found in composite component's child components
78 * to provided interface.
79 *
80 * \param composite_component Composite component to check
81 * \param interface Interface to connect
82 */
83template <typename TComponent, typename TInterface>
84void ConnectFirstChildComponentInterface(TComponent& composite_component, TInterface& interface);
85
86/*!
87 * Connects unconnected port composite interfaces in destination component interface with any matching
88 * component interfaces found in source.
89 * This function does not connect interfaces in source that are already connected to destination.
90 *
91 * \param source_component_interface Component interface with outgoing data flow
92 * \param destination_component_interface Component interface with incoming data flow
93 * \param connect_derived_interfaces Whether to connect sub- and superclass port composite interfaces
94 * \param connect_to_nested_source_interfaces Whether to connect unconnected destination interfaces to nested source interfaces also
95 */
96void ConnectUnconnectedMatchingInterfaces(core::tPortGroup& source_component_interface, core::tPortGroup& destination_component_interface, bool connect_derived_interfaces = false, bool connect_to_nested_source_interfaces = false);
97
98//----------------------------------------------------------------------
99// End of namespace declaration
100//----------------------------------------------------------------------
101}
102}
103
104#include "plugins/composite_ports/auto_connect.hpp"
105
106#endif
Note: See TracBrowser for help on using the repository browser.