Orocos Real-Time Toolkit  2.9.0
GlobalService.cpp
Go to the documentation of this file.
1 #include "GlobalService.hpp"
2 #include "../plugin/PluginLoader.hpp"
3 
4 #include "../os/StartStopManager.hpp"
5 
6 namespace RTT
7 {
8 
9  // Cleanup the GlobalService on termination of the process
10  // This is important if global services have ports that need to be disconnected.
11  namespace {
12  os::CleanupFunction release_global_service(&internal::GlobalService::Release);
13  }
14 
15  namespace internal
16  {
17  static Service::shared_ptr mserv;
18 
19  GlobalService::GlobalService()
20  : Service( "GlobalService" )
21  {
22  addOperation("require", &GlobalService::require, this)
23  .doc("Require that a certain service is loaded in the global service.")
24  .arg("service_name","The name of the service to load globally.");
25  }
26 
28  {
29  }
30 
32  if ( !mserv ) {
33  mserv.reset( new GlobalService() );
34  }
35  return mserv;
36  }
38  mserv.reset();
39  }
40 
41  bool GlobalService::require(const std::string servicename) {
42  return hasService(servicename) || plugin::PluginLoader::Instance()->loadService(servicename, 0); // load globally.
43  }
44  }
45 
46 }
boost::shared_ptr< Service > shared_ptr
Definition: Service.hpp:101
A process-wide services that hosts services not local to a single component.
bool require(const std::string servicename)
Require that a certain service is loaded in the global service.
static boost::shared_ptr< PluginLoader > Instance()
Create the instance of the PluginLoader.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:52
static RTT_API Service::shared_ptr Instance()
static RTT_API void Release()