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

Private GIT Repository
correcting bugs but still exsitings
[blast.git] / FunctionalBlock.cpp
1 #include "FunctionalBlock.h"\r
2 #include "ReferenceBlock.h"\r
3 #include "GroupBlock.h"\r
4 #include "AbstractInterface.h"\r
5 #include "FunctionalInterface.h"\r
6 #include "ReferenceInterface.h"\r
7 #include "BlockParameter.h"\r
8 \r
9 \r
10 FunctionalBlock::FunctionalBlock(GroupBlock *_parent, ReferenceBlock *_reference) throw(Exception) :  AbstractBlock() {\r
11   //if (! _reference->isReferenceBlock()) throw(Exception(BLOCK_INVALID_TYPE));\r
12   //if (! _group->isGroupBlock()) throw(Exception(BLOCK_INVALID_TYPE));\r
13   reference = _reference;\r
14   parent = _parent;\r
15   name = reference->getName();\r
16 }\r
17 \r
18 \r
19 void FunctionalBlock::parametersValidation(QList<AbstractBlock*>* checkedBlocks, QList<AbstractBlock *> *blocksToConfigure) {\r
20   /*\r
21   checkedBlocks->append(this);\r
22 \r
23   foreach(BlockParameter* param, params){\r
24     if(param->isUserParameter() && !param->isValueSet()){\r
25       if(!blocksToConfigure->contains(param->getOwner())){\r
26         blocksToConfigure->append(param->getOwner());\r
27       }\r
28     }\r
29   }\r
30   foreach(AbstractInterface *inter, outputs){\r
31     foreach(AbstractInterface *connectedInter, inter->getConnectedTo()){\r
32       if(!checkedBlocks->contains(connectedInter->getOwner())){\r
33         connectedInter->getOwner()->parametersValidation(checkedBlocks, blocksToConfigure);\r
34       }\r
35     }\r
36   }\r
37   */\r
38 }\r
39 \r
40 bool FunctionalBlock::isFunctionalBlock() {\r
41   return true;\r
42 }\r
43 \r
44 void FunctionalBlock::populate() {\r
45   int i;\r
46   BlockParameter* p;\r
47   AbstractInterface* inter;\r
48 \r
49   QList<BlockParameter*> lstParam = reference->getParameters();\r
50   for(i=0;i<lstParam.size();i++) {\r
51     p = lstParam.at(i)->clone();\r
52     addParameter(p);\r
53   }\r
54 \r
55   QList<AbstractInterface *> lstInter = reference->getInterfaces();\r
56   for(i=0;i<lstInter.size();i++) {\r
57     try {\r
58       inter = new FunctionalInterface(this, (ReferenceInterface*)lstInter.at(i));\r
59     }\r
60     catch(Exception e) {\r
61       cerr << "Abnormal case: " << qPrintable(e.getDefaultMessage()) << endl << "Aborting execution." << endl;\r
62       exit(1);\r
63     }\r
64 \r
65     addInterface(inter);\r
66   }\r
67 \r
68 }\r
69 \r
70 \r
71 QString FunctionalBlock::getReferenceXmlFile() {\r
72     return ((ReferenceBlock *)reference)->getXmlFile();\r
73 }\r
74 \r
75 QString FunctionalBlock::getReferenceHashMd5()\r
76 {\r
77     return ((ReferenceBlock *)reference)->getHashMd5();\r
78 }\r