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

Private GIT Repository
1st commit of all files
[blast.git] / GroupBlock.cpp
1 #include "GroupBlock.h"
2 #include "BlockParameterGeneric.h"
3 #include "AbstractInterface.h"
4 #include "string.h"
5 #include <sstream>
6
7 int GroupBlock::counter = 1;
8
9 GroupBlock::GroupBlock(GroupBlock *_parent) throw(Exception) :  AbstractBlock() {
10
11   // force topGroup to false if this group has a parent
12   if (_parent != NULL) {    
13     topGroup = false;
14     name = QString("sub_group")+"_"+QString::number(counter++);
15   }
16   else {
17     topGroup = true;
18     name = QString("top_group");
19   }
20   parent = _parent;
21   if (parent != NULL) {
22     // adding this to the child blocks of parent
23     AB_TO_GRP(parent)->addBlock(this);
24   }
25 }
26
27 GroupBlock::~GroupBlock() {
28   foreach(AbstractBlock* block, blocks) {
29     delete block;
30   }
31 }
32
33 bool GroupBlock::isGroupBlock() {
34   return true;
35 }
36
37 void GroupBlock::setParent(AbstractBlock *_parent) {
38   parent = _parent;
39   if (parent != NULL) {
40     topGroup = false;
41   }
42 }
43
44 void GroupBlock::removeBlock(AbstractBlock* block) {
45     blocks.removeAll(block);
46 }
47
48 void GroupBlock::parametersValidation(QList<AbstractBlock *> *checkedBlocks, QList<AbstractBlock *> *blocksToConfigure) {
49
50   /*
51   checkedBlocks->append(this);
52
53   foreach(BlockParameter* param, params){
54     if(param->isUserParameter() && !param->isValueSet()){
55       if(!blocksToConfigure->contains(param->getOwner())){
56         blocksToConfigure->append(param->getOwner());
57       }
58     }
59   }
60   foreach(AbstractInterface *inter, outputs){
61     foreach(AbstractInterface *connectedInter, inter->getConnectedTo()){
62       if(!checkedBlocks->contains(connectedInter->getOwner())){
63         connectedInter->getOwner()->parametersValidation(checkedBlocks, blocksToConfigure);
64       }
65     }
66   }
67   */
68 }
69
70 void GroupBlock::addGenericParameter(QString name, QString type, QString value) {
71   BlockParameter* param = new BlockParameterGeneric(this, name, type, value);
72   params.append(param);
73 }
74
75 void GroupBlock::removeGenericParameter(QString name) {
76   BlockParameter* p = getParameterFromName(name);
77   if (p != NULL) params.removeAll(p);
78 }