CppMicroServices

C++ Micro Services: Micro Services Classes
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Micro Services Classes

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

Namespaces

 ServiceConstants
 

Classes

class  Module
 Represents a CppMicroServices module. More...
 
struct  ModuleActivator
 Customizes the starting and stopping of a CppMicroServices module. More...
 
class  ModuleContext
 A module's execution context within the framework. More...
 
class  ModuleEvent
 An event from the Micro Services framework describing a module lifecycle change. More...
 
struct  ModuleEventHook
 Module Event Hook Service. More...
 
struct  ModuleFindHook
 Module Context Hook Service. More...
 
class  ModuleRegistry
 Here we handle all the modules that are loaded in the framework. More...
 
class  ModuleResource
 Represents a resource (text file, image, etc.) embedded in a CppMicroServices module. More...
 
class  ModuleResourceStream
 An input stream class for ModuleResource objects. More...
 
class  ModuleSettings
 Query and set certain properties of the CppMicroServices library. More...
 
class  ModuleVersion
 Version identifier for CppMicroServices modules. More...
 
class  LDAPFilter
 An RFC 1960-based Filter. More...
 
struct  PrototypeServiceFactory
 A factory for prototype scope services. More...
 
class  ServiceEvent
 An event from the Micro Services framework describing a service lifecycle change. More...
 
struct  ServiceEventListenerHook
 Service Event Listener Hook Service. More...
 
class  ServiceException
 A service exception used to indicate that a service problem occurred. More...
 
class  ServiceFactory
 A factory for module scope services. More...
 
struct  ServiceFindHook
 Service Find Hook Service. More...
 
struct  InterfaceType< Interface >
 A helper type used in several methods to get proper method overload resolutions. More...
 
struct  MakeInterfaceMap< I1, I2, I3 >
 Helper class for constructing InterfaceMap instances based on service implementations or service factories. More...
 
struct  ServiceListenerHook
 Service Listener Hook Service. More...
 
class  ServiceObjects< S >
 Allows multiple service objects for a service to be obtained. More...
 
class  ServiceObjects< void >
 Allows multiple service objects for a service to be obtained. More...
 
class  ServiceReference< S >
 A reference to a service. More...
 
class  ServiceReferenceBase
 A reference to a service. More...
 
class  ServiceRegistration< I1, I2, I3 >
 A registered service. More...
 
class  ServiceRegistrationBase
 A registered service. More...
 
struct  TrackedTypeTraitsBase< T, TTT >
 A base class template for type traits for objects tracked by a ServiceTracker instance. More...
 
struct  TrackedTypeTraits< S, T * >
 Default type traits for custom tracked objects of pointer type. More...
 
class  ServiceTracker< S, TTT >
 The ServiceTracker class simplifies using services from the framework's service registry. More...
 
struct  ServiceTrackerCustomizer< S, T >
 The ServiceTrackerCustomizer interface allows a ServiceTracker to customize the service objects that are tracked. More...
 

Macros

#define US_EXPORT_MODULE_ACTIVATOR(_module_libname, _activator_type)
 Export a module activator class. More...
 
#define US_IMPORT_MODULE(_import_module_libname)
 Import a static module. More...
 
#define US_IMPORT_MODULE_RESOURCES(_import_module_libname)
 Import a static module's resources. More...
 
#define US_LOAD_IMPORTED_MODULES_INTO_MAIN(_static_modules)
 Import a list of static modules into an executable. More...
 
#define US_LOAD_IMPORTED_MODULES(_module_libname, _static_modules)
 Import a list of static modules into a shared library. More...
 
#define US_INITIALIZE_MODULE(_module_name, _module_libname)
 Creates initialization code for a module. More...
 
#define US_INITIALIZE_EXECUTABLE(_executable_id)
 Creates initialization code for an executable. More...
 
#define US_DECLARE_SERVICE_INTERFACE(_service_interface_type, _service_interface_id)
 Declare a CppMicroServices service interface. More...
 

Typedefs

typedef std::map< std::string,
void * > 
InterfaceMap
 A map containing interfaces ids and their corresponding service object pointers. More...
 
typedef US_UNORDERED_MAP_TYPE
< std::string, Any
ServiceProperties
 A hash table with std::string as the key type and Any as the value type. More...
 
typedef ServiceReference< void > ServiceReferenceU
 A service reference of unknown type, which is not bound to any interface identifier. More...
 
typedef ServiceRegistration< void > ServiceRegistrationU
 A service registration object of unknown type. More...
 

