#include "SH_plugin_base.h"
#include "SH_runtime.h"

/*
SHRuntime * SHPluginBase::runtime() {
	return _rt;
}
*/

uint SHPluginBase::id() const {
	return getID(name(), type());
}


QVariant SHPluginBase::call(const QString & function, QVariantList args) {
	if (_rt)
		if (_rt->shs_engine_)
			return _rt->shs_engine_->call(function, args);
	return QVariant();
}


SHPluginBase * SHPluginBase::anotherPlugin(SHPluginBase::PluginType type_, const QString & name_) {
	uint id = Q2PIString(name_ + QString::number(type_)).hash();
	return _plugins.value(id, 0);
}


void SHPluginBase::setPluginProperty(const QString & pname, const QVariant & value) {
	RUNTIME->plugins_props_project[id()].addProperty(pname, value);
}


QVariant SHPluginBase::pluginProperty(const QString & pname) {
	return RUNTIME->plugins_props_project.value(id()).propertyValueByName(pname);
}


uint SHPluginBase::getID(const QString & name, int type) {
	return Q2PIString(name + QString::number(type)).hash();
}
