-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathmain.cpp
46 lines (35 loc) · 1.27 KB
/
main.cpp
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
#include <iostream>
#include <psdk/loader.hpp>
class IMathFunction
{
public:
virtual const char* Name() const = 0;
virtual double Eval(double x) const = 0;
virtual ~IMathFunction() = default;
};
int main()
{
PluginManager ma;
IPluginFactory* infoA = ma.addPlugin("PluginA");
// * infoA = ma.GetPluginInfo("PluginA");
assert(infoA != nullptr);
std::cout << " ---- Plugin Information --------- " << "\n"
<< " => Name = " << infoA->Name() << "\n"
<< " => Version = " << infoA->Version() << "\n"
<< " => Number of classes = " << infoA->NumberOfClasses()
<< "\n\n";
std::cout << "Classes exported by the Plugin: (PluginA) " << "\n";
for(size_t n = 0; n < infoA->NumberOfClasses(); n++)
{
std::cout << " -> Exported Class: " << infoA->GetClassName(n) << "\n";
}
// Type of pExp: std::shared_ptr<IMathFunction>
auto pExp = ma.CreateInstanceAs<IMathFunction>("PluginA", "Exp");
assert(pExp != nullptr);
std::cout << "pExp->Name() = " << pExp->Name() << "\n";
std::cout << "pExp->Eval(3.0) = " << pExp->Eval(3.0) << "\n";
auto pLog = ma.CreateInstanceAs<IMathFunction>("PluginA", "Log");
std::cout << "pLog->Name() = " << pLog->Name() << "\n";
std::cout << "pLog->Eval(3.0) = " << pLog->Eval(3.0) << "\n";
return 0;
}