ConditionTreeFactory.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarX::Gui::ConditionTreeFactory
17 * @author Kai Welke ( welke at kit dot edu)
18 * @date
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
25 #include "TermNode.h"
26 
29 #include <ArmarXCore/interface/observers/ConditionHandlerInterface.h>
30 
31 
32 namespace armarx
33 {
35  {
36  public:
37  static TermNodePtr createConditionTree(TermTreeGraphicsScene* scene, QTableWidget* checksTable, const TermImplPtr& root, int conditionId, IceManagerPtr manager, ConditionHandlerInterfacePrx handler)
38  {
39  // handle root node
40  std::list<TermNodePtr> nodes;
41  TermNodePtr rootNode(new TermNode(scene, checksTable, root, conditionId, manager, handler));
42  nodes.push_back(rootNode);
43 
44  std::list<TermNodePtr>::iterator iterNodes = nodes.begin();
45 
46  while (iterNodes != nodes.end())
47  {
48  // retreive first element
49  TermNodePtr node = nodes.front();
50  nodes.pop_front();
51 
52  // add childs to list
53  TermImplSequence childs = node->getImpl()->getChilds();
54  TermImplSequence::iterator iterChilds = childs.begin();
55 
56  while (iterChilds != childs.end())
57  {
58  TermNodePtr childNode(new TermNode(scene, checksTable, TermImplPtr::dynamicCast(*iterChilds), conditionId, manager, handler));
59  node->addChild(childNode);
60  nodes.push_back(childNode);
61 
62  iterChilds++;
63  }
64 
65  // next term
66  iterNodes = nodes.begin();
67  }
68 
69  return rootNode;
70  }
71  };
72 }
73 
armarx::TermNodePtr
std::shared_ptr< TermNode > TermNodePtr
Definition: TermNode.h:42
TermNode.h
armarx::ConditionTreeFactory
Definition: ConditionTreeFactory.h:34
TermImpl.h
IceInternal::Handle< TermImpl >
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
armarx::TermTreeGraphicsScene
Definition: TermTreeGraphicsScene.h:32
armarx::ConditionTreeFactory::createConditionTree
static TermNodePtr createConditionTree(TermTreeGraphicsScene *scene, QTableWidget *checksTable, const TermImplPtr &root, int conditionId, IceManagerPtr manager, ConditionHandlerInterfacePrx handler)
Definition: ConditionTreeFactory.h:37
IceUtil::Handle< IceManager >
armarx::TermNode
class ARMARXCOMPONENT_IMPORT_EXPORT TermNode
Definition: TermNode.h:40
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
ImportExportComponent.h