1 #include "GroupBlock.h"
2 #include "BlockParameterGeneric.h"
3 #include "AbstractInterface.h"
7 int GroupBlock::counter = 1;
9 GroupBlock::GroupBlock(GroupBlock *_parent) throw(Exception) : AbstractBlock() {
11 // force topGroup to false if this group has a parent
12 if (_parent != NULL) {
14 name = QString("sub_group")+"_"+QString::number(counter++);
18 name = QString("top_group");
22 // adding this to the child blocks of parent
23 AB_TO_GRP(parent)->addBlock(this);
27 GroupBlock::~GroupBlock() {
28 foreach(AbstractBlock* block, blocks) {
33 bool GroupBlock::isGroupBlock() {
37 void GroupBlock::setParent(AbstractBlock *_parent) {
43 void GroupBlock::removeAllBlocks() {
44 foreach(AbstractBlock* block, blocks) {
45 if (block->isGroupBlock()) {
46 GroupBlock* group = AB_TO_GRP(block);
47 group->removeAllBlocks();
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.
57 blocks.removeAll(block);
61 void GroupBlock::parametersValidation(QList<AbstractBlock *> *checkedBlocks, QList<AbstractBlock *> *blocksToConfigure) {
64 checkedBlocks->append(this);
66 foreach(BlockParameter* param, params){
67 if(param->isUserParameter() && !param->isValueSet()){
68 if(!blocksToConfigure->contains(param->getOwner())){
69 blocksToConfigure->append(param->getOwner());
73 foreach(AbstractInterface *inter, outputs){
74 foreach(AbstractInterface *connectedInter, inter->getConnectedTo()){
75 if(!checkedBlocks->contains(connectedInter->getOwner())){
76 connectedInter->getOwner()->parametersValidation(checkedBlocks, blocksToConfigure);
83 void GroupBlock::addGenericParameter(QString name, QString type, QString value) {
84 BlockParameter* param = new BlockParameterGeneric(this, name, type, value);
88 void GroupBlock::removeGenericParameter(QString name) {
89 BlockParameter* p = getParameterFromName(name);
90 if (p != NULL) params.removeAll(p);