SECompartmentGraph.hxx
1/* Distributed under the Apache License, Version 2.0.
2 See accompanying NOTICE file for details.*/
3
4template<COMPARTMENT_GRAPH_TEMPLATE>
5SECompartmentGraph<COMPARTMENT_GRAPH_TYPES>::SECompartmentGraph(const std::string& name, Logger* logger) : Loggable(logger), m_Name(name)
6{
7
8}
9template<COMPARTMENT_GRAPH_TEMPLATE>
11{
12 Clear();
13}
14
15template<COMPARTMENT_GRAPH_TEMPLATE>
17{
18 m_Compartments.clear();
19 m_CompartmentLinks.clear();
20}
21
22template<COMPARTMENT_GRAPH_TEMPLATE>
24{
25 return m_Name;
26}
27
28template<COMPARTMENT_GRAPH_TEMPLATE>
30{
31 if (GetCompartment(cmpt.GetName()) == nullptr)
32 m_Compartments.push_back(&cmpt);
33}
34template<COMPARTMENT_GRAPH_TEMPLATE>
36{
37 m_Compartments.push_back(&cmpt);
38}
39template<COMPARTMENT_GRAPH_TEMPLATE>
40CompartmentType* SECompartmentGraph<COMPARTMENT_GRAPH_TYPES>::GetCompartment(const std::string& name)
41{
42 for (CompartmentType* c : m_Compartments)
43 {
44 if (c->GetName() == name)
45 return c;
46 }
47 return nullptr;
48}
49template<COMPARTMENT_GRAPH_TEMPLATE>
50const CompartmentType* SECompartmentGraph<COMPARTMENT_GRAPH_TYPES>::GetCompartment(const std::string& name) const
51{
52 for (CompartmentType* c : m_Compartments)
53 {
54 if (c->GetName() == name)
55 return c;
56 }
57 return nullptr;
58}
59template<COMPARTMENT_GRAPH_TEMPLATE>
60const std::vector<CompartmentType*>& SECompartmentGraph<COMPARTMENT_GRAPH_TYPES>::GetCompartments() const
61{
62 return m_Compartments;
63}
64template<COMPARTMENT_GRAPH_TEMPLATE>
65void SECompartmentGraph<COMPARTMENT_GRAPH_TYPES>::RemoveCompartment(const CompartmentType& Compartment)
66{
67 size_t i = 0;
68 for (CompartmentType* n : m_Compartments)
69 {
70 if (n == &Compartment)
71 {
72 m_Compartments.erase(m_Compartments.begin() + i);
73 return;
74 }
75 i++;
76 }
77}
78template<COMPARTMENT_GRAPH_TEMPLATE>
80{
81 size_t i = 0;
82 for (CompartmentType* n : m_Compartments)
83 {
84 if (n->GetName() == name)
85 {
86 m_Compartments.erase(m_Compartments.begin() + i);
87 return;
88 }
89 i++;
90 }
91}
92
93template<COMPARTMENT_GRAPH_TEMPLATE>
94void SECompartmentGraph<COMPARTMENT_GRAPH_TYPES>::AddLink(CompartmentLinkType& link)
95{
96 if (GetLink(link.GetName()) == nullptr)
97 m_CompartmentLinks.push_back(&link);
98}
99template<COMPARTMENT_GRAPH_TEMPLATE>
101{
102 m_CompartmentLinks.push_back(&link);
103}
104template<COMPARTMENT_GRAPH_TEMPLATE>
105CompartmentLinkType* SECompartmentGraph<COMPARTMENT_GRAPH_TYPES>::GetLink(const std::string& name)
106{
107 for (CompartmentLinkType* p : m_CompartmentLinks)
108 {
109 if (p->GetName() == name)
110 return p;
111 }
112 return nullptr;
113}
114template<COMPARTMENT_GRAPH_TEMPLATE>
115const CompartmentLinkType* SECompartmentGraph<COMPARTMENT_GRAPH_TYPES>::GetLink(const std::string& name) const
116{
117 for (CompartmentLinkType* p : m_CompartmentLinks)
118 {
119 if (p->GetName() == name)
120 return p;
121 }
122 return nullptr;
123}
124template<COMPARTMENT_GRAPH_TEMPLATE>
125const std::vector<CompartmentLinkType*>& SECompartmentGraph<COMPARTMENT_GRAPH_TYPES>::GetLinks() const
126{
127 return m_CompartmentLinks;
128}
129template<COMPARTMENT_GRAPH_TEMPLATE>
130void SECompartmentGraph<COMPARTMENT_GRAPH_TYPES>::RemoveLink(const CompartmentLinkType& CompartmentLink)
131{
132 size_t i = 0;
133 for (CompartmentLinkType* p : m_CompartmentLinks)
134 {
135 if (p == &CompartmentLink)
136 {
137 m_CompartmentLinks.erase(m_CompartmentLinks.begin() + i);
138 return;
139 }
140 i++;
141 }
142}
143template<COMPARTMENT_GRAPH_TEMPLATE>
145{
146 size_t i = 0;
147 for (CompartmentLinkType* p : m_CompartmentLinks)
148 {
149 if (p->GetName() == name)
150 {
151 m_CompartmentLinks.erase(m_CompartmentLinks.begin() + i);
152 return;
153 }
154 i++;
155 }
156}
Definition: Logger.h:23
Definition: Logger.h:71
virtual CompartmentLinkType * GetLink(const std::string &name)
std::string m_Name
Definition: SECompartmentGraph.h:39
SECompartmentGraph(const std::string &name, Logger *logger)
virtual void RemoveCompartment(const CompartmentType &cmpt)
virtual void RemoveLink(const CompartmentLinkType &link)
virtual void Clear()
virtual const std::vector< CompartmentType * > & GetCompartments() const
virtual void ForceAddCompartment(CompartmentType &cmpt)
std::vector< CompartmentLinkType * > m_CompartmentLinks
Definition: SECompartmentGraph.h:41
virtual CompartmentType * GetCompartment(const std::string &name)
virtual ~SECompartmentGraph()
virtual void AddCompartment(CompartmentType &cmpt)
std::vector< CompartmentType * > m_Compartments
Definition: SECompartmentGraph.h:40
virtual const std::vector< CompartmentLinkType * > & GetLinks() const
virtual void AddLink(CompartmentLinkType &link)
virtual void ForceAddLink(CompartmentLinkType &link)
virtual std::string GetName() const

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.