X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/624231601a0f5daea9b8809993ad3503beafce4f..8e89ca269960b7bb43ccc054696dfc28e84d409a:/AbstractBlock.cpp

diff --git a/AbstractBlock.cpp b/AbstractBlock.cpp
index 87c973c..66c8f37 100644
--- a/AbstractBlock.cpp
+++ b/AbstractBlock.cpp
@@ -51,6 +51,14 @@ bool AbstractBlock::isTopGroupBlock() {
 bool AbstractBlock::isSourceBlock() {
   return false;
 }
+/* NB: a generator is a block that has no data inputs
+ * and has at least one data output.
+ */
+bool AbstractBlock::isGeneratorBlock() {
+  if (getDataInputs().size() > 0) return false;
+  
+  return true;
+}
 
 void AbstractBlock::addParameter(BlockParameter *param) {
   params.append(param);
@@ -119,22 +127,58 @@ void AbstractBlock::defineBlockParam(BlockParameter *param)
   param->setValue(value);  
 }
 
-QList<AbstractInterface *> AbstractBlock::getInterfaces() {
+QList<AbstractInterface *> AbstractBlock::getInterfaces(int direction, int purpose) {
   QList<AbstractInterface *> list;
-  list.append(inputs);
-  list.append(outputs);
-  list.append(bidirs);
+  bool selIn = false;
+  bool selOut = false;
+  bool selInOut = false;
+  
+  if (direction == AbstractInterface::AnyDirection) {
+    selIn = true;
+    selOut = true;
+    selInOut = true;
+  }
+  else if (direction == AbstractInterface::Input) {
+    selIn = true;    
+  }
+  else if (direction == AbstractInterface::Output) {
+    selOut = true;    
+  }
+  else if (direction == AbstractInterface::InOut) {
+    selInOut = true;    
+  }
+  if (selIn) {
+    foreach(AbstractInterface* iface, inputs) {
+      if ((iface->getPurpose() == purpose) || (purpose == AbstractInterface::AnyPurpose)) list.append(iface);      
+    }
+  }
+  if (selOut) {
+    foreach(AbstractInterface* iface, outputs) {
+      if ((iface->getPurpose() == purpose) || (purpose == AbstractInterface::AnyPurpose)) list.append(iface);      
+    }
+  }
+  if (selInOut) {
+    foreach(AbstractInterface* iface, bidirs) {
+      if ((iface->getPurpose() == purpose) || (purpose == AbstractInterface::AnyPurpose)) list.append(iface);      
+    }
+  }
   return list;
 }
 
 QList<AbstractInterface *> AbstractBlock::getDataInputs() {
-  QList<AbstractInterface *> list;
-  foreach(AbstractInterface* iface, inputs) {
-    if (iface->getPurpose() == AbstractInterface::Data) {
-      list.append(iface);
-    }
-  }
-  return list;
+  return getInterfaces(AbstractInterface::Input, AbstractInterface::Data);  
+}
+
+QList<AbstractInterface *> AbstractBlock::getDataOutputs() {
+  return getInterfaces(AbstractInterface::Output, AbstractInterface::Data);  
+}
+
+QList<AbstractInterface *> AbstractBlock::getControlInputs() {
+  return getInterfaces(AbstractInterface::Input, AbstractInterface::Control);  
+}
+
+QList<AbstractInterface *> AbstractBlock::getControlOutputs() {
+  return getInterfaces(AbstractInterface::Output, AbstractInterface::Control);    
 }
 
 AbstractInterface* AbstractBlock::getIfaceFromName(QString name) {