Orocos Real-Time Toolkit  2.5.0
GlobalService.cpp
00001 #include "GlobalService.hpp"
00002 #include "../plugin/PluginLoader.hpp"
00003 
00004 namespace RTT
00005 {
00006     namespace internal
00007     {
00008         static Service::shared_ptr mserv;
00009 
00010         GlobalService::GlobalService()
00011             : Service( "GlobalService" )
00012         {
00013             addOperation("require", &GlobalService::require, this)
00014                     .doc("Require that a certain service is loaded in the global service.")
00015                     .arg("service_name","The name of the service to load globally.");
00016         }
00017 
00018         GlobalService::~GlobalService()
00019         {
00020         }
00021 
00022         Service::shared_ptr GlobalService::Instance() {
00023             if ( !mserv ) {
00024                 mserv.reset( new GlobalService() );
00025             }
00026             return mserv;
00027         }
00028         void GlobalService::Release() {
00029             mserv.reset();
00030         }
00031 
00032         bool GlobalService::require(const std::string servicename) {
00033             return hasService(servicename) || plugin::PluginLoader::Instance()->loadService(servicename, 0); // load globally.
00034         }
00035     }
00036 
00037 }