export_index_node.hpp
Go to the documentation of this file.
00001 /*
00002  *    This file is part of ACADO Toolkit.
00003  *
00004  *    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
00005  *    Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
00006  *    Milan Vukov, Rien Quirynen, KU Leuven.
00007  *    Developed within the Optimization in Engineering Center (OPTEC)
00008  *    under supervision of Moritz Diehl. All rights reserved.
00009  *
00010  *    ACADO Toolkit is free software; you can redistribute it and/or
00011  *    modify it under the terms of the GNU Lesser General Public
00012  *    License as published by the Free Software Foundation; either
00013  *    version 3 of the License, or (at your option) any later version.
00014  *
00015  *    ACADO Toolkit is distributed in the hope that it will be useful,
00016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  *    Lesser General Public License for more details.
00019  *
00020  *    You should have received a copy of the GNU Lesser General Public
00021  *    License along with ACADO Toolkit; if not, write to the Free Software
00022  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023  *
00024  */
00025 
00026 
00033 #ifndef ACADO_TOOLKIT_EXPORT_INDEX_NODE_HPP
00034 #define ACADO_TOOLKIT_EXPORT_INDEX_NODE_HPP
00035 
00036 #include <acado/utils/acado_utils.hpp>
00037 #include <acado/code_generation/export_data_internal.hpp>
00038 #include <acado/code_generation/export_index.hpp>
00039 #include <acado/code_generation/export_index_node.hpp>
00040 
00041 BEGIN_NAMESPACE_ACADO
00042 
00043 enum ExportVariableType
00044 {
00045         EVT_VARIABLE,
00046         EVT_VALUE,
00047         EVT_BINARY_OPERATOR
00048 };
00049 
00050 class ExportIndexNode : public ExportDataInternal
00051 {
00052 public:
00053         ExportIndexNode(        const std::string& _name,
00054                                                 const std::string& _prefix,
00055                                                 const int _factor = 1,
00056                                                 const int _offset = 0)
00057         :       ExportDataInternal(_name, INT, ACADO_LOCAL, _prefix)
00058         {
00059                 if ( _factor )
00060                 {
00061                         varType = EVT_VARIABLE;
00062                         value = 0;
00063                         factor = _factor;
00064                         offset = _offset;
00065                         op = ESO_UNDEFINED;
00066                 }
00067                 else
00068                 {
00069                         varType = EVT_VALUE;
00070                         value = _offset;
00071                         factor = 1;
00072                         offset = 0;
00073                         op = ESO_UNDEFINED;
00074                 }
00075         }
00076 
00077         explicit ExportIndexNode(       const int _value )
00078         :       ExportDataInternal("defaultIndexName", INT, ACADO_LOCAL, ""),
00079                 varType( EVT_VALUE ), value( _value ), factor( 1 ), offset( 0 ), op( ESO_UNDEFINED )
00080         {}
00081 
00082         ExportIndexNode(        ExportStatementOperator _op,
00083                                                 const ExportIndex& _arg1,
00084                                                 const ExportIndex& _arg2
00085                                                 )
00086         :       ExportDataInternal("defaultIndexName", INT, ACADO_LOCAL, ""),
00087                 varType( EVT_BINARY_OPERATOR ), value( 0 ), factor( 1 ), offset( 0 ),
00088                 op( _op ), left( _arg1 ), right( _arg2 )
00089         {}
00090 
00091         virtual ~ExportIndexNode()
00092         {}
00093 
00094         virtual ExportIndexNode* clone() const
00095         {
00096                 return new ExportIndexNode( *this );
00097         }
00098 
00099         virtual returnValue exportDataDeclaration(      std::ostream& stream,
00100                                                                                                 const std::string& _realString = "real_t",
00101                                                                                                 const std::string& _intString = "int",
00102                                                                                                 int _precision = 16
00103                                                                                                 ) const;
00104 
00106         const std::string get( ) const;
00107 
00108 
00113         const int getGivenValue( ) const;
00114 
00115 
00121         virtual bool isGiven( ) const;
00122 
00123         bool isBinary() const
00124         {
00125                 if (varType == EVT_BINARY_OPERATOR)
00126                         return true;
00127 
00128                 return false;
00129         }
00130 
00131         bool isVariable() const
00132         {
00133                 if (varType == EVT_VARIABLE)
00134                         return true;
00135 
00136                 return false;
00137         }
00138 
00139         const int getFactor( ) const
00140         {
00141                 return factor;
00142         }
00143 
00144         const int getOffset( ) const
00145         {
00146                 return offset;
00147         }
00148 
00149 private:
00150         ExportVariableType varType;
00151         int value;
00152         int factor;
00153         int offset;
00154 
00155         int op;
00156         ExportIndex left;
00157         ExportIndex right;
00158 };
00159 
00160 CLOSE_NAMESPACE_ACADO
00161 
00162 #endif // ACADO_TOOLKIT_EXPORT_INDEX_NODE_HPP
00163 


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:58:09