OMSimulatorLib
The OMSimulator project is a FMI-based co-simulation environment that supports ordinary (i.e., non-delayed) and TLM connections.
Connector.h
Go to the documentation of this file.
1 /*
2  * This file is part of OpenModelica.
3  *
4  * Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
5  * c/o Linköpings universitet, Department of Computer and Information Science,
6  * SE-58183 Linköping, Sweden.
7  *
8  * All rights reserved.
9  *
10  * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
11  * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
12  * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
13  * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
14  * ACCORDING TO RECIPIENTS CHOICE.
15  *
16  * The OpenModelica software and the Open Source Modelica
17  * Consortium (OSMC) Public License (OSMC-PL) are obtained
18  * from OSMC, either from the above address,
19  * from the URLs: http://www.ida.liu.se/projects/OpenModelica or
20  * http://www.openmodelica.org, and in the OpenModelica distribution.
21  * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
22  *
23  * This program is distributed WITHOUT ANY WARRANTY; without
24  * even the implied warranty of MERCHANTABILITY or FITNESS
25  * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
26  * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
27  *
28  * See the full OSMC Public License conditions for more details.
29  *
30  */
31 
32 #ifndef _OMS_CONNECTOR_H_
33 #define _OMS_CONNECTOR_H_
34 
35 #include "ComRef.h"
36 #include "ssd/ConnectorGeometry.h"
37 #include "Types.h"
38 
39 #include <string>
40 
41 #include <pugixml.hpp>
42 
43 namespace oms
44 {
48  class Connector : protected oms_connector_t
49  {
50  public:
52  Connector(oms_causality_enu_t causality, oms_signal_type_enu_t type, const oms::ComRef& name, double height);
53  ~Connector();
54 
55  // you have to free the memory yourself
56  static Connector* NewConnector(const pugi::xml_node& node);
57 
58  oms_status_enu_t exportToSSD(pugi::xml_node& root) const;
59 
60  // methods to copy the object
61  Connector(const Connector& rhs);
62  Connector& operator=(const Connector& rhs);
63 
64  operator std::string() const {return std::string(name);}
65 
66  void setName(const oms::ComRef& name);
67  void setGeometry(const oms::ssd::ConnectorGeometry* newGeometry);
68 
69  const oms_causality_enu_t getCausality() const {return causality;}
70  const oms_signal_type_enu_t getType() const {return type;}
71  const oms::ComRef getName() const {return oms::ComRef(name);}
72  const oms::ssd::ConnectorGeometry* getGeometry() const {return reinterpret_cast<oms::ssd::ConnectorGeometry*>(geometry);}
73  Connector addPrefix(const ComRef& prefix) const;
74 
75  bool isInput() const { return oms_causality_input == causality; }
76  bool isOutput() const { return oms_causality_output == causality; }
77 
78  bool isTypeReal() const { return oms_signal_type_real == type; }
79  bool isTypeInteger() const { return oms_signal_type_integer == type || oms_signal_type_enum == type; }
80  bool isTypeBoolean() const { return oms_signal_type_boolean == type; }
81 
82  private:
83  friend bool operator==(const Connector& v1, const Connector& v2);
84  friend bool operator!=(const Connector& v1, const Connector& v2);
85  };
86 
87  bool operator==(const Connector& v1, const Connector& v2);
88  bool operator!=(const Connector& v1, const Connector& v2);
89 }
90 
91 #endif
ssd_connector_geometry_t * geometry
Geometry information of the connector.
Definition: Types.h:365
const oms::ssd::ConnectorGeometry * getGeometry() const
Definition: Connector.h:72
oms_causality_enu_t
Definition: Types.h:61
Connector & operator=(const Connector &rhs)
Definition: Connector.cpp:194
oms_status_enu_t
Definition: Types.h:43
const oms_causality_enu_t getCausality() const
Definition: Connector.h:69
friend bool operator==(const Connector &v1, const Connector &v2)
static Connector * NewConnector(const pugi::xml_node &node)
Definition: Connector.cpp:86
bool isTypeBoolean() const
Definition: Connector.h:80
~Connector()
Definition: Connector.cpp:80
const oms::ComRef getName() const
Definition: Connector.h:71
char * name
Name of the connector.
Definition: Types.h:364
ComRef - component reference.
Definition: ComRef.h:43
Connector.
Definition: Connector.h:48
bool isInput() const
Definition: Connector.h:75
Definition: Types.h:117
oms_status_enu_t exportToSSD(pugi::xml_node &root) const
Definition: Connector.cpp:139
Definition: Types.h:118
Connector addPrefix(const ComRef &prefix) const
Definition: Connector.cpp:235
void setGeometry(const oms::ssd::ConnectorGeometry *newGeometry)
Definition: Connector.cpp:223
oms_signal_type_enu_t
Definition: Types.h:115
Definition: Types.h:120
Definition: BusConnector.h:15
bool isTypeReal() const
Definition: Connector.h:78
friend bool operator!=(const Connector &v1, const Connector &v2)
Signal: input, output, and parameter.
Definition: Types.h:361
oms_causality_enu_t causality
input/output/parameter
Definition: Types.h:362
bool isTypeInteger() const
Definition: Connector.h:79
void setName(const oms::ComRef &name)
Definition: Connector.cpp:213
Connector(oms_causality_enu_t causality, oms_signal_type_enu_t type, const oms::ComRef &name)
Definition: Connector.cpp:38
output
Definition: Types.h:63
input
Definition: Types.h:62
Definition: Types.h:116
Definition: ConnectorGeometry.h:45
const oms_signal_type_enu_t getType() const
Definition: Connector.h:70
bool isOutput() const
Definition: Connector.h:76
oms_signal_type_enu_t type
Type of the connector.
Definition: Types.h:363