Beispiel #1
0
inline PLUGIN_TYPE *PluginManager<PLUGIN_TYPE>::clone(const std::string& plugin_id)
{
	boost::mutex::scoped_lock plugins_lock(m_plugin_mutex);
	typename pion::PluginManager<PLUGIN_TYPE>::PluginMap::iterator i = m_plugin_map.find(plugin_id);
	if (i == m_plugin_map.end())
		throw PluginNotFoundException(plugin_id);
	return i->second.second.create();
}
Beispiel #2
0
void PionPlugin::open(const std::string& plugin_name)
{
	std::string plugin_file;

	if (!findPluginFile(plugin_file, plugin_name))
		throw PluginNotFoundException(plugin_name);
		
	openFile(plugin_file);
}
Beispiel #3
0
inline boost::uint64_t PluginManager<PLUGIN_TYPE>::getStatistic(const std::string& plugin_id,
																PluginStatFunction stat_func) const
{
	// no need to lock (handled by PluginManager::get())
	const PLUGIN_TYPE *plugin_object_ptr = const_cast<PluginManager<PLUGIN_TYPE>*>(this)->get(plugin_id);
	if (plugin_object_ptr == NULL)
		throw PluginNotFoundException(plugin_id);
	return stat_func(plugin_object_ptr);
}
Beispiel #4
0
inline void PluginManager<PLUGIN_TYPE>::run(const std::string& plugin_id,
											PluginRunFunction run_func)
{
	// no need to lock (handled by PluginManager::get())
	PLUGIN_TYPE *plugin_object_ptr = get(plugin_id);
	if (plugin_object_ptr == NULL)
		throw PluginNotFoundException(plugin_id);
	run_func(plugin_object_ptr);
}
Beispiel #5
0
inline void PluginManager<PLUGIN_TYPE>::remove(const std::string& plugin_id)
{
	boost::mutex::scoped_lock plugins_lock(m_plugin_mutex);
	typename pion::PluginManager<PLUGIN_TYPE>::PluginMap::iterator i = m_plugin_map.find(plugin_id);
	if (i == m_plugin_map.end())
		throw PluginNotFoundException(plugin_id);
	if (i->second.second.is_open()) {
		i->second.second.destroy(i->second.first);
	} else {
		delete i->second.first;
	}
	m_plugin_map.erase(i);
}
Beispiel #6
0
inline void PluginManager<PLUGIN_TYPE>::replace(const std::string& plugin_id, PLUGIN_TYPE *plugin_ptr)
{
	PION_ASSERT(plugin_ptr);
	boost::mutex::scoped_lock plugins_lock(m_plugin_mutex);
	typename pion::PluginManager<PLUGIN_TYPE>::PluginMap::iterator i = m_plugin_map.find(plugin_id);
	if (i == m_plugin_map.end())
		throw PluginNotFoundException(plugin_id);
	if (i->second.second.is_open()) {
		i->second.second.destroy(i->second.first);
	} else {
		delete i->second.first;
	}
	i->second.first = plugin_ptr;
}