MicroModelicaCCompiler  4.5.3
macros.hpp
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  This file is part of QSS Solver.
4 
5  QSS Solver is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  QSS Solver is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QSS Solver. If not, see <http://www.gnu.org/licenses/>.
17 
18  ******************************************************************************/
19 
20 #pragma once
21 
22 #include <fstream>
23 #include <string>
24 #include <list>
25 
26 #include <ir/class.hpp>
27 #include <ir/index.hpp>
28 #include <util/symbol_table.hpp>
29 
30 namespace MicroModelica {
31 namespace Generator {
32 
33 namespace MACROS {
34 typedef enum { Modelica, Engine } Offset;
35 }
36 
37 class Macros {
38  public:
39  Macros(IR::Model& model, Util::Variable& variable);
40  Macros() : _model(), _variable(){};
41  ~Macros() = default;
42  std::string print() const;
43  std::string parameters(MACROS::Offset offset = MACROS::Modelica) const;
44  std::string engineIndex() const;
45  std::string engineIndexArguments() const;
46  std::string arguments(bool state = true) const;
47  std::string usage(std::string token, Option<IR::Range> range, int id) const;
48  std::string indexMacro(std::string token, Option<IR::Range> range, int id) const;
49  std::string modelAccess(int discretes, int algebraics);
50  std::string coeffMultipliers(int order);
51  friend std::ostream& operator<<(std::ostream& out, const Macros& m);
52 
53  protected:
54  void initialize();
55 
56  private:
57  IR::Model _model;
58  Util::Variable _variable;
59  bool _is_qss;
60  std::stringstream _macros;
61 };
62 } // namespace Generator
63 } // namespace MicroModelica
MicroModelica::Generator::Macros::engineIndex
std::string engineIndex() const
Definition: macros.cpp:111
MicroModelica::Generator::Macros::print
std::string print() const
Definition: macros.cpp:287
index.hpp
MicroModelica::Generator::Macros::operator<<
friend std::ostream & operator<<(std::ostream &out, const Macros &m)
Definition: macros.cpp:289
MicroModelica::Generator::Macros::Macros
Macros()
Definition: macros.hpp:74
symbol_table.hpp
MicroModelica::Generator::Macros::_model
IR::Model _model
Definition: macros.hpp:91
MicroModelica::Generator::MACROS::Engine
@ Engine
Definition: macros.hpp:102
Option
Definition: util_types.hpp:32
MicroModelica::Generator::Macros::_variable
Util::Variable _variable
Definition: macros.hpp:92
MicroModelica::Generator::Macros::indexMacro
std::string indexMacro(std::string token, Option< IR::Range > range, int id) const
Definition: macros.cpp:208
MicroModelica::Generator::Macros::arguments
std::string arguments(bool state=true) const
Definition: macros.cpp:61
MicroModelica::Generator::Macros::_macros
std::stringstream _macros
Definition: macros.hpp:94
MicroModelica::Generator::MACROS::Modelica
@ Modelica
Definition: macros.hpp:102
MicroModelica::Generator::Macros::engineIndexArguments
std::string engineIndexArguments() const
Definition: macros.cpp:90
MicroModelica::Generator::Macros::coeffMultipliers
std::string coeffMultipliers(int order)
Definition: macros.cpp:255
MicroModelica::Generator::Macros::parameters
std::string parameters(MACROS::Offset offset=MACROS::Modelica) const
Definition: macros.cpp:39
MicroModelica
Definition: files.cpp:45
MicroModelica::Generator::Macros::initialize
void initialize()
Definition: macros.cpp:124
MicroModelica::Generator::Macros::usage
std::string usage(std::string token, Option< IR::Range > range, int id) const
Definition: macros.cpp:198
MicroModelica::Generator::MACROS::Offset
Offset
Definition: macros.hpp:85
MicroModelica::Generator::Macros::~Macros
~Macros()=default
MicroModelica::Generator::Macros::_is_qss
bool _is_qss
Definition: macros.hpp:93
class.hpp
MicroModelica::Generator::Macros::modelAccess
std::string modelAccess(int discretes, int algebraics)
Definition: macros.cpp:234