SECircuitManager.h
1 /* Distributed under the Apache License, Version 2.0.
2  See accompanying NOTICE file for details.*/
3 
4 #pragma once
5 class SEFluidCircuit;
8 class SEThermalCircuit;
14 
15 #define CIRCUIT_LEDGER_TEMPLATE typename NodeType, typename PathType, typename CircuitType
16 #define CIRCUIT_LEDGER_TYPES NodeType,PathType,CircuitType
17 
18 template<CIRCUIT_LEDGER_TEMPLATE>
20 {
21  friend class PBCircuit;//friend the serialization class
22  friend class SECircuitManager;
23 protected:
25 public:
26  virtual ~SECircuitLedger() { Clear(); };
27  void Clear();
28  std::map<std::string, NodeType*> nodes;
29  std::map<std::string, PathType*> paths;
30  std::map<std::string, CircuitType*> circuits;
31 };
32 
33 #define ELECTRICAL_LEDGER_TYPES SEElectricalCircuitNode,SEElectricalCircuitPath,SEElectricalCircuit
34 #define FLUID_LEDGER_TYPES SEFluidCircuitNode,SEFluidCircuitPath,SEFluidCircuit
35 #define THERMAL_LEDGER_TYPES SEThermalCircuitNode,SEThermalCircuitPath,SEThermalCircuit
36 
37 class CDM_DECL SECircuitManager : public Loggable
38 {
39  friend class PBCircuit;//friend the serialization class
40 public:
41  SECircuitManager(Logger* logger);
42  virtual ~SECircuitManager();
43 
44  virtual void Clear(); //clear memory
45 
46  virtual void StateChange() { };
47 
48  void SetReadOnly(bool b);
49 protected:
50 
51 
52 public:
53  virtual SEElectricalCircuitNode& CreateElectricalNode(const std::string& name);
54  virtual void DeleteElectricalNode(const std::string& name);
55  virtual bool HasElectricalNode(const std::string& name) const;
56  virtual SEElectricalCircuitNode* GetElectricalNode(const std::string& name);
57  virtual const SEElectricalCircuitNode* GetElectricalNode(const std::string& name) const;
58  virtual SEElectricalCircuitPath& CreateElectricalPath(SEElectricalCircuitNode& src, SEElectricalCircuitNode& tgt, const std::string& name);
59  virtual void DeleteElectricalPath(const std::string& name);
60  virtual bool HasElectricalPath(const std::string& name) const;
61  virtual SEElectricalCircuitPath* GetElectricalPath(const std::string& name);
62  virtual const SEElectricalCircuitPath* GetElectricalPath(const std::string& name) const;
63  virtual SEElectricalCircuit& CreateElectricalCircuit(const std::string& name);
64  virtual void DeleteElectricalCircuit(const std::string& name);
65  virtual bool HasElectricalCircuit(const std::string& name) const;
66  virtual SEElectricalCircuit* GetElectricalCircuit(const std::string& name);
67  virtual const SEElectricalCircuit* GetElectricalCircuit(const std::string& name) const;
68  virtual void SetReadOnlyElectrical(bool b);
69 protected:
71 
72 public:
73  virtual SEFluidCircuitNode& CreateFluidNode(const std::string& name);
74  virtual void DeleteFluidNode(const std::string& name);
75  virtual bool HasFluidNode(const std::string& name) const;
76  virtual SEFluidCircuitNode* GetFluidNode(const std::string& name);
77  virtual const SEFluidCircuitNode* GetFluidNode(const std::string& name) const;
78  virtual SEFluidCircuitPath& CreateFluidPath(SEFluidCircuitNode& src, SEFluidCircuitNode& tgt, const std::string& name);
79  virtual void DeleteFluidPath(const std::string& name);
80  virtual bool HasFluidPath(const std::string& name) const;
81  virtual SEFluidCircuitPath* GetFluidPath(const std::string& name);
82  virtual const SEFluidCircuitPath* GetFluidPath(const std::string& name) const;
83  virtual SEFluidCircuit& CreateFluidCircuit(const std::string& name);
84  virtual void DeleteFluidCircuit(const std::string& name);
85  virtual bool HasFluidCircuit(const std::string& name) const;
86  virtual SEFluidCircuit* GetFluidCircuit(const std::string& name);
87  virtual const SEFluidCircuit* GetFluidCircuit(const std::string& name) const;
88  virtual void SetReadOnlyFluid(bool b);
89 protected:
91 
92 public:
93  virtual SEThermalCircuitNode& CreateThermalNode(const std::string& name);
94  virtual void DeleteThermalNode(const std::string& name);
95  virtual bool HasThermalNode(const std::string& name) const;
96  virtual SEThermalCircuitNode* GetThermalNode(const std::string& name);
97  virtual const SEThermalCircuitNode* GetThermalNode(const std::string& name) const;
98  virtual SEThermalCircuitPath& CreateThermalPath(SEThermalCircuitNode& src, SEThermalCircuitNode& tgt, const std::string& name);
99  virtual void DeleteThermalPath(const std::string& name);
100  virtual bool HasThermalPath(const std::string& name) const;
101  virtual SEThermalCircuitPath* GetThermalPath(const std::string& name);
102  virtual const SEThermalCircuitPath* GetThermalPath(const std::string& name) const;
103  virtual SEThermalCircuit& CreateThermalCircuit(const std::string& name);
104  virtual void DeleteThermalCircuit(const std::string& name);
105  virtual bool HasThermalCircuit(const std::string& name) const;
106  virtual SEThermalCircuit* GetThermalCircuit(const std::string& name);
107  virtual const SEThermalCircuit* GetThermalCircuit(const std::string& name) const;
108  virtual void SetReadOnlyThermal(bool b); ;
109 protected:
111 
112 
113 protected:
114  template<CIRCUIT_LEDGER_TEMPLATE> NodeType& CreateNode(const std::string& name, SECircuitLedger<CIRCUIT_LEDGER_TYPES>& ledger);
115  template<CIRCUIT_LEDGER_TEMPLATE> void DeleteNode(const std::string& name, SECircuitLedger<CIRCUIT_LEDGER_TYPES>& ledger);
116  template<CIRCUIT_LEDGER_TEMPLATE> bool HasNode(const std::string& name, const SECircuitLedger<CIRCUIT_LEDGER_TYPES>& ledger) const;
117  template<CIRCUIT_LEDGER_TEMPLATE> NodeType* GetNode(const std::string& name, SECircuitLedger<CIRCUIT_LEDGER_TYPES>& ledger);
118  template<CIRCUIT_LEDGER_TEMPLATE> const NodeType* GetNode(const std::string& name, const SECircuitLedger<CIRCUIT_LEDGER_TYPES>& ledger) const;
119  template<CIRCUIT_LEDGER_TEMPLATE> PathType& CreatePath(NodeType& src, NodeType& tgt, const std::string& name, SECircuitLedger<CIRCUIT_LEDGER_TYPES>& ledger);
120  template<CIRCUIT_LEDGER_TEMPLATE> void DeletePath(const std::string& name, SECircuitLedger<CIRCUIT_LEDGER_TYPES>& ledger);
121  template<CIRCUIT_LEDGER_TEMPLATE> bool HasPath(const std::string& name, const SECircuitLedger<CIRCUIT_LEDGER_TYPES>& ledger) const;
122  template<CIRCUIT_LEDGER_TEMPLATE> PathType* GetPath(const std::string& name, SECircuitLedger<CIRCUIT_LEDGER_TYPES>& ledger);
123  template<CIRCUIT_LEDGER_TEMPLATE> const PathType* GetPath(const std::string& name, const SECircuitLedger<CIRCUIT_LEDGER_TYPES>& ledger) const;
124  template<CIRCUIT_LEDGER_TEMPLATE> CircuitType& CreateCircuit(const std::string& name, SECircuitLedger<CIRCUIT_LEDGER_TYPES>& ledger);
125  template<CIRCUIT_LEDGER_TEMPLATE> void DeleteCircuit(const std::string& name, SECircuitLedger<CIRCUIT_LEDGER_TYPES>& ledger);
126  template<CIRCUIT_LEDGER_TEMPLATE> bool HasCircuit(const std::string& name, const SECircuitLedger<CIRCUIT_LEDGER_TYPES>& ledger) const;
127  template<CIRCUIT_LEDGER_TEMPLATE> CircuitType* GetCircuit(const std::string& name, SECircuitLedger<CIRCUIT_LEDGER_TYPES>& ledger);
128  template<CIRCUIT_LEDGER_TEMPLATE> const CircuitType* GetCircuit(const std::string& name, const SECircuitLedger<CIRCUIT_LEDGER_TYPES>& ledger) const;
129 };
130 #include "circuit/SECircuitManager.inl"
virtual ~SECircuitLedger()
Definition: SECircuitManager.h:26
Definition: SEElectricalCircuit.h:11
Definition: Logger.h:61
Definition: SEFluidCircuitPath.h:8
Definition: SEElectricalCircuitPath.h:8
Definition: SEThermalCircuitPath.h:8
std::map< std::string, PathType * > paths
Definition: SECircuitManager.h:29
Definition: Logger.h:11
SECircuitLedger< SEFluidCircuitNode, SEFluidCircuitPath, SEFluidCircuit > m_FluidLedger
Definition: SECircuitManager.h:90
void Clear()
Definition: SECircuitManager.cpp:20
Definition: SEFluidCircuitNode.h:7
Definition: SEFluidCircuit.h:11
virtual void StateChange()
Definition: SECircuitManager.h:46
Definition: SEThermalCircuit.h:11
Definition: PBCircuit.h:25
Definition: SECircuitManager.h:37
std::map< std::string, CircuitType * > circuits
Definition: SECircuitManager.h:30
std::map< std::string, NodeType * > nodes
Definition: SECircuitManager.h:28
friend class SECircuitManager
Definition: SECircuitManager.h:22
SECircuitLedger()
Definition: SECircuitManager.h:24
Definition: SECircuitManager.h:19
Definition: SEThermalCircuitNode.h:7
Definition: SEElectricalCircuitNode.h:7
SECircuitLedger< SEElectricalCircuitNode, SEElectricalCircuitPath, SEElectricalCircuit > m_ElectricalLedger
Definition: SECircuitManager.h:70
SECircuitLedger< SEThermalCircuitNode, SEThermalCircuitPath, SEThermalCircuit > m_ThermalLedger
Definition: SECircuitManager.h:108