Functions

ModuleContextGetModuleContext ()
 Returns the module context of the calling module. More...
 
std::ostream & operator<< (std::ostream &os, const Module &module)
 
std::ostream & operator<< (std::ostream &os, Module const *module)
 
std::ostream & operator<< (std::ostream &os, const ModuleResource &resource)
 
std::ostream & operator<< (std::ostream &os, const ModuleVersion &v)
 
std::ostream & operator<< (std::ostream &os, const LDAPFilter &filter)
 
template<class T >
const char * us_service_interface_iid ()
 Returns a unique id for a given type. More...
 
template<class I1 >
I1 * ExtractInterface (const InterfaceMap &map)
 Extract a service interface pointer from a given InterfaceMap instance. More...
 
std::ostream & operator<< (std::ostream &os, const ServiceReferenceBase &serviceRef)
 
std::ostream & operator<< (std::ostream &os, ModuleEvent::Type eventType)
 
std::ostream & operator<< (std::ostream &os, const ModuleEvent &event)
 
US_END_NAMESPACE US_EXPORT
std::ostream & 
operator<< (std::ostream &os, const US_PREPEND_NAMESPACE(ServiceEvent::Type)&type)
 
US_EXPORT std::ostream & operator<< (std::ostream &os, const US_PREPEND_NAMESPACE(ServiceEvent)&event)
 
std::ostream & operator<< (std::ostream &os, const 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

#define US_DECLARE_SERVICE_INTERFACE (   _service_interface_type,
  _service_interface_id 
)

Declare a CppMicroServices service interface.

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:

* #include <usServiceInterface.h>
*
* struct ISomeInterace { ... };
*
* US_DECLARE_SERVICE_INTERFACE(ISomeInterface, "com.mycompany.service.ISomeInterface/1.0")
*

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:

* #include <usServiceInterface.h>
*
* 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.
#define US_EXPORT_MODULE_ACTIVATOR (   _module_libname,
  _activator_type 
)

Export a module activator class.

Parameters
_module_libnameThe physical name of the module, without prefix or suffix.
_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*/)
{ /* register stuff */ }
void Unload(ModuleContext* /*context*/)
{ /* cleanup */ }
};
US_EXPORT_MODULE_ACTIVATOR(mylibname, MyActivator)
Note
If you use this macro in a source file compiled into an executable, additional requirements for the macro arguments apply:
  • The _module_libname argument must match the value of _module_name used in the US_INITIALIZE_MODULE macro call.
#define US_IMPORT_MODULE (   _import_module_libname)

Import a static module.

Parameters
_import_module_libnameThe physical name of the module to import, without prefix or suffix.

This macro imports the static module named _import_module_libname.

Inserting this macro into your application's source code will allow you to make use of a static module. Do not forget to list the imported module when calling the macro US_LOAD_IMPORTED_MODULES and to actually link the static module to the importing executable or shared library.

Example:

#include <usModuleImport.h>
US_IMPORT_MODULE(MyStaticModule)
US_LOAD_IMPORTED_MODULES(HostingModule, MyStaticModule)
See Also
US_LOAD_IMPORTED_MODULES
Static Modules
#define US_IMPORT_MODULE_RESOURCES (   _import_module_libname)

Import a static module's resources.

Parameters
_import_module_libnameThe physical name of the module to import, without prefix or suffix.

This macro imports the resources of the static module named _import_module_libname.

Inserting this macro into your application's source code will allow you to make use of the resources embedded in a static module. Do not forget to list the imported module when calling the macro US_LOAD_IMPORTED_MODULES and to actually link the static module to the importing executable or shared library.

See Also
US_IMPORT_MODULE
US_LOAD_IMPORTED_MODULES
Static Modules
#define US_INITIALIZE_EXECUTABLE (   _executable_id)

Creates initialization code for an executable.

Each executable which wants to register itself with the CppMicroServices library has to put a call to this macro in one of its source files. This ensures that the executable will get its own ModuleContext instance and can access the service registry.

Example call for an executable:

* US_INITIALIZE_EXECUTABLE("my_executable")
*

This will initialize the executable for use with the CppMicroServices library, using a default auto-load directory named after the provided executable id in _executable_id.

See Also
MicroServices_AutoLoading
Remarks
If you are using CMake, consider using the provided CMake macro usFunctionGenerateExecutableInit().
Parameters
_executable_idA valid C identifier for the executable (no spaces etc.).
#define US_INITIALIZE_MODULE (   _module_name,
  _module_libname 
)

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.

Example call for a module with file-name "libmylibname.so":

* US_INITIALIZE_MODULE("My Service Implementation", "mylibname")
*

This will initialize the module for use with the CppMicroServices library, using a default auto-load directory named after the provided library name in _module_libname.

See Also
MicroServices_AutoLoading
Remarks
If you are using CMake, consider using the provided CMake macro usFunctionGenerateModuleInit().
Parameters
_module_nameA human-readable name for the module. If you use this macro in a source file for an executable, the module name must be a valid C-identifier (no spaces etc.).
_module_libnameThe physical name of the module, withou prefix or suffix.
Note
If you want to create initialization code for an executable, see US_INITIALIZE_EXECUTABLE.
#define US_LOAD_IMPORTED_MODULES (   _module_libname,
  _static_modules 
)

Import a list of static modules into a shared library.

Parameters
_module_libnameThe physical name of the importing module, without prefix or suffix.
_static_modulesA space-deliminated list of physical module names, without prefix or suffix.

This macro ensures that the ModuleActivator::Load(ModuleContext*) function is called for each imported static module when the importing shared library is loaded (if the static module provides an activator). If the static module provides embedded resources and the US_IMPORT_MODULE_RESOURCES macro was called, the resources will be made available through the importing module.

There must be exactly one call of this macro in the shared library which is importing static modules.

Example:

#include <usModuleImport.h>
US_IMPORT_MODULE(MyStaticModule)
US_LOAD_IMPORTED_MODULES(HostingModule, MyStaticModule)
See Also
US_IMPORT_MODULE
US_LOAD_IMPORTED_MODULES_INTO_MAIN
Static Modules
#define US_LOAD_IMPORTED_MODULES_INTO_MAIN (   _static_modules)

Import a list of static modules into an executable.

Parameters
_static_modulesA space-deliminated list of physical module names, without prefix or suffix.

This macro ensures that the ModuleActivator::Load(ModuleContext*) function is called for each imported static module when the importing executable is loaded (if the static module provides an activator). If the static module provides embedded resources and the US_IMPORT_MODULE_RESOURCES macro was called, the resources will be made available through the importing module.

There must be exactly one call of this macro in the executable which is importing static modules.

Example:

#include <usModuleImport.h>
US_IMPORT_MODULE(MyStaticModule1)
US_IMPORT_MODULE(MyStaticModule2)
US_LOAD_IMPORTED_MODULES_INTO_MAIN(MyStaticModule1 MyStaticModule2)
See Also
US_IMPORT_MODULE
US_LOAD_IMPORTED_MODULES
Static Modules

Typedef Documentation

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

A map containing interfaces ids and their corresponding service object pointers.

InterfaceMap instances represent a complete service object which implementes 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
typedef US_UNORDERED_MAP_TYPE<std::string, Any> 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.

A service reference of unknown type, which is not bound to any interface identifier.

A service registration object of unknown type.

Function Documentation

template<class I1 >
I1* 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 NULL if map does not contain an entry for the given type.
See Also
MakeInterfaceMap
ModuleContext* GetModuleContext ( )

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.
std::ostream& operator<< ( std::ostream &  os,
const ServiceException exc 
)
std::ostream& operator<< ( std::ostream &  os,
ModuleEvent::Type  eventType 
)
std::ostream& operator<< ( std::ostream &  os,
const ModuleEvent event 
)
std::ostream& operator<< ( std::ostream &  os,
const LDAPFilter filter 
)
US_END_NAMESPACE US_EXPORT std::ostream& operator<< ( std::ostream &  os,
const US_PREPEND_NAMESPACE(ServiceEvent::Type)&  type 
)
US_EXPORT std::ostream& operator<< ( std::ostream &  os,
const US_PREPEND_NAMESPACE(ServiceEvent)&  event 
)
std::ostream& operator<< ( std::ostream &  os,
const ServiceReferenceBase serviceRef 
)
std::ostream& operator<< ( std::ostream &  os,
const ModuleVersion v 
)
std::ostream& operator<< ( std::ostream &  os,
const ModuleResource resource 
)
std::ostream& operator<< ( std::ostream &  os,
const Module module 
)
std::ostream& operator<< ( std::ostream &  os,
Module const *  module 
)
template<class T >
const char* us_service_interface_iid ( )
inline

Returns a unique id for a given type.

This template method is specialized in the macro US_DECLARE_SERVICE_INTERFACE to return a unique id for each service interface.

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