MicroModelicaCCompiler  4.5.3
stored_definition.cpp
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 #include <boost/variant/variant.hpp>
21 #include <boost/variant/get.hpp>
22 #include "stored_definition.hpp"
23 
24 namespace MicroModelica {
25 namespace IR {
26 
27 StoredDefinition::StoredDefinition() : _def(), _functions() {}
28 
29 void StoredDefinition::setModel(string name) { _def = Model(name); }
30 
31 void StoredDefinition::setPackage(string name) { _def = Package(name); }
32 
33 void StoredDefinition::addFunction(Function& f) { _functions.insert(f.name(), f); }
34 
35 Option<Function> StoredDefinition::function(string name)
36 {
37  Option<Function> f = _functions[name];
38  return f;
39 }
40 
41 Model& StoredDefinition::model() { return boost::get<Model>(_def); }
42 
43 Package& StoredDefinition::package() { return boost::get<Package>(_def); }
44 
45 bool StoredDefinition::isModel() { return _def.type() == typeid(Model); }
46 
47 bool StoredDefinition::isPackage() { return _def.type() == typeid(Package); }
48 
49 void StoredDefinition::postProcess()
50 {
51  if (isModel()) {
52  model().setEquations();
53  model().setEvents();
54  model().setOutputs();
55  model().setCalledFunctions(_functions);
56  model().setInputs();
57  model().setModelConfig();
58  model().computeDependencies();
59  } else {
60  package().setFunctions(_functions);
61  }
62 }
63 
64 } // namespace IR
65 } // namespace MicroModelica
MicroModelica::Generator::WRITER::Model
@ Model
Definition: writer.hpp:79
Option
Definition: util_types.hpp:32
MicroModelica::IR::StoredDefinition::StoredDefinition
StoredDefinition()
Definition: stored_definition.cpp:61
MicroModelica
Definition: files.cpp:45
stored_definition.hpp