Statement.hh 2.95 KB
Newer Older
sebastien's avatar
sebastien committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * Copyright (C) 2006-2008 Dynare Team
 *
 * This file is part of Dynare.
 *
 * Dynare is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Dynare is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 */

sebastien's avatar
sebastien committed
20
21
22
23
24
25
26
27
28
#ifndef _STATEMENT_HH
#define _STATEMENT_HH

using namespace std;

#include <ostream>
#include <string>
#include <map>

sebastien's avatar
sebastien committed
29
30
#include "SymbolList.hh"

sebastien's avatar
sebastien committed
31
32
33
34
class ModFileStructure
{
public:
  ModFileStructure();
35
36
  //! Wheter check is present
  bool check_present;
sebastien's avatar
sebastien committed
37
38
  //! Whether a simul statement is present
  bool simul_present;
sebastien's avatar
sebastien committed
39
40
41
42
43
44
45
46
47
48
49
  //! Whether a stoch_simul statement is present
  bool stoch_simul_present;
  //! Whether an estimation statement is present
  bool estimation_present;
  //! Whether a forecast statement is present
  bool forecast_present;
  //! Whether an osr statement is present
  bool osr_present;
  //! Whether a ramsey_policy statement is present
  bool ramsey_policy_present;
  //! The value of the "order" option of stoch_simul, estimation, forecast, osr, ramsey_policy
50
51
  //! Derivation order
  /*! First initialized to zero. If user sets order option somewhere in the MOD file, it will be equal to the maximum of order options. Otherwise will default to 2 */
sebastien's avatar
sebastien committed
52
  int order_option;
sebastien's avatar
sebastien committed
53
54
};

sebastien's avatar
sebastien committed
55
56
57
58
class Statement
{
public:
  virtual ~Statement();
sebastien's avatar
sebastien committed
59
60
  //! Do some internal check, and fill the ModFileStructure class
  virtual void checkPass(ModFileStructure &mod_file_struct);
sebastien's avatar
sebastien committed
61
62
63
64
65
66
67
  virtual void computingPass();
  //! Write Matlab outout code
  /*!
    \param output is the output stream of the main matlab file
    \param basename is the name of the modfile (without extension) which can be used to build auxiliary files
  */
  virtual void writeOutput(ostream &output, const string &basename) const = 0;
sebastien's avatar
sebastien committed
68
69
70
71
72
73
74
75
};

class NativeStatement : public Statement
{
private:
  const string native_statement;
public:
  NativeStatement(const string &native_statement_arg);
sebastien's avatar
sebastien committed
76
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
77
78
79
80
81
82
83
84
};

class OptionsList
{
public:
  typedef map<string, string> num_options_type;
  typedef map<string, pair<string, string> > paired_num_options_type;
  typedef map<string, string> string_options_type;
sebastien's avatar
sebastien committed
85
  typedef map<string, SymbolList> symbol_list_options_type;
sebastien's avatar
sebastien committed
86
87
88
  num_options_type num_options;
  paired_num_options_type paired_num_options;
  string_options_type string_options;
sebastien's avatar
sebastien committed
89
  symbol_list_options_type symbol_list_options;
sebastien's avatar
sebastien committed
90
  void writeOutput(ostream &output) const;
91
  void writeOutput(ostream &output, const string &option_group) const;
sebastien's avatar
sebastien committed
92
93
94
95
  void clear();
};

#endif // ! _STATEMENT_HH