diff --git a/CMakeLists.txt b/CMakeLists.txt index f9284aade45677b87bcfbcc5a9a366b536b40583..7dafd62f1dcd36919049428014466507f73cb70e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -185,7 +185,7 @@ SET(HDRS_UTILS include/core/utils/converter.h include/core/utils/eigen_assert.h include/core/utils/eigen_predicates.h - include/core/utils/loader.hpp + include/core/utils/loader.h include/core/utils/logging.h include/core/utils/make_unique.h include/core/utils/params_server.h @@ -322,6 +322,7 @@ SET(SRCS_MATH SET(SRCS_UTILS src/utils/converter_utils.cpp src/utils/params_server.cpp + src/utils/loader.cpp ) SET(SRCS_CAPTURE diff --git a/include/core/utils/loader.h b/include/core/utils/loader.h new file mode 100644 index 0000000000000000000000000000000000000000..6f1a4cc68c2d0dcb20a6ef18f53ec259507fc176 --- /dev/null +++ b/include/core/utils/loader.h @@ -0,0 +1,32 @@ +#ifndef LOADER_H +#define LOADER_H + +#include <string> + +class Loader{ +protected: + std::string path_; +public: + Loader(std::string _file); + virtual void load() = 0; + virtual void close() = 0; +}; + +class LoaderRaw: public Loader{ + void* resource_; +public: + LoaderRaw(std::string _file); + ~LoaderRaw(); + void load(); + void close(); +}; +// class LoaderPlugin: public Loader{ +// ClassLoader* resource_; +// void load(){ +// this->resource_ = new ClassLoader(this->path_); +// } +// void close(){ +// delete this->resource_; +// } +// }; +#endif diff --git a/include/core/utils/loader.hpp b/include/core/utils/loader.hpp deleted file mode 100644 index 3d867d799b36bfd53fb42e93577554caf1b050c1..0000000000000000000000000000000000000000 --- a/include/core/utils/loader.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef LOADER_HPP -#define LOADER_HPP -#include <dlfcn.h> -#include <string> -#include <stdexcept> -class Loader{ -protected: - std::string path_; -public: - Loader(std::string _file){ - this->path_ = _file; - } - virtual void load() = 0; - virtual void close() = 0; -}; -class LoaderRaw: public Loader{ - void* resource_; -public: - LoaderRaw(std::string _file): - Loader(_file) - { - // - } - ~LoaderRaw(){ - this->close(); - } - void load(){ - this->resource_ = dlopen(this->path_.c_str(), RTLD_LAZY); - if(not this->resource_) - throw std::runtime_error("Couldn't load resource with path " + this->path_ + "\n" + "Error info: " + dlerror()); - } - void close(){ - if(this->resource_) dlclose(this->resource_); - } -}; -// class LoaderPlugin: public Loader{ -// ClassLoader* resource_; -// void load(){ -// this->resource_ = new ClassLoader(this->path_); -// } -// void close(){ -// delete this->resource_; -// } -// }; -#endif \ No newline at end of file diff --git a/src/problem/problem.cpp b/src/problem/problem.cpp index eb2cb35db83742c81cd08dc197cd9addfa614a56..8e74f8411fcad44e8c8fcc8fbfd62bf96e8d0f90 100644 --- a/src/problem/problem.cpp +++ b/src/problem/problem.cpp @@ -13,7 +13,7 @@ #include "core/state_block/state_block.h" #include "core/utils/logging.h" #include "core/utils/params_server.h" -#include "core/utils/loader.hpp" +#include "core/utils/loader.h" #include "core/utils/check_log.hpp" diff --git a/src/utils/loader.cpp b/src/utils/loader.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9fdf6984b6a3de57fa8a8ae062232a685897209f --- /dev/null +++ b/src/utils/loader.cpp @@ -0,0 +1,37 @@ +#include "core/utils/loader.h" + +#include <dlfcn.h> +#include <stdexcept> + +Loader::Loader(std::string _file) +{ + path_ = _file; +} +LoaderRaw::LoaderRaw(std::string _file) : Loader(_file) +{ + // +} +LoaderRaw::~LoaderRaw() +{ + close(); +} +void LoaderRaw::load() +{ + resource_ = dlopen(path_.c_str(), RTLD_LAZY); + if (not resource_) + throw std::runtime_error("Couldn't load resource with path " + path_ + "\n" + "Error info: " + dlerror()); +} +void LoaderRaw::close() +{ + if (resource_) + dlclose(resource_); +} +// class LoaderPlugin: public Loader{ +// ClassLoader* resource_; +// void load(){ +// resource_ = new ClassLoader(path_); +// } +// void close(){ +// delete resource_; +// } +// };