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

Private GIT Repository
adding xsd files to master
[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 void GroupBlock::removeAllBlocks() {
44   foreach(AbstractBlock* block, blocks) {
45     if (block->isGroupBlock()) {
46       GroupBlock* group = AB_TO_GRP(block);
47       group->removeAllBlocks();
48     }
49     removeBlock(block);
50   }
51 }
52
53 void GroupBlock::removeBlock(AbstractBlock* block) {
54   /* CAUTION: no check is done if the block has connected interface
55      or not. Thus, they must be deleted elsewhere.
56   */
57   blocks.removeAll(block);
58   delete block;
59 }
60
61 void GroupBlock::parametersValidation(QList<AbstractBlock *> *checkedBlocks, QList<AbstractBlock *> *blocksToConfigure) {
62
63   /*
64   checkedBlocks->append(this);
65
66   foreach(BlockParameter* param, params){
67     if(param->isUserParameter() && !param->isValueSet()){
68       if(!blocksToConfigure->contains(param->getOwner())){
69         blocksToConfigure->append(param->getOwner());
70       }
71     }
72   }
73   foreach(AbstractInterface *inter, outputs){
74     foreach(AbstractInterface *connectedInter, inter->getConnectedTo()){
75       if(!checkedBlocks->contains(connectedInter->getOwner())){
76         connectedInter->getOwner()->parametersValidation(checkedBlocks, blocksToConfigure);
77       }
78     }
79   }
80   */
81 }
82
83 void GroupBlock::addGenericParameter(QString name, QString type, QString value) {
84   BlockParameter* param = new BlockParameterGeneric(this, name, type, value);
85   params.append(param);
86 }
87
88 void GroupBlock::removeGenericParameter(QString name) {
89   BlockParameter* p = getParameterFromName(name);
90   if (p != NULL) params.removeAll(p);
91 }