ContRap-Core
Data Structures | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes

crp::Library Class Reference

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< AtomicFunctionget_function (const std::string &function)
 Returns all the functions from the library with the given name as a function sequence.
ModuleInfoget_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.
XMLDataPoolget_library_info ()
 Returns library information or zero pointer if no library is found at the given path.

Protected Member Functions

SPtr< Listmake_arguments (const std::string &key, XMLDataPool *meta_info)
 Internal methods.
SPtr< AtomicFunctionmake_function (const std::string &key, XMLDataPool *meta_info, MetaFunction meta_call)
std::list< Optionmake_options (const std::string &key, XMLDataPool *meta_info)

Protected Attributes

XMLDataPoollibrary_identifier
 Library identifier.
std::map< std::string, ObjectInfofunctions
 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.
Loggerlogger
 Logger.

Detailed Description

Class Library is a library descriptor.


Member Enumeration Documentation

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.

Enumerator:
NO_CHANGE 
LOCAL 
GLOBAL 

Constructor & Destructor Documentation

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.

Parameters:
file_nameName of the library file
modeIf 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.


Member Function Documentation

void crp::Library::clear ( )

Cleans up the function pools.

std::string crp::Library::get_brief_info ( )

Returns the brief library information.

Returns:
Brief info of the library
std::vector<std::string> crp::Library::get_dependencies ( )

Returns the list of dependent libraries.

Returns:
List of library names
const std::string& crp::Library::get_file_name ( )

Returns the file name of the library.

Returns:
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.

Parameters:
functionName of the function
Returns:
Pointer to the functions
ModuleInfo* crp::Library::get_function_info ( const std::string &  function)

Returns the meta info of a function.

Parameters:
functionName of the function
Returns:
Meta info 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.

Returns:
List of function names
std::string crp::Library::get_info ( )

Returns the full library information.

Returns:
Brief info of the library
const std::string& crp::Library::get_init_code ( )

Returns the code, which should be executed on startup.

Returns:
Init code
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).

Returns:
Library identifier or a zero pointer
const std::string& crp::Library::get_name ( )

Returns the name of the library.

Returns:
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.

Returns:
Open mode of the library
bool crp::Library::is_loaded ( )

Returns if the library is loaded.

Returns:
True if the library is loaded.
void crp::Library::link_extends ( const SPtr< Scope > &  scope)

Links extends within for the base scope.

Parameters:
scopeRoot 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.

Parameters:
modeOpen mode of the library
Returns:
Returns true if the library was loaded

Field Documentation

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.

Library identifier.

Open mode of the library.

std::string crp::Library::name [protected]

Name of the library.


The documentation for this class was generated from the following file: