source: finroc_plugins_composite_ports/tInterfaceType.h @ 28:0d9e9fd957de

tip
Last change on this file since 28:0d9e9fd957de was 10:475d7a686fd6, checked in by Max Reichardt <mreichardt@…>, 23 months ago

Adds support for inheritance among port composite interfaces (sub and superclass interfaces can be connected). Change also includes that connecting secondary backends (of port composite interfaces with multiple port types) will not connect the primary. This adds more flexibility/convenience w.r.t. connecting only parts of port composite interfaces.

File size: 4.0 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/tInterfaceType.h
23 *
24 * \author  Max Reichardt
25 *
26 * \date    2020-02-07
27 *
28 * \brief   Contains tInterfaceType
29 *
30 * \b tInterfaceType
31 *
32 * Port composite interface type for rrlib_rtti.
33 * Needs to be initialized once so that rrlib_rtti knows this interface type
34 * (used similarly to rrlib::rtti::tDataType).
35 *
36 */
37//----------------------------------------------------------------------
38#ifndef __plugins__structure__tInterfaceType_h__
39#define __plugins__structure__tInterfaceType_h__
40
41//----------------------------------------------------------------------
42// External includes (system with <>, local with "")
43//----------------------------------------------------------------------
44#include "core/port/tPortGroup.h"
45#include "rrlib/util/tIntegerSequence.h"
46
47//----------------------------------------------------------------------
48// Internal includes with ""
49//----------------------------------------------------------------------
50#include "plugins/composite_ports/internal/tTypeInfo.h"
51
52//----------------------------------------------------------------------
53// Namespace declaration
54//----------------------------------------------------------------------
55namespace finroc
56{
57namespace composite_ports
58{
59
60//----------------------------------------------------------------------
61// Forward declarations / typedefs / enums
62//----------------------------------------------------------------------
63
64//----------------------------------------------------------------------
65// Class declaration
66//----------------------------------------------------------------------
67//! Port composite interface type
68/*!
69 * Port composite interface type for rrlib_rtti.
70 * Needs to be initialized once so that rrlib_rtti knows this interface type
71 * (used similarly to rrlib::rtti::tDataType).
72 */
73template <template <template <typename> class TPrimaryPort, template <typename> class ... TSecondaryPorts> class TInterface>
74class tInterfaceType : public rrlib::rtti::tType
75{
76
77//----------------------------------------------------------------------
78// Public methods and typedefs
79//----------------------------------------------------------------------
80public:
81
82  typedef TInterface<tAnyPortType> tGeneric;
83  typedef internal::tTypeInfo<tGeneric> tHolder;
84
85  tInterfaceType() :
86    rrlib::rtti::tType(&tHolder::cTYPE_INFO)
87  {
88  }
89
90  template <size_t Tchars>
91  tInterfaceType(const char(&name)[Tchars]) :
92    rrlib::rtti::tType(&tHolder::cTYPE_INFO)
93  {
94    GetSharedInfo().SetName(rrlib::util::tManagedConstCharPointer(name, false), &tHolder::cTYPE_INFO);
95  }
96
97  template <typename ... TFunctions>
98  tInterfaceType(const std::string& name) :
99    rrlib::rtti::tType(&tHolder::cTYPE_INFO)
100  {
101    GetSharedInfo().SetName(rrlib::util::tManagedConstCharPointer(name.c_str(), true), &tHolder::cTYPE_INFO);
102  }
103
104//----------------------------------------------------------------------
105// Private fields and methods
106//----------------------------------------------------------------------
107private:
108
109};
110
111//----------------------------------------------------------------------
112// End of namespace declaration
113//----------------------------------------------------------------------
114}
115}
116
117#endif
Note: See TracBrowser for help on using the repository browser.