\r
AbstractBlock::~AbstractBlock() {\r
\r
- foreach(AbstractInterface* iface, inputs) {\r
- delete iface;\r
- }\r
- foreach(AbstractInterface* iface, outputs) {\r
- delete iface;\r
- }\r
- foreach(AbstractInterface* iface, bidirs) {\r
- delete iface;\r
- }\r
- inputs.clear();\r
- outputs.clear();\r
- bidirs.clear();\r
+ removeAllInterfaces();\r
+\r
foreach(BlockParameter* p, params) {\r
delete p;\r
}\r
return false;\r
}\r
\r
+bool AbstractBlock::isTopGroupBlock() { \r
+ return false;\r
+}\r
+\r
+bool AbstractBlock::isSourceBlock() {\r
+ return false;\r
+}\r
+/* NB: a generator is a block that has no data inputs\r
+ * and has at least one data output.\r
+ */\r
+bool AbstractBlock::isGeneratorBlock() {\r
+ if (getDataInputs().size() > 0) return false;\r
+ \r
+ return true;\r
+}\r
+\r
void AbstractBlock::addParameter(BlockParameter *param) {\r
params.append(param);\r
}\r
delete inter;\r
}\r
\r
+void AbstractBlock::removeAllInterfaces() {\r
+\r
+ foreach(AbstractInterface* iface, inputs) {\r
+ delete iface;\r
+ }\r
+ foreach(AbstractInterface* iface, outputs) {\r
+ delete iface;\r
+ }\r
+ foreach(AbstractInterface* iface, bidirs) {\r
+ delete iface;\r
+ }\r
+ inputs.clear();\r
+ outputs.clear();\r
+ bidirs.clear();\r
+\r
+}\r
+\r
void AbstractBlock::defineBlockParam(BlockParameter *param)\r
{\r
cout << "definition of param : " << param->getName().toStdString() << endl;\r
param->setValue(value); \r
}\r
\r
-QList<AbstractInterface *> AbstractBlock::getInterfaces() {\r
+QList<AbstractInterface *> AbstractBlock::getInterfaces(int direction, int purpose) {\r
QList<AbstractInterface *> list;\r
- list.append(inputs);\r
- list.append(outputs);\r
- list.append(bidirs);\r
+ bool selIn = false;\r
+ bool selOut = false;\r
+ bool selInOut = false;\r
+ \r
+ if (direction == AbstractInterface::AnyDirection) {\r
+ selIn = true;\r
+ selOut = true;\r
+ selInOut = true;\r
+ }\r
+ else if (direction == AbstractInterface::Input) {\r
+ selIn = true; \r
+ }\r
+ else if (direction == AbstractInterface::Output) {\r
+ selOut = true; \r
+ }\r
+ else if (direction == AbstractInterface::InOut) {\r
+ selInOut = true; \r
+ }\r
+ if (selIn) {\r
+ foreach(AbstractInterface* iface, inputs) {\r
+ if ((iface->getPurpose() == purpose) || (purpose == AbstractInterface::AnyPurpose)) list.append(iface); \r
+ }\r
+ }\r
+ if (selOut) {\r
+ foreach(AbstractInterface* iface, outputs) {\r
+ if ((iface->getPurpose() == purpose) || (purpose == AbstractInterface::AnyPurpose)) list.append(iface); \r
+ }\r
+ }\r
+ if (selInOut) {\r
+ foreach(AbstractInterface* iface, bidirs) {\r
+ if ((iface->getPurpose() == purpose) || (purpose == AbstractInterface::AnyPurpose)) list.append(iface); \r
+ }\r
+ }\r
return list;\r
}\r
\r
+QList<AbstractInterface *> AbstractBlock::getDataInputs() {\r
+ return getInterfaces(AbstractInterface::Input, AbstractInterface::Data); \r
+}\r
+\r
+QList<AbstractInterface *> AbstractBlock::getDataOutputs() {\r
+ return getInterfaces(AbstractInterface::Output, AbstractInterface::Data); \r
+}\r
+\r
+QList<AbstractInterface *> AbstractBlock::getControlInputs() {\r
+ return getInterfaces(AbstractInterface::Input, AbstractInterface::Control); \r
+}\r
+\r
+QList<AbstractInterface *> AbstractBlock::getControlOutputs() {\r
+ return getInterfaces(AbstractInterface::Output, AbstractInterface::Control); \r
+}\r
+\r
AbstractInterface* AbstractBlock::getIfaceFromName(QString name) {\r
\r
foreach(AbstractInterface* iface, inputs) {\r