OverSim
StrategyTreeTest.cc
Go to the documentation of this file.
1 //
2 // Copyright (C) 2010 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 
25 #include "StrategyTreeTest.h"
26 
28  // TODO Auto-generated constructor stub
29 }
30 
32  // TODO Auto-generated destructor stub
33 }
34 
36 
37  TreeTestStrategyCall* treeTestStrategyCall = dynamic_cast<TreeTestStrategyCall*>(globalViewBuilderCall);
38 
39  setBranchCount(treeTestStrategyCall->getSrcNode(),treeTestStrategyCall->getNodeCount());
40 
41 }
42 
44 
45  TreeTestStrategyCall* msg = new TreeTestStrategyCall("TreeTestStrategyCall");
46 
47  msg->setNodeCount(getNodeCount());
48  msg->setBitLength(TREETESTSTRATEGYCALL_L(msg));
49 
50  return msg;
51 }
52 
54 
55  std::stringstream tempStr;
56 
57  tempStr << "BNC: " << getNodeCount() << " | BC: " << branchCountMap.size();
58 
59  return tempStr.str();
60 }
61 
63 
64  std::stringstream tempStr;
65  tempStr << "treeTest";
66 
67  return tempStr.str();
68 }
69 
70 void StrategyTreeTest::setBranchCount(const NodeHandle& treeNode, int count) {
71 
72  if(branchCountMap.find(treeNode) != branchCountMap.end()) {
73  branchCountMap.find(treeNode)->second = count;
74  } else {
75  branchCountMap.insert(branchCount(treeNode, count));
76  }
77 
78 }
79 
80 void StrategyTreeTest::cleanUpCoordData(const treeNodeMap& currentTreeChildNodes) {
81 
82  nodeCountMap::const_iterator branchIterator = branchCountMap.begin();
83 
84  while(branchIterator != branchCountMap.end()) {
85 
86  if(currentTreeChildNodes.find(branchIterator->first) == currentTreeChildNodes.end() && branchIterator->first != thisNode) {
87  branchCountMap.erase(branchIterator);
88  }
89 
90  branchIterator++;
91  }
92 
93 }
94 
96 
97  int nodeCount = 0;
98 
99  nodeCountMap::const_iterator branchCountMapIterator = branchCountMap.begin();
100 
101  while(branchCountMapIterator != branchCountMap.end()) {
102  nodeCount += branchCountMapIterator->second;
103  ++branchCountMapIterator;
104  }
105 
106  return nodeCount;
107 }
108 
111 }
112 
113 std::vector<std::vector<double> > StrategyTreeTest::getGlobalViewData() {
114  std::vector<std::vector<double> > test;
115  return test;
116 }