Medical Imaging Interaction Toolkit  2024.06.99-fe296c79
Medical Imaging Interaction Toolkit
Micro Services Classes

This category includes classes related to the C++ Micro Services component. More...

Collaboration diagram for Micro Services Classes:

Namespaces

 us::ServiceConstants
 

Classes

class  us::LDAPFilter
 
class  us::Module
 
struct  us::ModuleActivator
 
class  ModuleContext
 
class  us::ModuleEvent
 
struct  us::ModuleEventHook
 
struct  us::ModuleFindHook
 
class  us::ModuleRegistry
 
class  us::ModuleResource
 
class  us::ModuleResourceStream
 
class  us::ModuleSettings
 
class  us::ModuleVersion
 
struct  us::PrototypeServiceFactory
 
class  us::ServiceEvent
 
struct  ServiceEventListenerHook
 
class  us::ServiceException
 
class  us::ServiceFactory
 
struct  us::ServiceFindHook
 
struct  us::InterfaceType< Interface >
 
struct  us::MakeInterfaceMap< I1, I2, I3 >
 
class  us::ServiceObjects< S >
 
class  us::ServiceObjects< void >
 
class  us::ServiceReferenceBase
 
class  us::ServiceRegistration< I1, I2, I3 >
 
class  us::ServiceRegistrationBase
 
struct  us::TrackedTypeTraitsBase< T, TTT >
 
struct  us::TrackedTypeTraits< S, T * >
 
class  us::ServiceTracker< S, TTT >
 
struct  us::ServiceTrackerCustomizer< S, T >
 

Macros

#define US_EXPORT_MODULE_ACTIVATOR(_activator_type)
 Export a module activator class. More...
 
#define US_INITIALIZE_STATIC_MODULE(_module_name)
 Initialize a static module. More...
 
#define US_IMPORT_MODULE(_module_name)
 Import a static module. More...
 
#define US_INITIALIZE_MODULE
 Creates initialization code for a module. More...
 
#define US_DECLARE_SERVICE_INTERFACE(_service_interface_type, _service_interface_id)
 Declare a service interface id. More...
 

Typedefs

typedef std::map< std::string, void * > us::InterfaceMap
 
typedef US_UNORDERED_MAP_TYPE< std::string, Anyus::ServiceProperties
 
typedef ServiceRegistration< void > us::ServiceRegistrationU
 

Functions

static ModuleContextus::GetModuleContext ()
 Returns the module context of the calling module. More...
 
US_Core_EXPORT std::ostream & operator<< (std::ostream &os, const us::LDAPFilter &filter)
 
US_Core_EXPORT std::ostream & operator<< (std::ostream &os, const us::Module &module)
 
US_Core_EXPORT std::ostream & operator<< (std::ostream &os, us::Module const *module)
 
US_MSVC_POP_WARNING US_Core_EXPORT std::ostream & operator<< (std::ostream &os, const us::ModuleResource &resource)
 
US_Core_EXPORT std::ostream & operator<< (std::ostream &os, const us::ModuleVersion &v)
 
template<class T >
std::string us_service_interface_iid ()
 
template<class I1 >
I1 * us::ExtractInterface (const InterfaceMap &map)
 
US_MSVC_POP_WARNING US_Core_EXPORT std::ostream & operator<< (std::ostream &os, const us::ServiceReferenceBase &serviceRef)
 
US_Core_EXPORT std::ostream & us::operator<< (std::ostream &os, ModuleEvent::Type eventType)
 
US_Core_EXPORT std::ostream & us::operator<< (std::ostream &os, const ModuleEvent &event)
 
US_Core_EXPORT std::ostream & us::operator<< (std::ostream &os, const ServiceEvent::Type &type)
 
US_Core_EXPORT std::ostream & us::operator<< (std::ostream &os, const ServiceEvent &event)
 
US_Core_EXPORT std::ostream & operator<< (std::ostream &os, const us::ServiceException &exc)
 

Detailed Description

This category includes classes related to the C++ Micro Services component.

The C++ Micro Services component provides a dynamic service registry based on the service layer as specified in the OSGi R4.2 specifications.

Macro Definition Documentation

◆ US_DECLARE_SERVICE_INTERFACE

#define US_DECLARE_SERVICE_INTERFACE (   _service_interface_type,
  _service_interface_id 
)

