Class Reference for E1039 Core & Analysis Software
RoadMap.cc
Go to the documentation of this file.
1 //#include <iostream>
2 //#include <iomanip>
3 //#include <algorithm>
4 #include "RoadInfo.h"
5 #include "RoadMap.h"
6 using namespace std;
7 
9 {
10  ;
11 }
12 
14 {
15  for (Iter it = m_map.begin(); it != m_map.end(); it++) {
16  if (it->second) delete it->second;
17  }
18  m_map.clear();
19 }
20 
21 RoadInfo* RoadMap::Find(const int road) const
22 {
23  return m_map.find(road) != m_map.end() ? m_map.at(road) : 0;
24 }
25 
26 bool RoadMap::Contain(const RoadMap* map) const
27 {
28  for (RoadMap::ConstIter it = map->Begin(); it != map->End(); it++) {
29  if (m_map.find(it->first) != m_map.end()) return true;
30  }
31  return false;
32 }
33 
34 bool RoadMap::ContainEnabled(const RoadMap* map) const
35 {
36  for (RoadMap::ConstIter it = map->Begin(); it != map->End(); it++) {
37  if (! it->second->GetOnOff()) continue;
38  if (m_map.find(it->first) != m_map.end()) return true;
39  }
40  return false;
41 }
42 
43 void RoadMap::Add(const int road, const double weight, const int count)
44 {
45  RoadInfo* info = Find(road);
46  if (! info) {
47  if (m_frozen) return;
48  info = new RoadInfo(road);
49  m_map[road] = info;
50  }
51  info->Add(weight, count);
52 }
53 
54 void RoadMap::Add(const RoadInfo* info)
55 {
56  Add(info->GetRoadID(), info->GetWeight(), info->GetCount());
57 }
58 
59 void RoadMap::Add(const RoadMap* map)
60 {
61  for (RoadMap::ConstIter it = map->Begin(); it != map->End(); it++) Add(it->second);
62 }
63 
64 void RoadMap::Scale(const double val)
65 {
66  for (RoadMap::Iter it = m_map.begin(); it != m_map.end(); it++) it->second->Scale(val);
67 }
68 
69 void RoadMap::AddBG(const int road, const double weight, const int count)
70 {
71  RoadInfo* info = Find(road);
72  if (! info) {
73  if (m_frozen) return;
74  info = new RoadInfo(road);
75  m_map[road] = info;
76  }
77  info->AddBG(weight, count);
78 }
79 
80 void RoadMap::AddBG(const RoadInfo* info)
81 {
82  AddBG(info->GetRoadID(), info->GetWeightBG(), info->GetCountBG());
83 }
84 
85 void RoadMap::AddBG(const RoadMap* map)
86 {
87  for (RoadMap::ConstIter it = map->Begin(); it != map->End(); it++) AddBG(it->second);
88 }
89 
90 void RoadMap::ScaleBG(const double val)
91 {
92  for (RoadMap::Iter it = m_map.begin(); it != m_map.end(); it++) it->second->ScaleBG(val);
93 }
94 
Class to hold one road.
Definition: RoadInfo.h:8
void Add(const double weight, const int count=1)
Definition: RoadInfo.cc:43
double GetWeightBG() const
Definition: RoadInfo.h:36
int GetCountBG() const
Definition: RoadInfo.h:35
int GetRoadID() const
Definition: RoadInfo.h:23
double GetWeight() const
Definition: RoadInfo.h:29
void AddBG(const double weight, const int count=1)
Definition: RoadInfo.cc:54
int GetCount() const
Definition: RoadInfo.h:28
Class to hold a non-ordered set (i.e. map) of roads.
Definition: RoadMap.h:8
bool ContainEnabled(const RoadMap *map) const
Definition: RoadMap.cc:34
virtual ~RoadMap()
Definition: RoadMap.cc:13
RoadMap()
Definition: RoadMap.cc:8
InfoMap::const_iterator ConstIter
Definition: RoadMap.h:14
bool Contain(const RoadMap *map) const
Definition: RoadMap.cc:26
void Add(const int road, const double weight, const int count=1)
Definition: RoadMap.cc:43
RoadInfo * Find(const int road) const
Definition: RoadMap.cc:21
InfoMap::iterator Iter
Definition: RoadMap.h:13
ConstIter End() const
Definition: RoadMap.h:21
void Scale(const double val)
Definition: RoadMap.cc:64
void AddBG(const int road, const double weight, const int count=1)
Definition: RoadMap.cc:69
void ScaleBG(const double val)
Definition: RoadMap.cc:90
ConstIter Begin() const
Definition: RoadMap.h:20