layer3/dnplugininputcell.cpp \
layer3/dnpluginoutputcell.cpp \
layer3/platform/qt/qtdnpluginmanager.cpp \
- layer3/platform/qt/qtdnplugin.cpp
+ layer3/platform/qt/qtdnplugin.cpp \
+ layer1/dnplugininfo.cpp
HEADERS += \
layer1/TKLockImpl.h \
layer3/dnplugin.h \
layer3/platform/qt/qtdnpluginmanager.h \
layer3/platform/qt/qtdnplugin.h \
- plugins/dennco_plugin.h
+ plugins/dennco_plugin.h \
+ layer1/dnplugininfo.h
FORMS += layer3/QtDennco/mainwindow.ui
FORMS += layer3/QtDennco/portinfodialog.ui
#include "TKCellCode.h"
#include "DNStorage.h"
#include "DNUtils.h"
+#include "dnplugininfo.h"
#include <string>
}
else if (type == CELLTYPE_PLUGIN_IN)
{
- cell = cellFactory(theLocation, theName, type, true, false);
+ DNPluginInfo info = DNPluginInfo::create(theName);
+ if (info.isValid)
+ {
+ cell = pluginCellFactory(theLocation, theName, type, info.pluginName, info.pluginValueName, true, false);
+ }
+ else
+ {
+ std::string message = std::string("Failed to initialize cell '").append(theLocation).append("#").append(theName);
+ message.append("'\nThis is a plugin input cell. The name of the cell should be described by following form:\n'pluginValueName'@'pluginName'");
+ dnNotifyError("Initialization failed", message);
+ }
noScript = true;
}
else if (type == CELLTYPE_PLUGIN_OUT)
{
- cell = cellFactory(theLocation, theName, type, false, true);
+ DNPluginInfo info = DNPluginInfo::create(theName);
+ if (info.isValid)
+ {
+ cell = pluginCellFactory(theLocation, theName, type, info.pluginName, info.pluginValueName, false, true);
+ }
+ else
+ {
+ std::string message = std::string("Failed to initialize cell '").append(theLocation).append("#").append(theName);
+ message.append("'\nThis is a plugin output cell. The name of the cell should be described by following form:\n'pluginValueName'@'pluginName'");
+ dnNotifyError("Initialization failed", message);
+ }
noScript = true;
}
else
inline virtual float getValue(std::string key) const = 0;
virtual TKCell* cellFactory(std::string location, std::string name, std::string type, bool canInterfaceIn, bool canInterfaceOut) = 0;
+ virtual TKCell* pluginCellFactory(std::string location, std::string fullName, std::string type, std::string pluginName, std::string pluginValue, bool canInterfaceIn, bool canInterfaceOut) = 0;
virtual TKAxon* axonFactory(TKCell *theOwner) = 0;
virtual TKReceptor* receptorFactory(TKCell *theOwner) = 0;
virtual TKAxonTerminal* axonTerminalFactory(TKAxon *theOwner) = 0;
--- /dev/null
+// Copyright (c) 2013 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on 1/29/2013.
+//
+
+#include "dnplugininfo.h"
+#include "DNUtils.h"
+
+DNPluginInfo::DNPluginInfo()
+{
+ isValid = false;
+}
+
+DNPluginInfo::DNPluginInfo(const DNPluginInfo &other)
+{
+ isValid = other.isValid;
+ pluginName = other.pluginName;
+ pluginValueName = other.pluginValueName;
+}
+
+//static
+DNPluginInfo DNPluginInfo::create(const std::string &name)
+{
+ DNPluginInfo result;
+ unsigned int idx = name.find("@");
+ if (idx != std::string::npos && idx > 0 && idx + 1 < name.length())
+ {
+ result.isValid = true;
+ result.pluginValueName = name.substr(0,idx);
+ result.pluginName = name.substr(name.find_last_of("@")+1);
+ }
+
+ return result;
+}
--- /dev/null
+// Copyright (c) 2013 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on 1/29/2013.
+//
+
+#ifndef DNPLUGININFO_H
+#define DNPLUGININFO_H
+
+#include <string>
+
+struct DNPluginInfo
+{
+ DNPluginInfo();
+ DNPluginInfo(const DNPluginInfo &other);
+
+ std::string pluginName;
+ std::string pluginValueName;
+ bool isValid;
+
+ static DNPluginInfo create(const std::string& name);
+};
+
+#endif // DNPLUGININFO_H
if (type == CELLTYPE_JSBASIC || type.length() == 0)
{
cell = new DNQSBasicCell(this, location, name, canInterfaceIn, canInterfaceOut);
- cell->init();
}
else if (type == CELLTYPE_IN)
{
cell = new DNQSInputCell(this, location, name);
- cell->init();
}
else if (type == CELLTYPE_OUT)
{
cell = new DNQSOutputCell(this, location, name);
- cell->init();
}
else if (type == CELLTYPE_BASICSTORAGE)
{
cell = new DNQSBasicStorageCell(this, location, name, canInterfaceIn, canInterfaceOut);
- cell->init();
}
- else if (type == CELLTYPE_PLUGIN_IN)
- {
- cell = new DNPluginInputCell(this, location, name);
+
+ if (cell)
cell->init();
+ return cell;
+}
+
+TKCell* DNQSContainer::pluginCellFactory(std::string location, std::string fullName, std::string type, std::string pluginName, std::string pluginValue, bool canInterfaceIn, bool canInterfaceOut)
+{
+ Q_ASSERT(canInterfaceIn != canInterfaceOut);
+
+ (void)canInterfaceOut;
+
+ TKCell *cell = NULL;
+
+ if (canInterfaceIn)
+ {
+ cell = new DNPluginInputCell(this, location, fullName, pluginName, pluginValue);
}
- else if (type == CELLTYPE_PLUGIN_OUT)
+ else
{
- cell = new DNPluginOutputCell(this, location, name);
- cell->init();
+ cell = new DNPluginOutputCell(this, location, fullName, pluginName, pluginValue);
}
+ if (cell)
+ cell->init();
+
return cell;
}
inline QScriptValue getQSCellContainer() { return mQSCellContainer; }
virtual TKCell* cellFactory(std::string location, std::string name, std::string type, bool canInterfaceIn, bool canInterfaceOut);
+ virtual TKCell* pluginCellFactory(std::string location, std::string fullName, std::string type, std::string pluginName, std::string pluginValue, bool canInterfaceIn, bool canInterfaceOut);
virtual TKAxon* axonFactory(TKCell *theOwner);
virtual TKReceptor* receptorFactory(TKCell *theOwner);
virtual TKAxonTerminal* axonTerminalFactory(TKAxon *theOwner);
#include <limits>
-DNPluginInputCell::DNPluginInputCell(TKContainer *container, std::string location, std::string name):
+DNPluginInputCell::DNPluginInputCell(TKContainer *container, std::string location, std::string name, std::string pluginName, std::string valueName):
DNCellInterfaceable(container,location,name, true, false),
- d_plugin(NULL), d_inputValue(std::numeric_limits<float>::quiet_NaN())
+ d_plugin(NULL), d_valueName(valueName), d_inputValue(std::numeric_limits<float>::quiet_NaN())
{
- bool parsed = false;
- unsigned int idx = name.find("?");
- if (idx != std::string::npos && idx + 1 < name.length())
- {
- std::string pluginInfo = name.substr(idx+1);
- unsigned int idx2 = pluginInfo.find(":");
- if (idx != std::string::npos && idx2 > 0 && idx2 + 1 < pluginInfo.length())
- {
- parsed = true;
- std::string pluginName = pluginInfo.substr(0,idx2);
- d_valueName = pluginInfo.substr(idx2+1);
- d_plugin = DNPluginManager::instance()->getPlugin(pluginName);
- if (!d_plugin)
- {
- std::string message = std::string("Failed to initialize cell '").append(location).append("#").append(name);
- message.append("'\nLoading the specified plugin : '").append(pluginName).append("' failed");
- dnNotifyError("Initialization failed", message);
- }
- }
- }
- if (!parsed)
+ d_plugin = DNPluginManager::instance()->getPlugin(pluginName);
+ if (!d_plugin)
{
std::string message = std::string("Failed to initialize cell '").append(location).append("#").append(name);
- message.append("'\nThis is a plugin input cell. The name of the cell should be described by following form:\n'cellName'?'pluginName':'pluginValueName'");
+ message.append("'\nLoading the specified plugin : '").append(pluginName).append("' failed");
dnNotifyError("Initialization failed", message);
}
}
float d_inputValue;
public:
- DNPluginInputCell(TKContainer *container, std::string location, std::string name);
+ DNPluginInputCell(TKContainer *container, std::string location, std::string name, std::string pluginName, std::string valueName);
virtual ~DNPluginInputCell();
virtual bool doTick(float time);
#include <limits>
-DNPluginOutputCell::DNPluginOutputCell(TKContainer *container, std::string location, std::string name)
+DNPluginOutputCell::DNPluginOutputCell(TKContainer *container, std::string location, std::string name, std::string pluginName, std::string valueName)
: DNCellInterfaceable(container, location, name, false, true),
- d_plugin(NULL), d_outputValue(std::numeric_limits<float>::quiet_NaN())
+ d_plugin(NULL), d_valueName(valueName), d_outputValue(std::numeric_limits<float>::quiet_NaN())
{
- bool parsed = false;
- unsigned int idx = name.find("?");
- if (idx != std::string::npos && idx + 1 < name.length())
- {
- std::string pluginInfo = name.substr(idx+1);
- unsigned int idx2 = pluginInfo.find(":");
- if (idx != std::string::npos && idx2 > 0 && idx2 + 1 < pluginInfo.length())
- {
- parsed = true;
- std::string pluginName = pluginInfo.substr(0,idx2);
- d_valueName = pluginInfo.substr(idx2+1);
- d_plugin = DNPluginManager::instance()->getPlugin(pluginName);
- if (!d_plugin)
- {
- std::string message = std::string("Failed to initialize cell '").append(location).append("#").append(name);
- message.append("'\nLoading the specified plugin : '").append(pluginName).append("' failed");
- dnNotifyError("Initialization failed", message);
- }
- }
- }
- if (!parsed)
+ d_plugin = DNPluginManager::instance()->getPlugin(pluginName);
+ if (!d_plugin)
{
std::string message = std::string("Failed to initialize cell '").append(location).append("#").append(name);
- message.append("'\nThis is a plugin output cell. The name of the cell should be described by following form:\n'cellName'?'pluginName':'pluginValueName'");
+ message.append("'\nLoading the specified plugin : '").append(pluginName).append("' failed");
dnNotifyError("Initialization failed", message);
}
}
float d_outputValue;
public:
- DNPluginOutputCell(TKContainer *container, std::string location, std::string name);
+ DNPluginOutputCell(TKContainer *container, std::string location, std::string name, std::string pluginName, std::string valueName);
virtual ~DNPluginOutputCell();
virtual bool doTick(float time);