pid-rpath
2.2.8
|
pid-rpath is a package providing an API to ease the management of runtime resources within a PID workspace. Runtime resources may be either configuration files, executables or module libraries. Its usage is completely bound to the use of PID system.
pid-rpath packages provides the mechanisms used to find software resource like files and folders at runtime. Its usage is bound to the use of the PID development methodology.
To use it inside a PID package, first declare the dependency to the pid-package in the root CMakeLists.txt of your package:
Then declare a component (application or library) using PID runtime resource:
In this example, the component your_component_name
declares that it will/may access resources folder1
(a folder) and folder2/file1
(a file) at runtime. These resources' path are defined relative to the package share/resources
folder and will be accessed/written from this relative path.
The component has then to declare its dependency to the rpathlib
library:
or simpler:
Finally, inside the c++ code of your component, include the API of rpathlib
:
That's it your code is ready to use relative runtime path. To do so, anytime you want your code to access a resource at runtime use the PID_PATH
macro. For instance:
If the path used are unknown (because either you do not have created them in project folder or you did not declare them as runtime resources of the component) the system will generate an exception.
The resources may not exist, for instance if you want to write files (typically logs) into a folder. To allow the creation of resources, prefix the path string with the +
symbol:
This way the system will only check that the file may exist: it checks if the resource has been declared as a direct runtime resource by the component your_component_name
or that it is contained in a folder that is a runtime resource of this component. In this case the system does not check for the existence of the finally targetted resource in the filesystem.
Unix systems are supported (including macosx) but some of them have limited support, like Windows. When working with such systems there is no automatic configuration of path resolution mechnism, you must do this configuration by hand. To do this, you must call the PID_EXE
macro at the really beginning of your executable entry point (i.e. the main
function):
The license that applies to the whole package content is CeCILL-C. Please look at the license.txt file at the root of this repository for more details.
pid-rpath has been developed by following authors:
Please contact Robin Passama (robin) - LIRMM/CNRS for more information or questions. .pas sama@ lirm m.fr