ServicePlugin.hpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   tag: The SourceWorks  Tue Sep 7 00:55:18 CEST 2010  ServicePlugin.hpp
00003 
00004                         ServicePlugin.hpp -  description
00005                            -------------------
00006     begin                : Tue September 07 2010
00007     copyright            : (C) 2010 The SourceWorks
00008     email                : peter@thesourceworks.com
00009 
00010  ***************************************************************************
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU General Public                   *
00013  *   License as published by the Free Software Foundation;                 *
00014  *   version 2 of the License.                                             *
00015  *                                                                         *
00016  *   As a special exception, you may use this file as part of a free       *
00017  *   software library without restriction.  Specifically, if other files   *
00018  *   instantiate templates or use macros or inline functions from this     *
00019  *   file, or you compile this file and link it with other files to        *
00020  *   produce an executable, this file does not by itself cause the         *
00021  *   resulting executable to be covered by the GNU General Public          *
00022  *   License.  This exception does not however invalidate any other        *
00023  *   reasons why the executable file might be covered by the GNU General   *
00024  *   Public License.                                                       *
00025  *                                                                         *
00026  *   This library is distributed in the hope that it will be useful,       *
00027  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00028  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00029  *   Lesser General Public License for more details.                       *
00030  *                                                                         *
00031  *   You should have received a copy of the GNU General Public             *
00032  *   License along with this library; if not, write to the Free Software   *
00033  *   Foundation, Inc., 59 Temple Place,                                    *
00034  *   Suite 330, Boston, MA  02111-1307  USA                                *
00035  *                                                                         *
00036  ***************************************************************************/
00037 
00038 
00039 #ifndef ORO_SERVICEPLUGIN_HPP_
00040 #define ORO_SERVICEPLUGIN_HPP_
00041 
00042 #include "Plugin.hpp"
00043 #include <string>
00044 #include "../TaskContext.hpp"
00045 #include "../internal/GlobalService.hpp"
00046 
00047 namespace RTT {
00048     namespace plugin {
00049 
00050     }
00051 }
00052 
00053 #define ORO_SERVICEPLUGIN_xstr(s) ORO_SERVICEPLUGIN_str(s)
00054 #define ORO_SERVICEPLUGIN_str(s) #s
00055 
00056 // Disable foo() has C-linkage specified, but returns UDT 'bar' which is incompatible with C
00057 #ifdef _MSC_VER
00058 #pragma warning (disable:4190)
00059 #endif
00060 
00072 #define ORO_SERVICE_NAMED_PLUGIN( SERVICE, NAME ) \
00073     extern "C" {\
00074         RTT_EXPORT bool loadRTTPlugin(RTT::TaskContext* tc);  \
00075         bool loadRTTPlugin(RTT::TaskContext* tc) {    \
00076             if (tc == 0) return true; \
00077             RTT::Service::shared_ptr sp( new SERVICE( tc ) ); \
00078             return tc->provides()->addService( sp ); \
00079         } \
00080         RTT_EXPORT RTT::Service::shared_ptr createService();  \
00081         RTT::Service::shared_ptr createService() {    \
00082             RTT::Service::shared_ptr sp( new SERVICE( 0 ) ); \
00083             return sp; \
00084         } \
00085         RTT_EXPORT std::string getRTTPluginName(); \
00086         std::string getRTTPluginName() { \
00087             return NAME; \
00088         } \
00089         RTT_EXPORT std::string getRTTTargetName(); \
00090         std::string getRTTTargetName() { \
00091             return OROCOS_TARGET_NAME; \
00092         } \
00093     }
00094 
00106 #define ORO_SERVICE_PLUGIN( SERVICE ) \
00107     extern "C" {                      \
00108         RTT_EXPORT bool loadRTTPlugin(RTT::TaskContext* tc); \
00109         bool loadRTTPlugin(RTT::TaskContext* tc) {    \
00110             if (tc == 0) return true; \
00111             RTT::Service::shared_ptr sp( new SERVICE( tc ) ); \
00112             return tc->provides()->addService( sp ); \
00113         } \
00114         RTT_EXPORT RTT::Service::shared_ptr createService();  \
00115         RTT::Service::shared_ptr createService() {    \
00116             RTT::Service::shared_ptr sp( new SERVICE( 0 ) ); \
00117             return sp; \
00118         } \
00119         RTT_EXPORT std::string getRTTPluginName(); \
00120         std::string getRTTPluginName() { \
00121             return ORO_SERVICEPLUGIN_xstr(SERVICE); \
00122         } \
00123         RTT_EXPORT std::string getRTTTargetName(); \
00124         std::string getRTTTargetName() { \
00125             return OROCOS_TARGET_NAME; \
00126         } \
00127     }
00128 
00138 #define ORO_GLOBAL_SERVICE_NAMED_PLUGIN( SERVICE, NAME ) \
00139     extern "C" {\
00140         RTT_EXPORT bool loadRTTPlugin(RTT::TaskContext* tc);  \
00141         bool loadRTTPlugin(RTT::TaskContext* tc) {    \
00142             if (tc != 0) return false; \
00143             RTT::Service::shared_ptr sp( new SERVICE( tc ) ); \
00144             return RTT::internal::GlobalService::Instance()->addService( sp ); \
00145         } \
00146         RTT_EXPORT RTT::Service::shared_ptr createService();  \
00147         RTT::Service::shared_ptr createService() {    \
00148             RTT::Service::shared_ptr sp( new SERVICE( 0 ) ); \
00149             return sp; \
00150         } \
00151         RTT_EXPORT std::string getRTTPluginName(); \
00152         std::string getRTTPluginName() { \
00153             return NAME; \
00154         } \
00155         RTT_EXPORT std::string getRTTTargetName(); \
00156         std::string getRTTTargetName() { \
00157             return OROCOS_TARGET_NAME; \
00158         } \
00159     }
00160 
00170 #define ORO_GLOBAL_SERVICE_PLUGIN( SERVICE ) \
00171     extern "C" {                      \
00172         RTT_EXPORT bool loadRTTPlugin(RTT::TaskContext* tc); \
00173         bool loadRTTPlugin(RTT::TaskContext* tc) {    \
00174             if (tc != 0) return false; \
00175             RTT::Service::shared_ptr sp( new SERVICE( tc ) ); \
00176             return RTT::internal::GlobalService::Instance()->addService( sp ); \
00177         } \
00178         RTT_EXPORT RTT::Service::shared_ptr createService();  \
00179         RTT::Service::shared_ptr createService() {    \
00180             RTT::Service::shared_ptr sp( new SERVICE( 0 ) ); \
00181             return sp; \
00182         } \
00183         RTT_EXPORT std::string getRTTPluginName(); \
00184         std::string getRTTPluginName() { \
00185             return ORO_SERVICEPLUGIN_xstr(SERVICE); \
00186         } \
00187         RTT_EXPORT std::string getRTTTargetName(); \
00188         std::string getRTTTargetName() { \
00189             return OROCOS_TARGET_NAME; \
00190         } \
00191     }
00192 
00193 #endif /* ORO_SERVICEPLUGIN_HPP_ */


rtt
Author(s): RTT Developers
autogenerated on Sat Jun 8 2019 18:46:18