Pulse adds COVID-19 Simulation Support
×
SECircuit.h
1 /* Distributed under the Apache License, Version 2.0.
2  See accompanying NOTICE file for details.*/
3 
4 #pragma once
5 #include "circuit/SECircuitNode.h"
6 #include "circuit/SECircuitPath.h"
7 
8 #define CIRCUIT_TEMPLATE typename NodeType, typename PathType
9 #define CIRCUIT_TYPES NodeType,PathType
10 
11 template<CIRCUIT_TEMPLATE>
12 class SECircuit : public Loggable
13 {
14  friend class PBCircuit;//friend the serialization class
15 public:
16 
17  SECircuit(const std::string& name, Logger* logger);
18  virtual ~SECircuit();
19 
20  virtual void Clear(); //clear memory
21 
22  virtual std::string GetName() const;
23 
24  virtual bool HasReferenceNode() const;
25 
26  // Nodes //
27  virtual void AddNode(NodeType& node);
28  virtual void ForceAddNode(NodeType& node);// No check for node with the same name
29  virtual bool HasNode(NodeType& node);
30  virtual bool HasNode(const std::string& name);
31  virtual NodeType* GetNode(const std::string& name);
32  virtual const NodeType* GetNode(const std::string& name) const;
33  virtual const std::vector<NodeType*>& GetNodes() const;
34  virtual void RemoveNode(const NodeType& node);
35  virtual void RemoveNode(const std::string& name);
36 
37  // Paths //
38  virtual void AddPath(PathType& node);
39  virtual void ForceAddPath(PathType& node);// No check for path with the same name
40  virtual bool HasPath(PathType& node);
41  virtual bool HasPath(const std::string& name);
42  virtual PathType* GetPath(const std::string& name);
43  virtual const PathType* GetPath(const std::string& name) const;
44  virtual const std::vector<PathType*>& GetPaths() const;
45  virtual void RemovePath(const PathType& path);
46  virtual void RemovePath(const std::string& name);
47  virtual const std::vector<PathType*>& GetValvePaths();
48  virtual const std::vector<PathType*>& GetPolarizedElementPaths();
49 
50  virtual const std::vector<PathType*>* GetTargetPaths(const NodeType& node) const;
51  virtual const std::vector<PathType*>* GetSourcePaths(const NodeType& node) const;
52  virtual const std::vector<PathType*>* GetConnectedPaths(const NodeType& node) const;
53 
54  virtual void StateChange();
55  virtual void SetNextAndCurrentFromBaselines();
56 
57 protected:
58  std::string m_Name;
59  std::stringstream m_ss;
60 
61  std::vector<NodeType*> m_Nodes;
62  std::vector<PathType*> m_Paths;
63 
64  std::map<const NodeType*, std::vector<PathType*>*> m_TargetPathMap;
65  std::map<const NodeType*, std::vector<PathType*>*> m_SourcePathMap;
66  std::map<const NodeType*, std::vector<PathType*>*> m_ConnectedPathMap;
67 
68  std::vector<PathType*> m_ValvePaths;
69  std::vector<PathType*> m_PolarizedElementPaths;
70 };
std::vector< PathType * > m_ValvePaths
Definition: SECircuit.h:68
virtual const std::vector< PathType * > & GetPolarizedElementPaths()
Definition: SECircuit.cpp:302
std::string m_Name
Definition: SECircuit.h:58
std::vector< NodeType * > m_Nodes
Definition: SECircuit.h:61
virtual std::string GetName() const
Definition: SECircuit.cpp:129
std::map< const NodeType *, std::vector< PathType * > * > m_TargetPathMap
Definition: SECircuit.h:64
virtual void AddNode(NodeType &node)
Definition: SECircuit.cpp:148
Definition: Logger.h:75
virtual bool HasPath(PathType &node)
Definition: SECircuit.cpp:234
virtual void RemoveNode(const NodeType &node)
Definition: SECircuit.cpp:194
std::stringstream m_ss
Definition: SECircuit.h:59
virtual void Clear()
Definition: SECircuit.cpp:22
virtual const std::vector< PathType * > * GetTargetPaths(const NodeType &node) const
Returns all target paths for a node.
Definition: SECircuit.cpp:320
virtual bool HasNode(NodeType &node)
Definition: SECircuit.cpp:159
std::map< const NodeType *, std::vector< PathType * > * > m_SourcePathMap
Definition: SECircuit.h:65
std::vector< PathType * > m_Paths
Definition: SECircuit.h:62
virtual void ForceAddPath(PathType &node)
Definition: SECircuit.cpp:229
virtual void StateChange()
Definition: SECircuit.cpp:40
virtual const std::vector< NodeType * > & GetNodes() const
Definition: SECircuit.cpp:189
Definition: Logger.h:21
std::map< const NodeType *, std::vector< PathType * > * > m_ConnectedPathMap
Definition: SECircuit.h:66
virtual const std::vector< PathType * > * GetConnectedPaths(const NodeType &node) const
Returns all source paths for a node.
Definition: SECircuit.cpp:368
virtual void RemovePath(const PathType &path)
Definition: SECircuit.cpp:269
virtual void ForceAddNode(NodeType &node)
Definition: SECircuit.cpp:154
virtual bool HasReferenceNode() const
Definition: SECircuit.cpp:135
Definition: PBCircuit.h:25
virtual PathType * GetPath(const std::string &name)
Definition: SECircuit.cpp:244
std::vector< PathType * > m_PolarizedElementPaths
Definition: SECircuit.h:69
virtual NodeType * GetNode(const std::string &name)
Definition: SECircuit.cpp:169
virtual const std::vector< PathType * > & GetValvePaths()
Definition: SECircuit.cpp:297
SECircuit(const std::string &name, Logger *logger)
Definition: SECircuit.cpp:11
Definition: SECircuit.h:12
virtual void AddPath(PathType &node)
Definition: SECircuit.cpp:223
virtual const std::vector< PathType * > & GetPaths() const
Definition: SECircuit.cpp:264
virtual ~SECircuit()
Definition: SECircuit.cpp:16
virtual const std::vector< PathType * > * GetSourcePaths(const NodeType &node) const
Returns all source paths for a node.
Definition: SECircuit.cpp:344
virtual void SetNextAndCurrentFromBaselines()
Set all Current and Next values to the Baseline values for all Elements.
Definition: SECircuit.cpp:384

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.