diff --git a/common/include/villas/config.hpp.in b/common/include/villas/config.hpp.in index 1840b38f8..859c9577e 100644 --- a/common/include/villas/config.hpp.in +++ b/common/include/villas/config.hpp.in @@ -45,10 +45,16 @@ #define HTTP_USER_AGENT PROJECT_NAME " (" PROJECT_BUILD_ID ")" +/* Hard-coded cache line size */ +#if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__) + #define CACHELINE_SIZE 64 +#else + #error "Unsupported architecture" +#endif + /* Paths */ #define PREFIX "@CMAKE_INSTALL_PREFIX@" #define PLUGIN_PATH "@CMAKE_INSTALL_PREFIX@/share/villas/node/plugins" -#define WEB_PATH "@CMAKE_INSTALL_PREFIX@/share/villas/node/web" #define SYSFS_PATH "/sys" #define PROCFS_PATH "/proc" diff --git a/common/include/villas/plugin.hpp b/common/include/villas/plugin.hpp index 1ff5b2970..68b47bf63 100644 --- a/common/include/villas/plugin.hpp +++ b/common/include/villas/plugin.hpp @@ -97,6 +97,11 @@ public: list.push_back(t); } + /* Sort alphabetically */ + list.sort([](const T *a, const T *b) { + return a->getName() < b->getName(); + }); + return list; } @@ -105,40 +110,48 @@ public: dumpList(); }; -class Loader { - -public: - int load(const std::string &path); - int unload(); - - virtual int parse(json_t *json); -}; - class Plugin { friend plugin::Registry; +protected: + Logger logger; + public: Plugin(); - virtual ~Plugin(); + + virtual + ~Plugin(); // copying a plugin doesn't make sense, so explicitly deny it Plugin(Plugin const&) = delete; void operator=(Plugin const&) = delete; - virtual void dump(); + virtual + void dump(); /// Get plugin name - virtual std::string - getName() const = 0; + virtual + std::string getName() const = 0; /// Get plugin type - virtual std::string - getType() const = 0; + virtual + std::string getType() const = 0; // Get plugin description - virtual std::string - getDescription() const = 0; + virtual + std::string getDescription() const = 0; + + virtual + Logger getLogger() + { + if (!logger) { + auto name = fmt::format("{}:{}", getType(), getName()); + logger = logging.get(name); + } + + return logger; + } /** Custom formatter for spdlog */ template @@ -146,17 +159,6 @@ public: { return os << p.getName(); } - -protected: - std::string path; - - virtual - Logger - getLogger() - { - auto name = fmt::format("{}:{}", getType(), getName()); - return logging.get(name); - } }; template diff --git a/common/lib/plugin.cpp b/common/lib/plugin.cpp index aa262926a..efce470ab 100644 --- a/common/lib/plugin.cpp +++ b/common/lib/plugin.cpp @@ -42,55 +42,6 @@ Plugin::~Plugin() Registry::remove(this); } -#if 0 -int -Plugin::parse(json_t *json) -{ - const char *path; - - path = json_string_value(json); - if (!path) - return -1; - - this->path = std::string(path); - this->state = State::PARSED; - - return 0; -} - -int -Plugin::load() -{ - assert(this->state == State::PARSED); - assert(not this->path.empty()); - - this->handle = dlopen(this->path.c_str(), RTLD_NOW); - - if (this->handle == nullptr) - return -1; - - this->state = State::LOADED; - - return 0; -} - -int -Plugin::unload() -{ - int ret; - - assert(this->state == State::LOADED); - - ret = dlclose(this->handle); - if (ret != 0) - return -1; - - this->state = State::UNLOADED; - - return 0; -} -#endif - void Plugin::dump() { diff --git a/common/lib/table.cpp b/common/lib/table.cpp index e306112be..95e8cc2af 100644 --- a/common/lib/table.cpp +++ b/common/lib/table.cpp @@ -104,6 +104,7 @@ void Table::header() } free(col); + free(unit); } logger->info("{}", line1);