PLaSK library

Loading...
Searching...
No Matches
manager.hpp
Go to the documentation of this file.
1/*
2 * This file is part of PLaSK (https://plask.app) by Photonics Group at TUL
3 * Copyright (c) 2022 Lodz University of Technology
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14#ifndef PLASK__UTILS_DYNLIB_MANAGER_H
15#define PLASK__UTILS_DYNLIB_MANAGER_H
16
17#include "loader.hpp"
18#include <set>
19
20 namespace plask {
21
30 class PLASK_API DynamicLibraries {
31
33 typedef std::set<DynamicLibrary> DynamicLibrarySet;
34
36 DynamicLibrarySet loaded;
37
38 public:
39
41 typedef DynamicLibrarySet::const_iterator iterator;
42
44 typedef DynamicLibrarySet::const_iterator const_iterator;
45
46 DynamicLibraries() = default;
47 DynamicLibraries(const DynamicLibraries&) = delete; // MSVC require this since DynamicLibrarySet is not-copyable
48 DynamicLibraries& operator=(const DynamicLibraries&) = delete; // MSVC require this since DynamicLibrarySet is not-copyable
49 DynamicLibraries(DynamicLibraries&&) = default;
50 DynamicLibraries& operator=(DynamicLibraries&&) = default;
51
56 const_iterator begin() const { return loaded.begin(); }
57
62 const_iterator end() const { return loaded.end(); }
63
72 const DynamicLibrary& load(const std::string& file_name, unsigned flags=0);
73
78 void close(const DynamicLibrary& to_close);
79
81 void closeAll();
82
87 static DynamicLibraries& defaultSet();
88
97 static const DynamicLibrary& defaultLoad(const std::string& file_name, unsigned flags=0) { return defaultSet().load(file_name, flags); }
98
103 static void defaultClose(const DynamicLibrary& to_close) { defaultSet().close(to_close); }
104
106 static void defaultCloseAll() { defaultSet().closeAll(); }
107
108};
109
110
111} // namespace plask
112
113#endif // PLASK__UTILS_DYNLIB_MANAGER_H