Dynamic link library example
#include "interface/interface.h"
#include <iostream>
int main(int argc, char** argv)
{
if (plugin)
{
auto random = plugin.
Resolve<int ()>(
"PluginRandom");
if (random != nullptr)
{
for (int i = 0; i < 10; ++i)
std::cout << "random() = " << random() << std::endl;
}
}
plugin.
Load(
"plugin-interface");
if (plugin)
{
auto create = plugin.
Resolve<bool (IRandom**)>(
"PluginRandomCreate");
auto release = plugin.
Resolve<bool (IRandom*)>(
"PluginRandomRelease");
if ((create != nullptr) && (release != nullptr))
{
IRandom* pRandom;
if (create(&pRandom))
{
for (int i = 0; i < 10; ++i)
std::cout << "Random.random() = " << pRandom->random() << std::endl;
release(pRandom);
}
}
}
return 0;
}
T * Resolve(const std::string &name) const
Resolve dynamic link library symbol by the given name.
bool Load()
Load dynamic link library.
void Unload()
Unload dynamic link library.
Dynamic link library definition.