charon-core  0.3.1
WhileGroup.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2012 Gerald Mwangi
2 
3  This file is part of Charon.
4 
5  Charon is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  Charon is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with Charon. If not, see <http://www.gnu.org/licenses/>.
17 */
26 #include "../include/charon-core/WhileGroup.h"
27 #include "../include/charon-core/StatementIntf.h"
28 
29 WhileGroup::WhileGroup(const std::string& name) :
31  "WhileGroup", name,
32  "<h2>Executes the group as long as a given statement is "
33  "true</h2><br>"
34  "Executes the group as long as a given statement is true"
35  ),statement(true,false)
36 {
37  ParameteredObject::_setTags("charon-core") ;
38 
39  _addInputSlot(statement,"Statement","Statement for this whilegroup","bool");
40  // statement=true;
41  _innerWhilestatement=0;
42 }
43 
46 
47  bool extstatement=true;
48  if(!_innerWhilestatement)
49  return;
50 
51 
52  if(statement.connected()) {
53  extstatement=extstatement&&statement();
54  }
55  while((*_innerWhilestatement)&&extstatement) {
56  _pluginMan->runWorkflow();
58  _pluginMan->resetExecuted();
59  }
60  _innerWhilestatement->reset();
62 }
63 
66  create(const std::string& name, ParameteredObject::template_type) {
67  return new WhileGroup(name);
68 }
69 
72  delete b;
73 }
74 
77 #ifdef _DEBUG
79 #else
81 #endif
82 }
83 
84 
85 
87 
88  initializeWhileGroup();
89 
90  std::map<std::string, ParameteredObject *> objs=_pluginMan->getObjectList();
91 
92  std::map<std::string, ParameteredObject *>::iterator it=objs.begin();
93  for(;it!=objs.end();it++)
94  {
95  ParameteredObject* obj=it->second;
96  StatementIntf* curStatement=dynamic_cast<StatementIntf*>(obj);
97 
98  if (curStatement) {
99  _innerWhilestatement=curStatement;
100  break;
101  }
102 
103  }
104  if(!_innerWhilestatement)
105  {
106  std::stringstream msg;
107  msg<<"Could not find a statement module in the workflow: "<<this->workFlowFile();
108  raise(msg.str());
109  }
110 }
111 
112 void WhileGroup::initializeWhileGroup() {
113 
114 }
whilegroup_DECLDIR ParameteredObject * create(const std::string &name, ParameteredObject::template_type)
Creates an instance of the plugin.
Definition: WhileGroup.cpp:66
void initializeGroup()
Group Initialization.
Definition: WhileGroup.cpp:86
build_type
defined build type
#define whilegroup_DECLDIR
Not needed without MSVC.
Definition: WhileGroup.h:36
template_type
Integer which represents a template type.
WhileGroup(const std::string &name="")
default constructor
Definition: WhileGroup.cpp:29
Base class for serializable objects.
Convenience file to iclude all ParameteredObject dependencies and Template functions.
bool connected() const
Check if slot is connected.
Definition: Slots.cpp:85
void _setTags(const std::string &tags)
Register additional tag names for grouping ParameteredObjects.
the object was compiled in release mode
whilegroup_DECLDIR void destroy(ParameteredObject *b)
Deletes an instance of the plugin.
Definition: WhileGroup.cpp:71
void _addInputSlot(Slot &slot, const std::string &name, const std::string &doc, const std::string &type="")
These functions needs to be called by the derived class in order to register all objects which can be...
whilegroup_DECLDIR ParameteredObject::build_type getBuildType()
Report build configuration to prevent linking of incompatibel runtime libs.
Definition: WhileGroup.cpp:76
void executeGroup()
Update object.
Definition: WhileGroup.cpp:44
void enableLoopConnections()
enableLoopConnections
the object was compiled in debug mode
void runWorkflow()
run whole workflow
virtual void execute()
execute plugin code
const std::map< std::string, ParameteredObject * > & getObjectList() const
Get names of existing instances.
void resetExecuted()
Set the executed flags of the objects to false.
void disableLoopConnections()
disableLoopConnections