ContRap-Core
|
Class Library is a library descriptor. More...
#include <library.h>
Data Structures | |
class | ObjectInfo |
Internal class to save meta information together with the object implementation. More... | |
Public Types | |
enum | OpenMode { NO_CHANGE, LOCAL, GLOBAL } |
Open mode of the library. More... | |
Public Member Functions | |
Library (const std::string &file_name="", OpenMode mode=GLOBAL) | |
Creates a new library manager. | |
~Library () | |
Relases the memory. | |
const std::string & | get_name () |
Returns the name of the library. | |
std::string | get_brief_info () |
Returns the brief library information. | |
std::string | get_info () |
Returns the full library information. | |
const std::string & | get_file_name () |
Returns the file name of the library. | |
const std::string & | get_init_code () |
Returns the code, which should be executed on startup. | |
std::vector< std::string > | get_dependencies () |
Returns the list of dependent libraries. | |
const std::vector< std::string > & | get_functions () |
Returns the list of function names in the current library, where each function name is unique. | |
SPtr< AtomicFunction > | get_function (const std::string &function) |
Returns all the functions from the library with the given name as a function sequence. | |
ModuleInfo * | get_function_info (const std::string &function) |
Returns the meta info of a function. | |
void | link_extends (const SPtr< Scope > &scope) |
Links extends within for the base scope. | |
bool | update (OpenMode mode=NO_CHANGE) |
Updates the information stored in the library. | |
void | unload () |
Unloads the library. | |
void | clear () |
Cleans up the function pools. | |
bool | is_loaded () |
Returns if the library is loaded. | |
OpenMode | get_open_mode () |
Returns the open mode of the library. | |
XMLDataPool * | get_library_info () |
Returns library information or zero pointer if no library is found at the given path. | |
Protected Member Functions | |
SPtr< List > | make_arguments (const std::string &key, XMLDataPool *meta_info) |
Internal methods. | |
SPtr< AtomicFunction > | make_function (const std::string &key, XMLDataPool *meta_info, MetaFunction meta_call) |
std::list< Option > | make_options (const std::string &key, XMLDataPool *meta_info) |
Protected Attributes | |
XMLDataPool * | library_identifier |
Library identifier. | |
std::map< std::string, ObjectInfo > | functions |
Association of raw names of the library functions to the meta information. | |
std::vector< std::string > | function_names |
Raw function names. | |
std::string | name |
Name of the library. | |
std::string | file_name |
File name of the library. | |
std::string | init_code |
Init code. | |
time_t | change |
Time of last change. | |
void * | handle |
Library handle. | |
OpenMode | mode |
Open mode of the library. | |
Logger * | logger |
Logger. |
Open mode of the library.
If set to Library::LOCAL the library is loaded with a local symbol resolution mode (see the documentation of dlopen or the documentation of the function open_library() for details). If set to Library::NO_CHANGE the library will be reopend in the same mode.
crp::Library::Library | ( | const std::string & | file_name = "" , |
OpenMode | mode = GLOBAL |
||
) |
Creates a new library manager.
This method does not load the library. Use update() to load the library.
file_name | Name of the library file |
mode | If set to Library::LOCAL the library will open with local symbol realocation. If set to Library::GLOBAL global realocation is used. If Library::NO_CHANGE is specified, the default mode (Library::GLOBAL) is used. |
crp::Library::~Library | ( | ) |
Relases the memory.
void crp::Library::clear | ( | ) |
Cleans up the function pools.
std::string crp::Library::get_brief_info | ( | ) |
Returns the brief library information.
std::vector<std::string> crp::Library::get_dependencies | ( | ) |
Returns the list of dependent libraries.
const std::string& crp::Library::get_file_name | ( | ) |
Returns the file name of the library.
SPtr<AtomicFunction> crp::Library::get_function | ( | const std::string & | function | ) |
Returns all the functions from the library with the given name as a function sequence.
function | Name of the function |
ModuleInfo* crp::Library::get_function_info | ( | const std::string & | function | ) |
Returns the meta info of a function.
function | Name of the function |
const std::vector<std::string>& crp::Library::get_functions | ( | ) |
Returns the list of function names in the current library, where each function name is unique.
std::string crp::Library::get_info | ( | ) |
Returns the full library information.
const std::string& crp::Library::get_init_code | ( | ) |
Returns the code, which should be executed on startup.
XMLDataPool* crp::Library::get_library_info | ( | ) |
Returns library information or zero pointer if no library is found at the given path.
If the library is not loaded yet, the library is loaded shortly with local relocation and lazy symbol binding and unloaded again.
This function can be used check if a given library is a valid contrap library (e.g. test the result on being non zero).
const std::string& crp::Library::get_name | ( | ) |
Returns the name of the library.
OpenMode crp::Library::get_open_mode | ( | ) |
Returns the open mode of the library.
The mode Library::NO_CHANGE is never returned by this method.
bool crp::Library::is_loaded | ( | ) |
Returns if the library is loaded.
Links extends within for the base scope.
scope | Root scope |
SPtr<List> crp::Library::make_arguments | ( | const std::string & | key, |
XMLDataPool * | meta_info | ||
) | [protected] |
Internal methods.
SPtr<AtomicFunction> crp::Library::make_function | ( | const std::string & | key, |
XMLDataPool * | meta_info, | ||
MetaFunction | meta_call | ||
) | [protected] |
std::list<Option> crp::Library::make_options | ( | const std::string & | key, |
XMLDataPool * | meta_info | ||
) | [protected] |
void crp::Library::unload | ( | ) |
Unloads the library.
bool crp::Library::update | ( | OpenMode | mode = NO_CHANGE | ) |
Updates the information stored in the library.
mode | Open mode of the library |
time_t crp::Library::change [protected] |
Time of last change.
std::string crp::Library::file_name [protected] |
File name of the library.
std::vector<std::string> crp::Library::function_names [protected] |
Raw function names.
std::map<std::string, ObjectInfo> crp::Library::functions [protected] |
Association of raw names of the library functions to the meta information.
void* crp::Library::handle [protected] |
Library handle.
std::string crp::Library::init_code [protected] |
Init code.
XMLDataPool* crp::Library::library_identifier [protected] |
Library identifier.
Logger* crp::Library::logger [protected] |
OpenMode crp::Library::mode [protected] |
Open mode of the library.
std::string crp::Library::name [protected] |
Name of the library.