Declare a service interface id.

This macro associates the given identifier _service_interface_id (a string literal) to the interface class called _service_interface_type. The Identifier must be unique. For example:

struct ISomeInterace { ... };
US_DECLARE_SERVICE_INTERFACE(ISomeInterface, "com.mycompany.service.ISomeInterface/1.0")

The usage of this macro is optional and the service interface id which is automatically associated with any type is usually good enough (the demangled type name). However, care must be taken if the default id is compared with a string literal hard-coding a service interface id. E.g. the default id for templated types in the STL may differ between platforms. For user-defined types and templates the ids are typically consistent, but platform specific default template arguments will lead to different ids.

This macro is normally used right after the class definition for _service_interface_type, in a header file.

If you want to use US_DECLARE_SERVICE_INTERFACE with interface classes declared in a namespace then you have to make sure the US_DECLARE_SERVICE_INTERFACE macro call is not inside a namespace though. For example:

namespace Foo
{
struct ISomeInterface { ... };
}
US_DECLARE_SERVICE_INTERFACE(Foo::ISomeInterface, "com.mycompany.service.ISomeInterface/1.0")
Parameters
_service_interface_typeThe service interface type.
_service_interface_idA string literal representing a globally unique identifier.

Definition at line 104 of file usServiceInterface.h.

◆ US_EXPORT_MODULE_ACTIVATOR

#define US_EXPORT_MODULE_ACTIVATOR (   _activator_type)

Export a module activator class.

Parameters
_activator_typeThe fully-qualified type-name of the module activator class.

Call this macro after the definition of your module activator to make it accessible by the CppMicroServices library.

Example:

class MyActivator : public ModuleActivator
{
public:
void Load(ModuleContext* /*context*/) override
{ /* register stuff */ }
void Unload(ModuleContext* /*context*/) override
{ /* cleanup */ }
};

Definition at line 119 of file usModuleActivator.h.

◆ US_IMPORT_MODULE

#define US_IMPORT_MODULE (   _module_name)

Import a static module.

Parameters
_module_nameThe name of the module to import.

This macro imports the static module named _module_name.

Inserting this macro into your application's source code will allow you to make use of a static module. It will initialize the static module and calls its ModuleActivator. It the module does not provide an activator, use the US_INITIALIZE_STATIC_MODULE macro instead. Do not forget to actually link the static module to the importing executable or shared library.

Example:

#include <usModuleImport.h>
US_IMPORT_MODULE(MyStaticModule1)
See also
US_INITIALIZE_STATIC_MODULE
US_IMPORT_MODULE_RESOURCES
Static Modules

Definition at line 85 of file usModuleImport.h.

◆ US_INITIALIZE_MODULE

#define US_INITIALIZE_MODULE

Creates initialization code for a module.

Each module which wants to register itself with the CppMicroServices library has to put a call to this macro in one of its source files. Further, the modules source files must be compiled with the US_MODULE_NAME pre-processor definition set to a module-unique identifier.

Calling the US_INITIALIZE_MODULE macro will initialize the module for use with the CppMicroServices library, using a default auto-load directory named after the US_MODULE_NAME definition.

See also
MicroServices_AutoLoading
Remarks
If you are using CMake, consider using the provided CMake macro usFunctionGenerateModuleInit().

Definition at line 57 of file usModuleInitialization.h.

◆ US_INITIALIZE_STATIC_MODULE

#define US_INITIALIZE_STATIC_MODULE (   _module_name)

Initialize a static module.

Parameters
_module_nameThe name of the module to initialize.

This macro initializes the static module named _module_name.

It the module provides an activator, use the US_IMPORT_MODULE macro instead, to ensure that the activator is called. Do not forget to actually link the static module to the importing executable or shared library.

See also
US_IMPORT_MODULE
US_IMPORT_MODULE_RESOURCES
Static Modules

Definition at line 52 of file usModuleImport.h.

Typedef Documentation

◆ InterfaceMap

typedef std::map<std::string, void*> us::InterfaceMap

A map containing interfaces ids and their corresponding service object pointers. InterfaceMap instances represent a complete service object which implements one or more service interfaces. For each implemented service interface, there is an entry in the map with the key being the service interface id and the value a pointer to the service interface implementation.

