source: finroc_plugins_composite_ports/interface_types.h

tip
Last change on this file was 28:0d9e9fd957de, checked in by Max Reichardt <max.reichardt@…>, 6 months ago

Fixes GetFullInterfaceType and GetPartialInterfaceType functions

File size: 3.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/interface_types.h
23 *
24 * \author  Max Reichardt
25 *
26 * \date    2021-03-20
27 *
28 * Utility functions for handling port composite interface types
29 *
30 */
31//----------------------------------------------------------------------
32#ifndef __plugins__composite_ports__interface_types_h__
33#define __plugins__composite_ports__interface_types_h__
34
35//----------------------------------------------------------------------
36// External includes (system with <>, local with "")
37//----------------------------------------------------------------------
38
39//----------------------------------------------------------------------
40// Internal includes with ""
41//----------------------------------------------------------------------
42#include "plugins/composite_ports/internal/tInterfaceTypeInfo.h"
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 * \param type Data type to check
62 * \return Is specified data type a port composite interface type?
63 */
64inline bool IsInterfaceType(const rrlib::rtti::tType& type)
65{
66  return type.GetTypeClassification() == rrlib::rtti::tTypeClassification::PORT_COMPOSITE_INTERFACE;
67}
68
69/*!
70 * \param type Data type
71 * \return Full interface type if type is a port composite interface type - possibly a partial interface type
72 */
73inline rrlib::rtti::tType GetFullInterfaceType(const rrlib::rtti::tType& type)
74{
75  return IsInterfaceType(type) ? static_cast<const internal::tInterfaceTypeInfo&>(type.SharedTypeInfo()).GetFullType() : rrlib::rtti::tType();
76}
77
78/*!
79 * \param type Data type
80 * \return Partial interface type if type is a port composite interface type with a partial interface type
81 */
82inline rrlib::rtti::tType GetPartialInterfaceType(const rrlib::rtti::tType& type)
83{
84  return IsInterfaceType(type) ? static_cast<const internal::tInterfaceTypeInfo&>(type.SharedTypeInfo()).GetPartialType() : rrlib::rtti::tType();
85}
86
87/*!
88 * \param type Data type to check
89 * \return Is specified data type a partial port composite interface type?
90 */
91inline bool IsPartialInterfaceType(const rrlib::rtti::tType& type)
92{
93  return GetPartialInterfaceType(type) == type;
94}
95
96/*!
97 * \param base_type Base type
98 * \param type Type to check
99 * \return Whether base_type is base interface of type to check (possibly over multiple levels)
100 */
101bool IsDerivedFrom(const rrlib::rtti::tType& base_type, const rrlib::rtti::tType& type);
102
103
104//----------------------------------------------------------------------
105// End of namespace declaration
106//----------------------------------------------------------------------
107}
108}
109
110
111#endif
Note: See TracBrowser for help on using the repository browser.