本文整理汇总了C++中PluginLoader类的典型用法代码示例。如果您正苦于以下问题:C++ PluginLoader类的具体用法?C++ PluginLoader怎么用?C++ PluginLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PluginLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PRINT_DEBUG
/*----------------------------------------------------------------------------*/
bool Analyzer::addPlugin( const QString& file )
{
if ( file.isEmpty() ) //nothing to load
return false;
PRINT_DEBUG ("Loading plugin: " << file);
PluginLoader * loader = new PluginLoader( file );
Q_ASSERT (loader);
if (loader->isLoaded())
{
error( "Plugin already loaded!" );
loader->unload();
delete loader;
return false;
}
const bool success = loader->init();
if (!success)
{
error( "Plugin initialization failed!" );
loader->unload();
delete loader;
return false;
}
mPlugins.append( loader );
connect( loader, SIGNAL(destroyed( QObject* )),
this, SLOT(removePlugin( QObject* )) );
emit newPlugin( loader );
return true;
}
示例2: PluginLoader
/// Indexes all plugins found in /Plugins
void GameCore::loadPlugins()
{
typedef PluginSDK::Types(*getPluginTypeFunc)();
typedef ExtensionScripting*(*createScriptEnvironmentFunc)(GameCore*);
typedef ExtensionAudio*(*createAudioEnvironmentFunc)(GameCore*);
StringList dll_list = FileSystem::scanDirectory("Plugins", "dll", false);
for (auto& dll_name : dll_list)
{
// Let's check what the plugin is and load immediately
PluginLoader* plugin = new PluginLoader(dll_name);
if (plugin)
{
Log("Plugin loaded: %s", dll_name.c_str());
getPluginTypeFunc funptr = (getPluginTypeFunc)plugin->getFunctionAddress("getPluginType");
if (funptr)
{
PluginSDK::Types pluginType = funptr();
switch (pluginType)
{
case PluginSDK::Scripting:
{
Log("THIS IS A SCRIPTING PLUGIN");
createScriptEnvironmentFunc funptr = (createScriptEnvironmentFunc)plugin->getFunctionAddress("createScriptingEnvironment");
if (funptr)
{
ExtensionScripting* scriptingEnvironment = funptr(this);
if (scriptingEnvironment)
{
Log("Got the scripting environment, Registered.");
scriptingEnvironments.push_back(scriptingEnvironment);
}
}
}
break;
case PluginSDK::Audio:
{
Log("THIS IS A AUDIO PLUGIN");
createAudioEnvironmentFunc funptr = (createAudioEnvironmentFunc)plugin->getFunctionAddress("createAudioEnvironment");
if (funptr)
{
ExtensionAudio* audioEnvironment = funptr(this);
if (audioEnvironment)
{
Log("Got the audio environment, Registered.");
gameAudio.audioEnvironments.push_back(audioEnvironment);
}
}
}
break;
}
}
}
}
}
示例3: reloadPlugins
void Device::reloadPlugins()
{
QHash<QString, KdeConnectPlugin*> newPluginMap;
QMultiMap<QString, KdeConnectPlugin*> newPluginsByIncomingInterface;
QMultiMap<QString, KdeConnectPlugin*> newPluginsByOutgoingInterface;
QSet<QString> supportedIncomingInterfaces;
QSet<QString> supportedOutgoingInterfaces;
QStringList unsupportedPlugins;
if (isPaired() && isReachable()) { //Do not load any plugin for unpaired devices, nor useless loading them for unreachable devices
KConfigGroup pluginStates = KSharedConfig::openConfig(pluginsConfigFile())->group("Plugins");
PluginLoader* loader = PluginLoader::instance();
const bool deviceSupportsCapabilities = !m_incomingCapabilities.isEmpty() || !m_outgoingCapabilities.isEmpty();
foreach (const QString& pluginName, loader->getPluginList()) {
const KPluginMetaData service = loader->getPluginInfo(pluginName);
const QSet<QString> incomingInterfaces = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-SupportedPackageType").toSet();
const QSet<QString> outgoingInterfaces = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-OutgoingPackageType").toSet();
const bool pluginEnabled = isPluginEnabled(pluginName);
if (pluginEnabled) {
supportedIncomingInterfaces += incomingInterfaces;
supportedOutgoingInterfaces += outgoingInterfaces;
}
//If we don't find intersection with the received on one end and the sent on the other, we don't
//let the plugin stay
//Also, if no capabilities are specified on the other end, we don't apply this optimizaton, as
//we assume that the other client doesn't know about capabilities.
const bool capabilitiesSupported = deviceSupportsCapabilities && (!incomingInterfaces.isEmpty() || !outgoingInterfaces.isEmpty());
if (capabilitiesSupported
&& (m_incomingCapabilities & outgoingInterfaces).isEmpty()
&& (m_outgoingCapabilities & incomingInterfaces).isEmpty()
) {
qCWarning(KDECONNECT_CORE) << "not loading " << pluginName << "because of unmatched capabilities";
unsupportedPlugins.append(pluginName);
continue;
}
if (pluginEnabled) {
KdeConnectPlugin* plugin = m_plugins.take(pluginName);
if (!plugin) {
plugin = loader->instantiatePluginForDevice(pluginName, this);
}
foreach(const QString& interface, incomingInterfaces) {
newPluginsByIncomingInterface.insert(interface, plugin);
}
foreach(const QString& interface, outgoingInterfaces) {
newPluginsByOutgoingInterface.insert(interface, plugin);
}
newPluginMap[pluginName] = plugin;
}
示例4: reloadPlugins
void Device::reloadPlugins()
{
QHash<QString, KdeConnectPlugin*> newPluginMap;
QMultiMap<QString, KdeConnectPlugin*> newPluginsByIncomingInterface;
QMultiMap<QString, KdeConnectPlugin*> newPluginsByOutgoingInterface;
if (isPaired() && isReachable()) { //Do not load any plugin for unpaired devices, nor useless loading them for unreachable devices
KConfigGroup pluginStates = KSharedConfig::openConfig(pluginsConfigFile())->group("Plugins");
PluginLoader* loader = PluginLoader::instance();
//Code borrowed from KWin
foreach (const QString& pluginName, loader->getPluginList()) {
QString enabledKey = pluginName + QString::fromLatin1("Enabled");
bool isPluginEnabled = (pluginStates.hasKey(enabledKey) ? pluginStates.readEntry(enabledKey, false)
: loader->getPluginInfo(pluginName).isEnabledByDefault());
if (isPluginEnabled) {
KdeConnectPlugin* plugin = m_plugins.take(pluginName);
QStringList incomingInterfaces, outgoingInterfaces;
if (plugin) {
incomingInterfaces = m_pluginsByIncomingInterface.keys(plugin);
outgoingInterfaces = m_pluginsByOutgoingInterface.keys(plugin);
} else {
const KPluginMetaData service = loader->getPluginInfo(pluginName);
incomingInterfaces = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-SupportedPackageType");
outgoingInterfaces = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-OutgoingPackageType");
}
//If we don't find intersection with the received on one end and the sent on the other, we don't
//let the plugin stay
//Also, if no capabilities are specified on the other end, we don't apply this optimizaton, as
//we assume that the other client doesn't know about capabilities.
if (!m_incomingCapabilities.isEmpty() && !m_outgoingCapabilities.isEmpty()
&& (m_incomingCapabilities & outgoingInterfaces.toSet()).isEmpty()
&& (m_outgoingCapabilities & incomingInterfaces.toSet()).isEmpty()
) {
delete plugin;
continue;
}
if (!plugin) {
plugin = loader->instantiatePluginForDevice(pluginName, this);
}
foreach(const QString& interface, incomingInterfaces) {
newPluginsByIncomingInterface.insert(interface, plugin);
}
foreach(const QString& interface, outgoingInterfaces) {
newPluginsByOutgoingInterface.insert(interface, plugin);
}
newPluginMap[pluginName] = plugin;
}
示例5: main
//-------------------------------------------------------------------------------------------------------
int main (int argc, char* argv[])
{
if (!checkPlatform ())
{
printf ("Platform verification failed! Please check your Compiler Settings!\n");
return -1;
}
const char* fileName = "again.dll";
//const char* fileName = "adelay.dll";
//const char* fileName = "surrounddelay.dll";
//const char* fileName = "vstxsynth.dll";
//const char* fileName = "drawtest.dll";
if (argc > 1)
fileName = argv[1];
printf ("HOST> Load library...\n");
PluginLoader loader;
if (!loader.loadLibrary (fileName))
{
printf ("Failed to load VST Plugin library!\n");
return -1;
}
PluginEntryProc mainEntry = loader.getMainEntry ();
if (!mainEntry)
{
printf ("VST Plugin main entry not found!\n");
return -1;
}
printf ("HOST> Create effect...\n");
AEffect* effect = mainEntry (HostCallback);
if (!effect)
{
printf ("Failed to create effect instance!\n");
return -1;
}
printf ("HOST> Init sequence...\n");
effect->dispatcher (effect, effOpen, 0, 0, 0, 0);
effect->dispatcher (effect, effSetSampleRate, 0, 0, 0, kSampleRate);
effect->dispatcher (effect, effSetBlockSize, 0, kBlockSize, 0, 0);
checkEffectProperties (effect);
checkEffectProcessing (effect);
checkEffectEditor (effect);
printf ("HOST> Close effect...\n");
effect->dispatcher (effect, effClose, 0, 0, 0, 0);
return 0;
}
示例6: main
int main(int argc, char **argv) {
int c;
std::string fname("");
while ((c = getopt(argc, argv, "hf:")) != -1) {
switch (c) {
default:
case 'h': usage(); return 0; break;
case 'f': fname = optarg; break;
}
}
if (optind != argc) return (usage());
Project project;
// Setup the plugins
PluginLoader *loader = PluginLoader::s_getSystemLoader();
log4cxx::PropertyConfigurator::configure("logger.conf");
try {
loader->loadDir("./plugins");
} catch (IOException e) {
std::cerr << "Error loading plugins: " << e.what() << std::endl;
return 1;
}
// Load a file if it's been passed in
if (fname.length() > 0) {
try {
project.load(fname);
} catch (const std::exception &e) {
std::cerr << "error opening file: " << fname << std::endl;
std::cerr << e.what() << std::endl;
}
}
std::cout << "Press the 'X' key to exit the application" << std::endl;
char ch;
while ((ch = std::cin.get()) != 'x' && ch != 'X') {}
try {
loader->unloadAll();
} catch (IOException e) {
std::cerr << "Error unloading plugins: " << e.what() << std::endl;
return 1;
}
return 0;
}
示例7: logContext
void Plugins::enumerate() {
PluginParser.AddChild(&PluginMMLParser);
PluginRootParser.AddChild(&PluginParser);
logContext("parsing plugins");
PluginLoader loader;
loader.CurrentElement = &PluginRootParser;
for (std::vector<DirectorySpecifier>::const_iterator it =
data_search_path.begin();
it != data_search_path.end(); ++it) {
DirectorySpecifier path = *it + "Plugins";
loader.ParseDirectory(path);
}
std::sort(m_plugins.begin(), m_plugins.end());
clear_game_error();
}
示例8: main
int main(int argc, char **argv)
{
PluginLoader factory;
if(factory.OpenModule(gFilename, "CxUtils"))
{
// Every plugin library must have an initializer method to create
// an instance of a plugin-based class. CxUtils includes one example
// method to do so, see plugin.h for how to declare and implement.
Plugin* plugin = factory.CreatePlugin("CxUtils", "CreateCxUtilsPluginExample");
if(plugin)
{
std::cout << plugin->GetPluginDescription() << std::endl;
delete plugin;
}
}
return 0;
}
示例9: main
int main(int argc, char **argv)
{
QtSingleApplication *app = new QtSingleApplication(argc, argv);
PluginLoader pluginLoader;
QObject *plugin = pluginLoader.loadLauncher("badi");
if(plugin)
{
ApplicationPlugin *appPlugin = dynamic_cast<ApplicationPlugin *>(plugin);
app->closeAllWindows();
delete app;
app = appPlugin->createApplication(argc, argv);
if(app)
{
if (app->sendMessage("Wake up!"))
return 0;
return app->exec();
}
}
}
示例10: setupPlugins
void KRenameWindow::setupPlugins()
{
PluginLoader *loader = PluginLoader::Instance();
const QList<Plugin *> &list = loader->plugins();
QList<Plugin *>::const_iterator it = list.begin();
m_pluginsWidgetHash.reserve(list.count());
m_pluginsHash.reserve(list.count());
m_pagePlugins->searchPlugins->searchLine()->setTreeWidget(m_pagePlugins->listPlugins);
while (it != list.end()) {
// create plugin gui
QWidget *widget = new QWidget(m_pagePlugins->stackPlugins);
(*it)->createUI(widget);
int idx = m_pagePlugins->stackPlugins->addWidget(widget);
m_pagePlugins->stackPlugins->setCurrentIndex(idx);
m_pluginsHash[(*it)->name()] = (*it);
m_pluginsWidgetHash[(*it)->name()] = widget;
// add to list of all plugins
QTreeWidgetItem *item = new QTreeWidgetItem(m_pagePlugins->listPlugins);
item->setText(0, (*it)->name());
item->setIcon(0, (*it)->icon());
slotPluginChanged(item);
++it;
}
m_pagePlugins->splitter->setStretchFactor(0, 0);
m_pagePlugins->splitter->setStretchFactor(1, 8);
m_pagePlugins->listPlugins->sortColumn();
}
示例11: main
int main() {
PluginLoader* pluginTest = new PluginLoader;
TrinitasPlugin* tmpPlugin = NULL;
/*load all Plugins in the directory where
*where this programm is located
*/
pluginTest->Load("Plugins");
// this dont work for now dont know why
cout << "GetPluginByName:\n";
tmpPlugin = pluginTest->GetByName("Client");
if (tmpPlugin) {
cout << "GetPluginByName: ";
tmpPlugin->Do();
}
cout << "GetPluginByID:\n ";
tmpPlugin = pluginTest->GetAt(1);
if (tmpPlugin) {
cout << "GetPluginByID: ";
tmpPlugin->Do();
}
return 0;
}
示例12: printPluginCategoryList
void
printPluginCategoryList()
{
PluginLoader *loader = PluginLoader::getInstance();
vector<PluginLoader::PluginKey> plugins = loader->listPlugins();
set<string> printedcats;
for (size_t i = 0; i < plugins.size(); ++i) {
PluginLoader::PluginKey key = plugins[i];
PluginLoader::PluginCategoryHierarchy category =
loader->getPluginCategory(key);
Plugin *plugin = loader->loadPlugin(key, 48000);
if (!plugin) continue;
string catstr = "";
if (category.empty()) catstr = '|';
else {
for (size_t j = 0; j < category.size(); ++j) {
catstr += category[j];
catstr += '|';
if (printedcats.find(catstr) == printedcats.end()) {
std::cout << catstr << std::endl;
printedcats.insert(catstr);
}
}
}
std::cout << catstr << key << ":::" << plugin->getName() << ":::" << plugin->getMaker() << ":::" << plugin->getDescription() << std::endl;
}
}
示例13: main
int main(int argc, char* argv[]) {
if (argc < 4) {
cerr << "Invalid number of arguments." << endl;
cout << "Usage: " << argv[0] << " <input_video_file_path> <analytic_plugin_dir_path> <analytic_plugin_filename>" << endl;
cout << "Example: " << argv[0] << "input.mp4 ~/analytic/ analytic_plugin.so" << endl;
return -1;
}
string input_video_file_path = argv[1];
string analytic_plugin_dir_path = argv[2];
string analytic_plugin_filename = argv[3];
ConcurrentQueue<api::Image_t>* pImageInputQueue = new ConcurrentQueue<api::Image_t>(10);
ConcurrentQueue<api::Image_t>* pResultsOutputQueue = new ConcurrentQueue<api::Image_t>(10);
// Load Analytic
api::Analytic* pAnalytic = NULL;
PluginLoader<api::Analytic> loader;
string sPathToAnalyticPlugin = analytic_plugin_dir_path;
if(*sPathToAnalyticPlugin.rbegin() != '/') // last char
{
sPathToAnalyticPlugin.append("/");
}
sPathToAnalyticPlugin.append(analytic_plugin_filename);
try
{
loader.loadPlugin(sPathToAnalyticPlugin);
pAnalytic = loader.createPluginInstance();
}
catch(opencctv::Exception &e)
{
cerr << "Failed to load the Analytic plugin: " << sPathToAnalyticPlugin << endl;
return -1;
}
// Create Consumer thread to write results into a txt file
string sOutputFilename = analytic_plugin_dir_path;
if(*sOutputFilename.rbegin() != '/') // last char
{
sOutputFilename.append("/");
}
sOutputFilename.append(currentDateTime());
sOutputFilename.append(".txt");
ConsumerThread resultsConsumer(sOutputFilename, pResultsOutputQueue);
boost::thread* pConsumerThread = new boost::thread(resultsConsumer);
// Create Producer thread to read frames from input video files
ProducerThread imageProducer(input_video_file_path, pImageInputQueue);
boost::thread* pProducerThread = new boost::thread(imageProducer);
// Run analytic
try
{
if(pAnalytic->init(analytic_plugin_dir_path))
{
pAnalytic->process(pImageInputQueue, pResultsOutputQueue);
}
else
{
cerr << "Failed to initialize the Analytic. init() failed.";
}
}
catch(exception &e)
{
cerr << "Exception in Analytic: " << e.what() << endl;
}
return 0;
}
示例14: runPlugin
int runPlugin(string myname, string soname, string id,
string output, int outputNo, bool useFrames, PaStreamParameters inputParameters)
{
float *recordedSamples;
float *fifo;
PaStream* stream;
PaError err = paNoError;
int elapsed = 0;
int returnValue = 1;
RealTime rt;
PluginWrapper *wrapper = 0;
RealTime adjustment = RealTime::zeroTime;
PluginLoader *loader = PluginLoader::getInstance();
PluginLoader::PluginKey key = loader->composePluginKey(soname, id);
// load plugin
Plugin *plugin = loader->loadPlugin(key, SAMPLE_RATE, PluginLoader::ADAPT_ALL_SAFE);
if (!plugin) {
cerr << myname << ": ERROR: Failed to load plugin \"" << id
<< "\" from library \"" << soname << "\"" << endl;
return 1;
}
// Find block/step size
int blockSize = plugin->getPreferredBlockSize();
int stepSize = plugin->getPreferredStepSize();
if (blockSize == 0) {
blockSize = 1024;
}
if (stepSize == 0) {
if (plugin->getInputDomain() == Plugin::FrequencyDomain) {
stepSize = blockSize/2;
} else {
stepSize = blockSize;
}
} else if (stepSize > blockSize) {
cerr << "WARNING: stepSize " << stepSize << " > blockSize " << blockSize << ", resetting blockSize to ";
if (plugin->getInputDomain() == Plugin::FrequencyDomain) {
blockSize = stepSize * 2;
} else {
blockSize = stepSize;
}
cerr << blockSize << endl;
}
// set up port audio
fifo = new float[blockSize]();
recordedSamples = new float[stepSize]();
ofstream *out = 0;
cerr << "Running plugin: \"" << plugin->getIdentifier() << "\"..." << endl;
cerr << "Using block size = " << blockSize << ", step size = " << stepSize << endl;
// display output name
Plugin::OutputList outputs = plugin->getOutputDescriptors();
Plugin::OutputDescriptor od;
if (outputs.empty()) {
cerr << "ERROR: Plugin has no outputs!" << endl;
goto done;
}
if (outputNo < 0) {
for (size_t oi = 0; oi < outputs.size(); ++oi) {
if (outputs[oi].identifier == output) {
outputNo = oi;
break;
}
}
if (outputNo < 0) {
cerr << "ERROR: Non-existent output \"" << output << "\" requested" << endl;
goto done;
}
} else {
if (int(outputs.size()) <= outputNo) {
cerr << "ERROR: Output " << outputNo << " requested, but plugin has only " << outputs.size() << " output(s)" << endl;
goto done;
}
}
od = outputs[outputNo];
cerr << "Output is: \"" << od.identifier << "\"" << endl;
// Initialise plugin
if (!plugin->initialise(1, stepSize, blockSize)) {
cerr << "ERROR: Plugin initialise (stepSize = " << stepSize << ", blockSize = "
<< blockSize << ") failed." << endl;
goto done;
}
// Compensate timestamp if in freq domain
wrapper = dynamic_cast<PluginWrapper *>(plugin);
if (wrapper) {
PluginInputDomainAdapter *ida = wrapper->getWrapper<PluginInputDomainAdapter>();
if (ida) adjustment = ida->getTimestampAdjustment();
//.........这里部分代码省略.........
示例15: enumeratePlugins
void
enumeratePlugins(Verbosity verbosity)
{
PluginLoader *loader = PluginLoader::getInstance();
if (verbosity == PluginInformation) {
cout << "\nVamp plugin libraries found in search path:" << endl;
}
vector<PluginLoader::PluginKey> plugins = loader->listPlugins();
typedef multimap<string, PluginLoader::PluginKey>
LibraryMap;
LibraryMap libraryMap;
for (size_t i = 0; i < plugins.size(); ++i) {
string path = loader->getLibraryPathForPlugin(plugins[i]);
libraryMap.insert(LibraryMap::value_type(path, plugins[i]));
}
string prevPath = "";
int index = 0;
for (LibraryMap::iterator i = libraryMap.begin();
i != libraryMap.end(); ++i) {
string path = i->first;
PluginLoader::PluginKey key = i->second;
if (path != prevPath) {
prevPath = path;
index = 0;
if (verbosity == PluginInformation) {
cout << "\n " << path << ":" << endl;
} else if (verbosity == PluginInformationDetailed) {
string::size_type ki = i->second.find(':');
string text = "Library \"" + i->second.substr(0, ki) + "\"";
cout << "\n" << header(text, 1);
}
}
Plugin *plugin = loader->loadPlugin(key, 48000);
if (plugin) {
char c = char('A' + index);
if (c > 'Z') c = char('a' + (index - 26));
PluginLoader::PluginCategoryHierarchy category =
loader->getPluginCategory(key);
string catstr;
if (!category.empty()) {
for (size_t ci = 0; ci < category.size(); ++ci) {
if (ci > 0) catstr += " > ";
catstr += category[ci];
}
}
if (verbosity == PluginInformation) {
cout << " [" << c << "] [v"
<< plugin->getVampApiVersion() << "] "
<< plugin->getName() << ", \""
<< plugin->getIdentifier() << "\"" << " ["
<< plugin->getMaker() << "]" << endl;
if (catstr != "") {
cout << " > " << catstr << endl;
}
if (plugin->getDescription() != "") {
cout << " - " << plugin->getDescription() << endl;
}
} else if (verbosity == PluginInformationDetailed) {
cout << header(plugin->getName(), 2);
cout << " - Identifier: "
<< key << endl;
cout << " - Plugin Version: "
<< plugin->getPluginVersion() << endl;
cout << " - Vamp API Version: "
<< plugin->getVampApiVersion() << endl;
cout << " - Maker: \""
<< plugin->getMaker() << "\"" << endl;
cout << " - Copyright: \""
<< plugin->getCopyright() << "\"" << endl;
cout << " - Description: \""
<< plugin->getDescription() << "\"" << endl;
cout << " - Input Domain: "
<< (plugin->getInputDomain() == Vamp::Plugin::TimeDomain ?
"Time Domain" : "Frequency Domain") << endl;
cout << " - Default Step Size: "
<< plugin->getPreferredStepSize() << endl;
cout << " - Default Block Size: "
<< plugin->getPreferredBlockSize() << endl;
cout << " - Minimum Channels: "
<< plugin->getMinChannelCount() << endl;
cout << " - Maximum Channels: "
<< plugin->getMaxChannelCount() << endl;
} else if (verbosity == PluginIds) {
//.........这里部分代码省略.........