CASM
AClustersApproachtoStatisticalMechanics
|
#include <RuntimeLibrary.hh>
Write, compile, load and use code at runtime.
Definition at line 17 of file RuntimeLibrary.hh.
Public Member Functions | |
RuntimeLibrary (std::string _filename_base, std::string _compile_options, std::string _so_options, std::string compile_msg, const Logging &logging=Logging()) | |
Construct a RuntimeLibrary object, with the options to be used for compile the '.o' file and the '.so' file. More... | |
~RuntimeLibrary () | |
template<typename Signature > | |
std::function< Signature > | get_function (std::string function_name) const |
Obtain a function from the current library. More... | |
void | rm () |
Remove the current library and source code. More... | |
Log & | log () const |
Log & | debug_log () const |
Log & | err_log () const |
Static Public Member Functions | |
static std::pair< std::string, std::string > | default_cxxflags () |
Default c++ compiler options. More... | |
static std::pair< std::string, std::string > | default_soflags () |
Default c++ compiler options. More... | |
static std::pair< std::string, std::string > | default_cxx () |
Return default compiler. More... | |
static std::pair< fs::path, std::string > | default_casm_includedir () |
Return default includedir for CASM. More... | |
static std::pair< fs::path, std::string > | default_casm_libdir () |
Return default libdir for CASM. More... | |
static std::pair< fs::path, std::string > | default_boost_includedir () |
Return default includedir for boost. More... | |
static std::pair< fs::path, std::string > | default_boost_libdir () |
Return default libdir for boost. More... | |
static Logging | null () |
Private Member Functions | |
void | _compile () |
Compile a shared library. More... | |
void | _load () |
Load a library with a given name. More... | |
void | _close () |
Close the current library. More... | |
Private Attributes | |
std::string | m_filename_base |
std::string | m_compile_options |
std::string | m_so_options |
void * | m_handle |
CASM::RuntimeLibrary::RuntimeLibrary | ( | std::string | _filename_base, |
std::string | _compile_options, | ||
std::string | _so_options, | ||
std::string | compile_msg, | ||
const Logging & | logging = Logging() |
||
) |
Construct a RuntimeLibrary object, with the options to be used for compile the '.o' file and the '.so' file.
Definition at line 8 of file RuntimeLibrary.cc.
CASM::RuntimeLibrary::~RuntimeLibrary | ( | ) |
Definition at line 64 of file RuntimeLibrary.cc.
|
private |
Close the current library.
This is also done on destruction.
Definition at line 120 of file RuntimeLibrary.cc.
|
private |
Compile a shared library.
_filename_base | Base name for the source code file. For example, "/path/to/hello" looks for "/path/to/hello.cc", and compile "/path/to/hello.o" and "/path/to/hello.so". |
To enable runtime symbol lookup use C-style functions, i.e use extern "C" for functions you want to use via get_function. This means no member functions or overloaded functions.
Definition at line 81 of file RuntimeLibrary.cc.
|
private |
Load a library with a given name.
_filename_base | For "hello", this loads "hello.so" |
Definition at line 108 of file RuntimeLibrary.cc.
|
static |
Return default includedir for boost.
Return include path option for boost.
Definition at line 332 of file RuntimeLibrary.cc.
|
static |
Return default libdir for boost.
Return lib path option for boost.
Definition at line 361 of file RuntimeLibrary.cc.
|
static |
Return default includedir for CASM.
Return include path option for CASM.
Definition at line 274 of file RuntimeLibrary.cc.
|
static |
Return default libdir for CASM.
Return lib path option for CASM.
Definition at line 303 of file RuntimeLibrary.cc.
|
static |
Return default compiler.
Return default compiler and specifying variable.
Definition at line 252 of file RuntimeLibrary.cc.
|
static |
Default c++ compiler options.
Definition at line 259 of file RuntimeLibrary.cc.
|
static |
Default c++ compiler options.
Default c++ shared library options.
Definition at line 266 of file RuntimeLibrary.cc.
|
inline |
Obtain a function from the current library.
Must be a C-style function to enable symbol lookup, i.e your source code should use extern "C". This means no member functions or overloaded functions.
Definition at line 38 of file RuntimeLibrary.hh.
void CASM::RuntimeLibrary::rm | ( | ) |
Remove the current library and source code.
Definition at line 128 of file RuntimeLibrary.cc.
|
private |
Definition at line 88 of file RuntimeLibrary.hh.
|
private |
Definition at line 87 of file RuntimeLibrary.hh.
|
private |
Definition at line 91 of file RuntimeLibrary.hh.
|
private |
Definition at line 89 of file RuntimeLibrary.hh.