The C++ Micro Services library provides a generic resources system to embed arbitrary files into a module's shared library (the current size limitation is based on the largest source code file size your compiler can handle).
The following features are supported:
Resources are embedded by compiling a source file generated by the usResourceCompiler
executable into a module's shared or static library (or into an executable).
If you are using CMake, consider using the provided usFunctionEmbedResources
CMake macro which handles the invocation of the usResourceCompiler
executable and sets up the correct file dependencies.
Each module provides access to its embedded resources via the Module class which provides methods returning ModuleResource objects. The ModuleResourceStream class provides a std::istream compatible object to access the resource contents.
The following example shows how to retrieve a resource from each currently loaded module whose path is specified by a module property:
This example could be enhanced to dynamically react to modules being loaded and unloaded, making use of the popular "extender pattern" from OSGi.
Currently, the system has the following limitations:
usResourceCompiler
executable can be compiled into a module's shared library (you can work around this limitation by creating static modules and importing them).