To create InterfaceMap instances, use the MakeInterfaceMap helper class.

Note
This is a low-level type and should only rarely be used.
See also
MakeInterfaceMap

Definition at line 138 of file usServiceInterface.h.

◆ ServiceProperties

A hash table with std::string as the key type and Any as the value type. It is typically used for passing service properties to ModuleContext::RegisterService.

Definition at line 42 of file usServiceProperties.h.

◆ ServiceRegistrationU

A service registration object of unknown type.

Definition at line 199 of file usServiceRegistration.h.

Function Documentation

◆ ExtractInterface()

template<class I1 >
I1* us::ExtractInterface ( const InterfaceMap map)

Extract a service interface pointer from a given InterfaceMap instance.

Parameters
mapa InterfaceMap instance.
Returns
The service interface pointer for the service interface id of the I1 interface type or nullptr if map does not contain an entry for the given type.
See also
MakeInterfaceMap

Definition at line 330 of file usServiceInterface.h.

◆ GetModuleContext()

static ModuleContext* us::GetModuleContext ( )
inlinestatic

Returns the module context of the calling module.

This function allows easy access to the ModuleContext instance from inside a C++ Micro Services module.

Returns
The ModuleContext of the calling module.

Definition at line 50 of file usGetModuleContext.h.

References us::Module::GetModuleContext().

◆ operator<<() [1/11]

US_Core_EXPORT std::ostream& us::operator<< ( std::ostream &  os,
const ModuleEvent event 
)

◆ operator<<() [2/11]

US_Core_EXPORT std::ostream& us::operator<< ( std::ostream &  os,
const ServiceEvent event 
)

◆ operator<<() [3/11]

US_Core_EXPORT std::ostream& us::operator<< ( std::ostream &  os,
const ServiceEvent::Type type 
)

◆ operator<<() [4/11]

US_Core_EXPORT std::ostream& operator<< ( std::ostream &  os,
const us::LDAPFilter filter 
)

◆ operator<<() [5/11]

US_Core_EXPORT std::ostream& operator<< ( std::ostream &  os,
const us::Module module 
)

◆ operator<<() [6/11]

US_MSVC_POP_WARNING US_Core_EXPORT std::ostream& operator<< ( std::ostream &  os,
const us::ModuleResource resource 
)

◆ operator<<() [7/11]

US_Core_EXPORT std::ostream& operator<< ( std::ostream &  os,
const us::ModuleVersion v 
)

◆ operator<<() [8/11]

US_Core_EXPORT std::ostream& operator<< ( std::ostream &  os,
const us::ServiceException exc 
)

◆ operator<<() [9/11]

US_MSVC_POP_WARNING US_Core_EXPORT std::ostream& operator<< ( std::ostream &  os,
const us::ServiceReferenceBase serviceRef 
)

◆ operator<<() [10/11]

US_Core_EXPORT std::ostream& us::operator<< ( std::ostream &  os,
ModuleEvent::Type  eventType 
)

◆ operator<<() [11/11]

US_Core_EXPORT std::ostream& operator<< ( std::ostream &  os,
us::Module const *  module 
)

◆ us_service_interface_iid()

template<class T >
std::string us_service_interface_iid ( )

Returns a unique id for a given type. By default, the demangled name of T is returned.

This template method may be specialized directly or be using the macro US_DECLARE_SERVICE_INTERFACE to return a custom id for each service interface.

Template Parameters
TThe service interface type.
Returns
A unique id for the service interface type T.

Definition at line 50 of file usServiceInterface.h.

References us::GetDemangledName(), and US_PREPEND_NAMESPACE.

usModuleImport.h
usServiceInterface.h
ModuleContext
Definition: usModuleContext.h:91
US_DECLARE_SERVICE_INTERFACE
#define US_DECLARE_SERVICE_INTERFACE(_service_interface_type, _service_interface_id)
Declare a service interface id.
Definition: usServiceInterface.h:104
US_EXPORT_MODULE_ACTIVATOR
#define US_EXPORT_MODULE_ACTIVATOR(_activator_type)
Export a module activator class.
Definition: usModuleActivator.h:119
US_IMPORT_MODULE
#define US_IMPORT_MODULE(_module_name)
Import a static module.
Definition: usModuleImport.h:85