log_record.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 
00032 #ifndef ACADO_TOOLKIT_LOG_RECORD_HPP
00033 #define ACADO_TOOLKIT_LOG_RECORD_HPP
00034 
00035 #include <acado/utils/acado_utils.hpp>
00036 #include <acado/matrix_vector/matrix_vector.hpp>
00037 #include <acado/symbolic_expression/symbolic_expression.hpp>
00038 #include <acado/variables_grid/variables_grid.hpp>
00039 
00040 #include <map>
00041 #include <iterator>
00042 
00043 BEGIN_NAMESPACE_ACADO
00044 
00045 class Logging;
00046 
00072 class LogRecord
00073 {
00074         friend class Logging;
00075 
00076         //
00077         // PUBLIC MEMBER FUNCTIONS:
00078         //
00079         public:
00080 
00087                 LogRecord(      LogFrequency _frequency = LOG_AT_EACH_ITERATION,
00088                                         PrintScheme _printScheme = PS_DEFAULT
00089                                         );
00090 
00092                 ~LogRecord( );
00093 
00103                 returnValue operator<<( LogName _name
00104                                                                 );
00105 
00115                 returnValue operator<<( const Expression& _name
00116                                                                 );
00117 
00127                 returnValue addItem(    LogName _name,
00128                                                                 const char* const _label = DEFAULT_LABEL
00129                                                                 );
00130 
00140                 returnValue addItem(    const Expression& _name,
00141                                                                 const char* const _label = DEFAULT_LABEL
00142                                                                 );
00143 
00155                 inline returnValue getAll(      LogName _name,
00156                                                                         MatrixVariablesGrid& values
00157                                                                         ) const;
00158 
00170                 inline returnValue getAll(      const Expression& _name,
00171                                                                         MatrixVariablesGrid& values
00172                                                                         ) const;
00173 
00174 
00186                 inline returnValue getFirst(    LogName _name,
00187                                                                                 DMatrix& firstValue
00188                                                                                 ) const;
00189 
00201                 inline returnValue getFirst(    const Expression& _name,
00202                                                                                 DMatrix& firstValue
00203                                                                                 ) const;
00204 
00216                 inline returnValue getFirst(    LogName _name,
00217                                                                                 VariablesGrid& firstValue
00218                                                                                 ) const;
00219 
00231                 inline returnValue getFirst(    const Expression& _name,
00232                                                                                 VariablesGrid& firstValue
00233                                                                                 ) const;
00234 
00235 
00247                 inline returnValue getLast(     LogName _name,
00248                                                                         DMatrix& lastValue
00249                                                                         ) const;
00250 
00262                 inline returnValue getLast(     const Expression& _name,
00263                                                                         DMatrix& lastValue
00264                                                                         ) const;
00265 
00277                 inline returnValue getLast(     LogName _name,
00278                                                                         VariablesGrid& lastValue
00279                                                                         ) const;
00280 
00292                 inline returnValue getLast(     const Expression& _name,
00293                                                                         VariablesGrid& lastValue
00294                                                                         ) const;
00295 
00296 
00308                 inline returnValue setAll(      LogName _name,
00309                                                                         const MatrixVariablesGrid& values
00310                                                                         );
00311 
00323                 inline returnValue setAll(      const Expression& _name,
00324                                                                         const MatrixVariablesGrid& values
00325                                                                         );
00326 
00327 
00340                 inline returnValue setLast(     LogName _name,
00341                                                                         const DMatrix& value,
00342                                                                         double time = -INFTY
00343                                                                         );
00344 
00357                 inline returnValue setLast(     const Expression& _name,
00358                                                                         const DMatrix& value,
00359                                                                         double time = -INFTY
00360                                                                         );
00361 
00374                 inline returnValue setLast(     LogName _name,
00375                                                                         VariablesGrid& value,
00376                                                                         double time = -INFTY
00377                                                                         );
00378 
00391                 inline returnValue setLast(     const Expression& _name,
00392                                                                         VariablesGrid& value,
00393                                                                         double time = -INFTY
00394                                                                         );
00395 
00406                 returnValue print(      std::ostream& _stream = std::cout,
00407                                                         LogPrintMode _mode = PRINT_ITEM_BY_ITEM
00408                                                         ) const;
00409 
00414                 returnValue printInfo( ) const;
00415 
00423                 uint getMaxNumMatrices( ) const;
00424 
00429                 inline uint getNumItems( ) const;
00430 
00436                 inline BooleanType isEmpty( ) const;
00437 
00443                 inline LogFrequency getLogFrequency( ) const;
00444 
00449                 inline PrintScheme getPrintScheme( ) const;
00450 
00458                 inline returnValue setLogFrequency(     LogFrequency _frequency
00459                                                                                                 );
00460 
00467                 inline returnValue setPrintScheme(      PrintScheme _printScheme
00468                                                                                         );
00469 
00478                 inline BooleanType hasItem(     LogName _name
00479                                                                         ) const;
00480 
00489                 inline BooleanType hasItem(     const Expression& _name
00490                                                                         ) const;
00491 
00499                 inline BooleanType hasNonEmptyItem(     LogName _name
00500                                                                                         ) const;
00501 
00509                 inline BooleanType hasNonEmptyItem(     const Expression& _name
00510                                                                                         ) const;
00511 
00512 
00513                 inline uint getNumDoubles( ) const;
00514 
00527                 returnValue getAll(     uint _name,
00528                                                         LogRecordItemType _type,
00529                                                         MatrixVariablesGrid& values
00530                                                         ) const;
00531 
00544                 returnValue getFirst(   uint _name,
00545                                                                 LogRecordItemType _type,
00546                                                                 DMatrix& firstValue
00547                                                                 ) const;
00548 
00561                 returnValue getLast(    uint _name,
00562                                                                 LogRecordItemType _type,
00563                                                                 DMatrix& lastValue
00564                                                                 ) const;
00565 
00578                 returnValue setAll(     uint _name,
00579                                                         LogRecordItemType _type,
00580                                                         const MatrixVariablesGrid& values
00581                                                         );
00582 
00596                 returnValue setLast(    uint _name,
00597                                                                 LogRecordItemType _type,
00598                                                                 const DMatrix& value,
00599                                                                 double time = -INFTY
00600                                                                 );
00601 
00602 
00612                 inline BooleanType hasItem(     uint _name,
00613                                                                         LogRecordItemType _type
00614                                                                         ) const;
00615 
00623                 inline returnValue enableWriteProtection(LogName _name);
00624 
00632                 inline returnValue enableWriteProtection(const Expression& _name);
00633 
00641                 inline returnValue disableWriteProtection(LogName _name);
00642 
00650                 inline returnValue disableWriteProtection(const Expression& _name);
00651 
00653                 returnValue updateLogRecord(    LogRecord& _record
00654                                                                                 ) const;
00655 
00656     //
00657     // DATA MEMBERS:
00658     //
00659         protected:
00661                 int aliasIdx;
00663                 LogFrequency frequency;
00665                 PrintScheme printScheme;
00666 
00668                 struct LogRecordData
00669                 {
00670                         LogRecordData()
00671                                 : label( DEFAULT_LABEL ), writeProtection( false )
00672                         {}
00673 
00674                         LogRecordData(  const std::string& _label
00675                                                         )
00676                                 : label( _label ), writeProtection( false )
00677                         {}
00678 
00679                         LogRecordData(  const MatrixVariablesGrid& _values,
00680                                                         const std::string& _label,
00681                                                         bool _writeProtection
00682                                                         )
00683                                 : values( _values ), label( _label ), writeProtection( _writeProtection )
00684                         {}
00685 
00686                         MatrixVariablesGrid values;
00687                         std::string label;
00688                         bool writeProtection;
00689                 };
00690 
00692                 typedef std::map<std::pair<int, LogRecordItemType>, LogRecordData> LogRecordItems;
00694                 LogRecordItems items;
00695 };
00696 
00697 CLOSE_NAMESPACE_ACADO
00698 
00699 #include <acado/user_interaction/log_record.ipp>
00700 
00701 #endif  // ACADO_TOOLKIT_LOG_RECORD_HPP
00702 
00703 /*
00704  *      end of file
00705  */


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Sat Jun 8 2019 19:37:53