Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PluginManager.h « plugin « include « audaspace « extern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: af2f469c4ea4f857e83673d6130b3543eef35785 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*******************************************************************************
 * Copyright 2009-2016 Jörg Müller
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

#pragma once

/**
 * @file PluginManager.h
 * @ingroup plugin
 * The PluginManager class.
 */

#include "Audaspace.h"

#include <unordered_map>
#include <string>

AUD_NAMESPACE_BEGIN

/**
 * This manager provides utilities for plugin loading.
 */
class AUD_API PluginManager
{
private:
	static std::unordered_map<std::string, void*> m_plugins;

	// delete copy constructor and operator=
	PluginManager(const PluginManager&) = delete;
	PluginManager& operator=(const PluginManager&) = delete;
	PluginManager() = delete;

public:
	/**
	 * Opens a shared library.
	 * @param path The path to the file.
	 * @return A handle to the library or nullptr if opening failed.
	 */
	static void* openLibrary(const std::string& path);

	/**
	 * Looks up a symbol from an opened library.
	 * @param handle The handle to the opened library.
	 * @param name The name of the symbol to look up.
	 * @return The symbol or nullptr if the symbol was not found.
	 */
	static void* lookupLibrary(void* handle, const std::string& name);

	/**
	 * Closes an opened shared library.
	 * @param handle The handle to the library to be closed.
	 */
	static void closeLibrary(void* handle);

	/**
	 * Loads a plugin from a file.
	 * @param path The path to the file.
	 * @return Whether the file could successfully be loaded.
	 */
	static bool loadPlugin(const std::string& path);

	/**
	 * Loads all plugins found in a folder.
	 * @param path The path to the folder containing the plugins.
	 */
	static void loadPlugins(const std::string& path = "");
};

AUD_NAMESPACE_END