Removed comment header and global scope operators

This commit is contained in:
Bob Polis 2022-09-14 09:55:51 +02:00
parent e7bb903f03
commit e44b5c79c3

View File

@ -1,11 +1,3 @@
//
// plugin.hpp
// plugins
//
// Created by Bob Polis at 2019-06-09
// Copyright (c) 2019 SwiftCoder. All rights reserved.
//
#ifndef _plugin_H_
#define _plugin_H_
@ -25,10 +17,10 @@ namespace sc {
class plugin {
public:
static void scan_plugins(const std::string& dir, const std::string& ext) {
DIR* plugins_dir = ::opendir(dir.c_str());
DIR* plugins_dir = opendir(dir.c_str());
throw_if_null_msg(plugins_dir, (dir + " could not be opened").c_str());
struct dirent* info;
while ((info = ::readdir(plugins_dir)) != nullptr) {
while ((info = readdir(plugins_dir)) != nullptr) {
if (info->d_name[0] != '.') {
std::string plugname {info->d_name};
std::string::size_type lastdot = plugname.rfind(".");
@ -39,7 +31,7 @@ namespace sc {
}
}
}
throw_if_min1(::closedir(plugins_dir));
throw_if_min1(closedir(plugins_dir));
}
using processor = std::function<void(const plugin&)>;
@ -64,12 +56,12 @@ namespace sc {
static size_t count() { return plugins.size(); }
plugin(const std::string& path) : _path {path} {
_plugin = ::dlopen(path.c_str(), RTLD_LAZY);
_plugin = dlopen(path.c_str(), RTLD_LAZY);
const char* err {::dlerror()};
const char* err {dlerror()};
if (err) std::cerr << err << '\n';
if (_plugin) {
_factory = reinterpret_cast<factory>(::dlsym(_plugin, "create_instance"));
_factory = reinterpret_cast<factory>(dlsym(_plugin, "create_instance"));
if (!_factory) {
std::cerr << "create_instance() function not found in " << path << '\n';
}
@ -78,7 +70,7 @@ namespace sc {
~plugin() {
if (_plugin) {
::dlclose(_plugin);
dlclose(_plugin);
_plugin = nullptr;
}
}