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

Private GIT Repository
added creation of control ifaces
[blast.git] / FunctionalBlock.cpp
index f54708419ae9422e8b9a1b867397ec5f477a9d4f..cb8ceba679d5da8c5f835cbc673483280cbc7f9d 100644 (file)
@@ -46,25 +46,44 @@ void FunctionalBlock::populate() {
   BlockParameter* p;\r
   AbstractInterface* inter;\r
 \r
+  // create parameters from reference block\r
   QList<BlockParameter*> lstParam = reference->getParameters();\r
   for(i=0;i<lstParam.size();i++) {\r
     p = lstParam.at(i)->clone();\r
     addParameter(p);\r
   }\r
 \r
-  QList<AbstractInterface *> lstInter = reference->getInterfaces();\r
-  for(i=0;i<lstInter.size();i++) {\r
+  // create interfaces from reference block\r
+  QList<AbstractInterface *> lstRef = reference->getInterfaces();\r
+  // store relation between functional and reference\r
+  QHash<AbstractInterface *, AbstractInterface *> hashIface;\r
+  for(i=0;i<lstRef.size();i++) {\r
     try {\r
-      inter = new FunctionalInterface(this, (ReferenceInterface*)lstInter.at(i));\r
+      inter = new FunctionalInterface(this, AI_TO_REF(lstRef.at(i)));\r
     }\r
     catch(Exception e) {\r
       cerr << "Abnormal case: " << qPrintable(e.getDefaultMessage()) << endl << "Aborting execution." << endl;\r
       exit(1);\r
     }\r
+    hashIface.insert(lstRef.at(i),inter);\r
 \r
     addInterface(inter);\r
   }\r
-\r
+    \r
+  AbstractInterface* funCtlIface = NULL;\r
+  AbstractInterface* funDataIface = NULL;\r
+  \r
+  for(i=0;i<lstRef.size();i++) {    \r
+    AbstractInterface* refIface = lstRef.at(i);    \r
+    if (refIface->getPurpose() == AbstractInterface::Control) {\r
+      funCtlIface = hashIface.value(refIface);\r
+      funDataIface = hashIface.value(refIface->getAssociatedIface());\r
+      if (! funCtlIface->setAssociatedIface(funDataIface)) {\r
+        cerr << "Abnormal case when associating a control interface to data" << endl << "Aborting execution." << endl;\r
+        exit(1);\r
+      }       \r
+    }\r
+  }\r
 }\r
 \r
 \r