Eclipse SUMO - Simulation of Urban MObility
Node.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
21 // Representation of electric circuit nodes, i.e. wire junctions and connection points.
22 /****************************************************************************/
23 #pragma once
24 #include <config.h>
25 
26 #include <vector>
27 #include <string>
28 
29 
30 // ===========================================================================
31 // class declarations
32 // ===========================================================================
33 class Element;
34 
35 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
39 class Node {
40 
41 private:
42  bool isground;
44  std::string name; // unique property, each object has distinctive and unique name
45  int id; // a sequential ID number, might be useful when making the equation
46  int num_matrixRow; // number of matrix row during solving the equations
47  int num_matrixCol; // number of matrix column during solving the equations
48  double voltage;
49  std::vector<Element*>* elements; // too lazy to implement a linked list
50  // each node is connected to one or more element, an element is a resistor or voltage/current source
51 
52 public:
53  // A constructor, same functionality as "init" functions
54  Node(std::string name, int id);
55 
56  // connects an element to the node
57  void addElement(Element* element);
58  // disconnects an element to the node
59  void eraseElement(Element* element);
60  // getters and setters
61  double getVoltage();
62  void setVoltage(double volt);
63  int getNumOfElements();
64  // iterates through the vector of the node's elements and returns the first, which is not equal to "element" in the argument of the function
66  std::string& getName();
67  bool isGround();
68  bool isRemovable() const {
69  return isremovable;
70  }
71  void setGround(bool isground);
72  int getId();
73  void setNumMatrixRow(int num);
74  int getNumMatrixRow();
75  void setNumMatrixCol(int num);
76  int getNumMatrixCol();
77  void setId(int id);
78  std::vector<Element*>* getElements();
79  void setRemovability(bool isremovable);
80 };
Definition: Node.h:39
void setVoltage(double volt)
Definition: Node.cpp:57
void setGround(bool isground)
Definition: Node.cpp:73
void setNumMatrixCol(int num)
Definition: Node.cpp:93
int getId()
Definition: Node.cpp:77
int getNumMatrixCol()
Definition: Node.cpp:97
int id
Definition: Node.h:45
Node(std::string name, int id)
Definition: Node.cpp:32
Element * getAnOtherElement(Element *element)
Definition: Node.cpp:109
bool isGround()
Definition: Node.cpp:69
bool isground
Definition: Node.h:42
void addElement(Element *element)
Definition: Node.cpp:44
void eraseElement(Element *element)
Definition: Node.cpp:48
bool isremovable
Definition: Node.h:43
int getNumOfElements()
Definition: Node.cpp:61
std::string & getName()
Definition: Node.cpp:65
double getVoltage()
Definition: Node.cpp:53
int num_matrixCol
Definition: Node.h:47
void setNumMatrixRow(int num)
Definition: Node.cpp:85
std::string name
Definition: Node.h:44
int num_matrixRow
Definition: Node.h:46
void setId(int id)
Definition: Node.cpp:81
void setRemovability(bool isremovable)
Definition: Node.cpp:105
std::vector< Element * > * getElements()
Definition: Node.cpp:101
std::vector< Element * > * elements
Definition: Node.h:49
double voltage
Definition: Node.h:48
int getNumMatrixRow()
Definition: Node.cpp:89
bool isRemovable() const
Definition: Node.h:68