]> AND Private Git Repository - blast.git/blobdiff - ReferenceBlock.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
added creation of control ifaces
[blast.git] / ReferenceBlock.cpp
index 722fc12186da982f691d33db7a402b1b9cb9803b..e09b1188c0dcb8c30b753d23f24a66fae9862bb2 100644 (file)
@@ -224,6 +224,7 @@ void ReferenceBlock::loadInterfaces(QDomElement &elt) throw(Exception) {
   if ((elt.isNull()) || (elt.tagName() != "interfaces")) throw (Exception(BLOCKFILE_CORRUPTED));
 
   QDomElement eltInputs = elt.firstChildElement("inputs");
+  // getting each input
   QDomNodeList listNodeInputs = eltInputs.elementsByTagName("input");
   for(int i=0;i<listNodeInputs.size();i++) {
     QDomNode node = listNodeInputs.at(i);
@@ -242,7 +243,21 @@ void ReferenceBlock::loadInterfaces(QDomElement &elt) throw(Exception) {
     inter = new ReferenceInterface(this,nameStr,typeStr,widthStr,AbstractInterface::Input, purpose, mult);
     inputs.append(inter);
   }
-
+  // getting each control
+  QDomNodeList listNodeInCtl = eltInputs.elementsByTagName("control");
+  for(int i=0;i<listNodeInCtl.size();i++) {
+    QDomNode node = listNodeInCtl.at(i);
+    QDomElement eltInput = node.toElement();
+    nameStr = eltInput.attribute("iface","none");
+    AbstractInterface* dataIface = getIfaceFromName(nameStr);
+    if (dataIface == NULL) throw (Exception(BLOCKFILE_CORRUPTED));
+    nameStr = dataIface->getName()+"_ctl";
+    inter = new ReferenceInterface(this,nameStr,"boolean","1",AbstractInterface::Input, AbstractInterface::Control, 1);
+    if (!inter->setAssociatedIface(dataIface)) {
+      throw (Exception(BLOCKFILE_CORRUPTED));      
+    }
+    inputs.append(inter);
+  }
   QDomElement eltOutputs = eltInputs.nextSiblingElement("outputs");
   QDomNodeList listNodeOutputs = eltOutputs.elementsByTagName("output");
   for(int i=0;i<listNodeOutputs.size();i++) {
@@ -259,6 +274,21 @@ void ReferenceBlock::loadInterfaces(QDomElement &elt) throw(Exception) {
     inter = new ReferenceInterface(this,nameStr,typeStr,widthStr,AbstractInterface::Output, purpose, mult);
     outputs.append(inter);
   }
+  // getting each control
+  QDomNodeList listNodeOutCtl = eltOutputs.elementsByTagName("control");
+  for(int i=0;i<listNodeOutCtl.size();i++) {
+    QDomNode node = listNodeOutCtl.at(i);
+    QDomElement eltOutput = node.toElement();
+    nameStr = eltOutput.attribute("iface","none");
+    AbstractInterface* dataIface = getIfaceFromName(nameStr);
+    if (dataIface == NULL) throw (Exception(BLOCKFILE_CORRUPTED));
+    nameStr = dataIface->getName()+"_ctl";
+    inter = new ReferenceInterface(this,nameStr,"boolean","1",AbstractInterface::Output, AbstractInterface::Control, 1);
+    if (!inter->setAssociatedIface(dataIface)) {
+      throw (Exception(BLOCKFILE_CORRUPTED));      
+    }
+    outputs.append(inter);
+  }
 
   QDomElement eltBidirs = eltInputs.nextSiblingElement("bidirs");
   QDomNodeList listNodeBidirs = eltBidirs.elementsByTagName("bidir");