export_index_node.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of ACADO Toolkit.
3  *
4  * ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
5  * Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
6  * Milan Vukov, Rien Quirynen, KU Leuven.
7  * Developed within the Optimization in Engineering Center (OPTEC)
8  * under supervision of Moritz Diehl. All rights reserved.
9  *
10  * ACADO Toolkit is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 3 of the License, or (at your option) any later version.
14  *
15  * ACADO Toolkit is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with ACADO Toolkit; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
25 
26 
33 #ifndef ACADO_TOOLKIT_EXPORT_INDEX_NODE_HPP
34 #define ACADO_TOOLKIT_EXPORT_INDEX_NODE_HPP
35 
40 
42 
44 {
48 };
49 
51 {
52 public:
53  ExportIndexNode( const std::string& _name,
54  const std::string& _prefix,
55  const int _factor = 1,
56  const int _offset = 0)
57  : ExportDataInternal(_name, INT, ACADO_LOCAL, _prefix)
58  {
59  if ( _factor )
60  {
62  value = 0;
63  factor = _factor;
64  offset = _offset;
65  op = ESO_UNDEFINED;
66  }
67  else
68  {
70  value = _offset;
71  factor = 1;
72  offset = 0;
73  op = ESO_UNDEFINED;
74  }
75  }
76 
77  explicit ExportIndexNode( const int _value )
78  : ExportDataInternal("defaultIndexName", INT, ACADO_LOCAL, ""),
79  varType( EVT_VALUE ), value( _value ), factor( 1 ), offset( 0 ), op( ESO_UNDEFINED )
80  {}
81 
83  const ExportIndex& _arg1,
84  const ExportIndex& _arg2
85  )
86  : ExportDataInternal("defaultIndexName", INT, ACADO_LOCAL, ""),
87  varType( EVT_BINARY_OPERATOR ), value( 0 ), factor( 1 ), offset( 0 ),
88  op( _op ), left( _arg1 ), right( _arg2 )
89  {}
90 
91  virtual ~ExportIndexNode()
92  {}
93 
94  virtual ExportIndexNode* clone() const
95  {
96  return new ExportIndexNode( *this );
97  }
98 
99  virtual returnValue exportDataDeclaration( std::ostream& stream,
100  const std::string& _realString = "real_t",
101  const std::string& _intString = "int",
102  int _precision = 16
103  ) const;
104 
106  const std::string get( ) const;
107 
108 
113  const int getGivenValue( ) const;
114 
115 
121  virtual bool isGiven( ) const;
122 
123  bool isBinary() const
124  {
126  return true;
127 
128  return false;
129  }
130 
131  bool isVariable() const
132  {
133  if (varType == EVT_VARIABLE)
134  return true;
135 
136  return false;
137  }
138 
139  const int getFactor( ) const
140  {
141  return factor;
142  }
143 
144  const int getOffset( ) const
145  {
146  return offset;
147  }
148 
149 private:
151  int value;
152  int factor;
153  int offset;
154 
155  int op;
158 };
159 
161 
162 #endif // ACADO_TOOLKIT_EXPORT_INDEX_NODE_HPP
163 
virtual ExportIndexNode * clone() const
Make a deep copy of the instance.
virtual bool isGiven() const
ExportIndexNode(ExportStatementOperator _op, const ExportIndex &_arg1, const ExportIndex &_arg2)
Allows to pass back messages to the calling function.
#define CLOSE_NAMESPACE_ACADO
Defines a scalar-valued index variable to be used for exporting code.
ExportIndexNode(const std::string &_name, const std::string &_prefix, const int _factor=1, const int _offset=0)
virtual ~ExportIndexNode()
bool isBinary() const
ExportStatementOperator
const int getOffset() const
const int getFactor() const
ExportIndexNode(const int _value)
ExportVariableType
#define BEGIN_NAMESPACE_ACADO
ExportVariableType varType
const int getGivenValue() const
virtual returnValue exportDataDeclaration(std::ostream &stream, const std::string &_realString="real_t", const std::string &_intString="int", int _precision=16) const
bool isVariable() const


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:34