Orocos Real-Time Toolkit  2.8.3
ServicePlugin.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: The SourceWorks Tue Sep 7 00:55:18 CEST 2010 ServicePlugin.hpp
3 
4  ServicePlugin.hpp - description
5  -------------------
6  begin : Tue September 07 2010
7  copyright : (C) 2010 The SourceWorks
8  email : peter@thesourceworks.com
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 
39 #ifndef ORO_SERVICEPLUGIN_HPP_
40 #define ORO_SERVICEPLUGIN_HPP_
41 
42 #include "Plugin.hpp"
43 #include <string>
44 #include "../TaskContext.hpp"
45 #include "../internal/GlobalService.hpp"
46 
47 namespace RTT {
48  namespace plugin {
49 
50  }
51 }
52 
53 #define ORO_SERVICEPLUGIN_xstr(s) ORO_SERVICEPLUGIN_str(s)
54 #define ORO_SERVICEPLUGIN_str(s) #s
55 
56 // Disable foo() has C-linkage specified, but returns UDT 'bar' which is incompatible with C
57 #ifdef _MSC_VER
58 #pragma warning (disable:4190)
59 #endif
60 
72 #define ORO_SERVICE_NAMED_PLUGIN( SERVICE, NAME ) \
73  extern "C" {\
74  RTT_EXPORT bool loadRTTPlugin(RTT::TaskContext* tc); \
75  bool loadRTTPlugin(RTT::TaskContext* tc) { \
76  if (tc == 0) return true; \
77  RTT::Service::shared_ptr sp( new SERVICE( tc ) ); \
78  return tc->provides()->addService( sp ); \
79  } \
80  RTT_EXPORT RTT::Service::shared_ptr createService(); \
81  RTT::Service::shared_ptr createService() { \
82  RTT::Service::shared_ptr sp( new SERVICE( 0 ) ); \
83  return sp; \
84  } \
85  RTT_EXPORT std::string getRTTPluginName(); \
86  std::string getRTTPluginName() { \
87  return NAME; \
88  } \
89  RTT_EXPORT std::string getRTTTargetName(); \
90  std::string getRTTTargetName() { \
91  return OROCOS_TARGET_NAME; \
92  } \
93  }
94 
106 #define ORO_SERVICE_PLUGIN( SERVICE ) \
107  extern "C" { \
108  RTT_EXPORT bool loadRTTPlugin(RTT::TaskContext* tc); \
109  bool loadRTTPlugin(RTT::TaskContext* tc) { \
110  if (tc == 0) return true; \
111  RTT::Service::shared_ptr sp( new SERVICE( tc ) ); \
112  return tc->provides()->addService( sp ); \
113  } \
114  RTT_EXPORT RTT::Service::shared_ptr createService(); \
115  RTT::Service::shared_ptr createService() { \
116  RTT::Service::shared_ptr sp( new SERVICE( 0 ) ); \
117  return sp; \
118  } \
119  RTT_EXPORT std::string getRTTPluginName(); \
120  std::string getRTTPluginName() { \
121  return ORO_SERVICEPLUGIN_xstr(SERVICE); \
122  } \
123  RTT_EXPORT std::string getRTTTargetName(); \
124  std::string getRTTTargetName() { \
125  return OROCOS_TARGET_NAME; \
126  } \
127  }
128 
138 #define ORO_GLOBAL_SERVICE_NAMED_PLUGIN( SERVICE, NAME ) \
139  extern "C" {\
140  RTT_EXPORT bool loadRTTPlugin(RTT::TaskContext* tc); \
141  bool loadRTTPlugin(RTT::TaskContext* tc) { \
142  if (tc != 0) return false; \
143  RTT::Service::shared_ptr sp( new SERVICE( tc ) ); \
144  return RTT::internal::GlobalService::Instance()->addService( sp ); \
145  } \
146  RTT_EXPORT RTT::Service::shared_ptr createService(); \
147  RTT::Service::shared_ptr createService() { \
148  RTT::Service::shared_ptr sp( new SERVICE( 0 ) ); \
149  return sp; \
150  } \
151  RTT_EXPORT std::string getRTTPluginName(); \
152  std::string getRTTPluginName() { \
153  return NAME; \
154  } \
155  RTT_EXPORT std::string getRTTTargetName(); \
156  std::string getRTTTargetName() { \
157  return OROCOS_TARGET_NAME; \
158  } \
159  }
160 
170 #define ORO_GLOBAL_SERVICE_PLUGIN( SERVICE ) \
171  extern "C" { \
172  RTT_EXPORT bool loadRTTPlugin(RTT::TaskContext* tc); \
173  bool loadRTTPlugin(RTT::TaskContext* tc) { \
174  if (tc != 0) return false; \
175  RTT::Service::shared_ptr sp( new SERVICE( tc ) ); \
176  return RTT::internal::GlobalService::Instance()->addService( sp ); \
177  } \
178  RTT_EXPORT RTT::Service::shared_ptr createService(); \
179  RTT::Service::shared_ptr createService() { \
180  RTT::Service::shared_ptr sp( new SERVICE( 0 ) ); \
181  return sp; \
182  } \
183  RTT_EXPORT std::string getRTTPluginName(); \
184  std::string getRTTPluginName() { \
185  return ORO_SERVICEPLUGIN_xstr(SERVICE); \
186  } \
187  RTT_EXPORT std::string getRTTTargetName(); \
188  std::string getRTTTargetName() { \
189  return OROCOS_TARGET_NAME; \
190  } \
191  }
192 
193 #endif /* ORO_SERVICEPLUGIN_HPP_ */
This file defines the Orocos plugin API.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:51