GCC Code Coverage Report


Directory: avs_core/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 0.0% 0 / 0 / 3
Functions: 0.0% 0 / 0 / 2
Branches: -% 0 / 0 / 0

core/PluginManager.h
Line Branch Exec Source
1 #ifndef AVSCORE_PLUGINS_H
2 #define AVSCORE_PLUGINS_H
3
4 #include <string>
5 #include <map>
6 #include <vector>
7 #include "internal.h"
8
9 class InternalEnvironment;
10 struct PluginFile;
11
12 struct StdStriComparer
13 {
14 bool operator() (const std::string& lhs, const std::string& rhs) const
15 {
16 #if defined(MSVC)
17 return (_strcmpi(lhs.c_str(), rhs.c_str()) < 0);
18 #else
19 return (strcasecmp(lhs.c_str(), rhs.c_str()) < 0);
20 #endif
21 }
22 };
23
24 typedef std::vector<const AVSFunction*> FunctionList;
25 typedef std::map<std::string,FunctionList,StdStriComparer> FunctionMap;
26 class PluginManager
27 {
28 private:
29 InternalEnvironment *Env;
30 PluginFile *PluginInLoad;
31 std::vector<std::string> AutoloadDirs;
32 std::vector<PluginFile> AutoLoadedImports;
33 std::vector<PluginFile> AutoLoadedPlugins;
34 std::vector<PluginFile> LoadedPlugins;
35 FunctionMap ExternalFunctions;
36 FunctionMap AutoloadedFunctions;
37 bool AutoloadExecuted;
38 bool Autoloading;
39
40 int TryAsAvs26(PluginFile &plugin, AVSValue *result, std::string& avsexception_message);
41 bool TryAsAvs25(PluginFile &plugin, AVSValue *result);
42 bool TryAsAvsPreV11C(PluginFile& plugin, AVSValue* result);
43 bool TryAsAvsC(PluginFile &plugin, AVSValue *result);
44
45 const AVSFunction* Lookup(const FunctionMap& map,
46 const char* search_name,
47 const AVSValue* args,
48 size_t num_args,
49 bool strict,
50 size_t args_names_count,
51 const char* const* arg_names) const;
52
53
54 public:
55 PluginManager(InternalEnvironment* env);
56 ~PluginManager();
57
58 void ClearAutoloadDirs();
59 void AddAutoloadDir(const std::string &dir_utf8, bool toFront);
60
61 bool LoadPlugin(PluginFile &plugin, bool throwOnError, AVSValue *result);
62 bool LoadPlugin(const char* path, bool throwOnError, AVSValue *result);
63
64 bool HasAutoloadExecuted() const { return AutoloadExecuted; }
65
66 void UpdateFunctionExports(const char* funcName, const char* funcParams, const char *exportVar);
67
68 std::string ListAutoloadDirs();
69
70 bool FunctionExists(const char* name) const;
71 std::string PluginLoading() const; // Returns the basename of the plugin DLL that is currently being loaded, or NULL if no plugin is being loaded
72 void AutoloadPlugins();
73 void AddFunction(const char* name, const char* params, IScriptEnvironment::ApplyFunc apply, void* user_data, const char *exportVar,
74 bool isCalledFromAvs25Interface,
75 bool isCalledFromPreV11CInterface);
76 const AVSFunction* Lookup(const char* search_name,
77 const AVSValue* args,
78 size_t num_args,
79 bool strict,
80 size_t args_names_count,
81 const char* const* arg_names) const;
82 };
83
84 #endif // AVSCORE_PLUGINS_H
85