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.cpp |
---|
23 | * |
---|
24 | * \author Max Reichardt |
---|
25 | * |
---|
26 | * \date 2021-03-20 |
---|
27 | * |
---|
28 | */ |
---|
29 | //---------------------------------------------------------------------- |
---|
30 | #include "plugins/composite_ports/interface_types.h" |
---|
31 | |
---|
32 | //---------------------------------------------------------------------- |
---|
33 | // External includes (system with <>, local with "") |
---|
34 | //---------------------------------------------------------------------- |
---|
35 | |
---|
36 | //---------------------------------------------------------------------- |
---|
37 | // Internal includes with "" |
---|
38 | //---------------------------------------------------------------------- |
---|
39 | |
---|
40 | //---------------------------------------------------------------------- |
---|
41 | // Debugging |
---|
42 | //---------------------------------------------------------------------- |
---|
43 | #include <cassert> |
---|
44 | |
---|
45 | //---------------------------------------------------------------------- |
---|
46 | // Namespace usage |
---|
47 | //---------------------------------------------------------------------- |
---|
48 | |
---|
49 | //---------------------------------------------------------------------- |
---|
50 | // Namespace declaration |
---|
51 | //---------------------------------------------------------------------- |
---|
52 | namespace finroc |
---|
53 | { |
---|
54 | namespace composite_ports |
---|
55 | { |
---|
56 | |
---|
57 | //---------------------------------------------------------------------- |
---|
58 | // Forward declarations / typedefs / enums |
---|
59 | //---------------------------------------------------------------------- |
---|
60 | |
---|
61 | //---------------------------------------------------------------------- |
---|
62 | // Const values |
---|
63 | //---------------------------------------------------------------------- |
---|
64 | |
---|
65 | //---------------------------------------------------------------------- |
---|
66 | // Implementation |
---|
67 | //---------------------------------------------------------------------- |
---|
68 | bool IsDerivedFrom(const rrlib::rtti::tType& base_type, const rrlib::rtti::tType& type) |
---|
69 | { |
---|
70 | if (IsInterfaceType(type) && IsInterfaceType(base_type)) |
---|
71 | { |
---|
72 | rrlib::rtti::tType type_to_check = type; |
---|
73 | while (type_to_check) |
---|
74 | { |
---|
75 | if (type_to_check == base_type) |
---|
76 | { |
---|
77 | return true; |
---|
78 | } |
---|
79 | rrlib::rtti::tType parent_type = type_to_check.GetUnderlyingType(); |
---|
80 | if ((!parent_type) || parent_type == type_to_check) |
---|
81 | { |
---|
82 | return false; |
---|
83 | } |
---|
84 | type_to_check = parent_type; |
---|
85 | } |
---|
86 | } |
---|
87 | return false; |
---|
88 | } |
---|
89 | |
---|
90 | //---------------------------------------------------------------------- |
---|
91 | // End of namespace declaration |
---|
92 | //---------------------------------------------------------------------- |
---|
93 | } |
---|
94 | } |
---|