Gazebo Common

API Reference

5.6.0
PluginMacros.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 
19 #ifndef IGNITION_COMMON_REGISTERMACROS_HH_
20 #define IGNITION_COMMON_REGISTERMACROS_HH_
21 
23 #include "ignition/common/detail/PluginMacros.hh"
24 
25 // Deprecated, use gz-plugin
26 
27 // --------------- Specialize a plugin interface (optional) -------------------
28 
55 #define IGN_COMMON_SPECIALIZE_INTERFACE(interfaceName)\
56  DETAIL_IGN_COMMON_SPECIALIZE_INTERFACE(interfaceName)
57 
58 
59 // ------------- Add a set of plugins or a set of interfaces ------------------
60 
61 // The following three macros can be used to produce multiple plugins and/or
62 // multiple interfaces from your shared library.
63 
64 /* Usage example for multiple plugins and one interface:
65  *
66  * IGN_COMMON_BEGIN_ADDING_PLUGINS
67  * IGN_COMMON_ADD_PLUGIN(mylibrary::ns::SomeClass1, mylibrary::ns::SomeInterface)
68  * IGN_COMMON_ADD_PLUGIN(mylibrary::ns::SomeClass2, mylibrary::ns::SomeInterface)
69  * IGN_COMMON_FINISH_ADDING_PLUGINS
70  *
71  *
72  * Usage example for one plugin and multiple interfaces:
73  *
74  * IGN_COMMON_BEGIN_ADDING_PLUGINS
75  * IGN_COMMON_ADD_PLUGIN(mylibrary::ns::SomeClass, mylibrary::ns::Interface1)
76  * IGN_COMMON_ADD_PLUGIN(mylibrary::ns::SomeClass, mylibrary::ns::Interface2)
77  * IGN_COMMON_FINISH_ADDING_PLUGINS
78  *
79  *
80  * Usage example for multiple plugins and multiple interfaces:
81  *
82  * IGN_COMMON_BEGIN_ADDING_PLUGINS
83  * IGN_COMMON_ADD_PLUGIN(mylibrary::ns::SomeClass, mylibrary::ns::FooInterface)
84  * IGN_COMMON_ADD_PLUGIN(mylibrary::ns::SomeOtherClass, mylibrary::ns::BarInterface)
85  * IGN_COMMON_ADD_PLUGIN(mylibrary::ns::SomeClass, mylibrary::ns::SomeInterface)
86  * IGN_COMMON_ADD_PLUGIN(mylibrary::ns::SomeOtherClass, mylibrary::ns::FooInterface)
87  * IGN_COMMON_ADD_PLUGIN(mylibrary::ns::SomeOtherClass, mylibrary::ns::SomeInterface)
88  * IGN_COMMON_FINISH_ADDING_PLUGINS
89  */
90 
91 // Note that the order in which (Plugin, Interface) pairs are added does not
92 // matter. Multiple plugins are allowed to provide the same interface. There is
93 // no inherent limit on the number of interfaces or plugins that are allowed.
94 //
95 // These macros MUST be called in the global namespace in a source file of your
96 // library's codebase. A single library is only allowed to have ONE block of
97 // these macros (i.e. if you find yourself invoking
98 // IGN_COMMON_BEGIN_ADDING_PLUGINS more than once in your library, then you are
99 // doing something that is not permitted). Recommended practice is to have a
100 // single source file (e.g. plugins.cpp) in your library's codebase that is
101 // dedicated to hosting these macros.
102 
103 
112 #define IGN_COMMON_BEGIN_ADDING_PLUGINS\
113  DETAIL_IGN_COMMON_BEGIN_ADDING_PLUGINS
114 
115 
123 #define IGN_COMMON_ADD_PLUGIN(plugin, interface)\
124  DETAIL_IGN_COMMON_ADD_PLUGIN(plugin, interface)
125 
126 
129 #define IGN_COMMON_FINISH_ADDING_PLUGINS\
130  DETAIL_IGN_COMMON_FINISH_ADDING_PLUGINS
131 
132 
133 // -------------- Add a single plugin with a single interface -----------------
134 
140 #define IGN_COMMON_REGISTER_SINGLE_PLUGIN(plugin, interface) \
141  IGN_COMMON_BEGIN_ADDING_PLUGINS\
142  IGN_COMMON_ADD_PLUGIN(plugin, interface)\
143  IGN_COMMON_FINISH_ADDING_PLUGINS
144 
145 #endif