logging.cpp
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 
34 
35 using namespace std;
36 
38 
39 //
40 // PUBLIC MEMBER FUNCTIONS:
41 //
42 
43 
45 {
46  logIdx = -1;
47 }
48 
50 {}
51 
53  )
54 {
55  return addLogRecord( _record );
56 }
57 
59  )
60 {
61  unsigned newIndex;
62  if (_record.aliasIdx >= 0)
63  {
64  logCollection[ _record.aliasIdx ] = _record;
65  newIndex = _record.aliasIdx;
66  }
67  else
68  {
69  logCollection.push_back( _record );
70  newIndex = logCollection.size() - 1;
71  logCollection.back().aliasIdx = _record.aliasIdx = newIndex;
72  }
73 
74  return newIndex;
75 }
76 
78  ) const
79 {
80  if (_record.aliasIdx < 0 || _record.aliasIdx >= ((int)getNumLogRecords( ) - 1))
82 
83  _record = logCollection[ _record.aliasIdx ];
84 
85  return SUCCESSFUL_RETURN;
86 }
87 
88 
90  ) const
91 {
92  for (unsigned ind = 0; ind < logCollection.size(); ++ind)
93  {
94  if (logCollection[ ind ].getLogFrequency() != _record.getLogFrequency())
95  continue;
96 
97  logCollection[ ind ].updateLogRecord( _record );
98  }
99 
100  return SUCCESSFUL_RETURN;
101 }
102 
104 {
105  return logCollection.size();
106 }
107 
109 {
110  cout << "LogCollection having the following records: \n";
111  for (uint i = 0; i < logCollection.size(); ++i)
112  logCollection[ i ].printInfo();
113 
114  return SUCCESSFUL_RETURN;
115 }
116 
118 {
119  unsigned nDoubles = 0;
120 
121  for (unsigned i = 0; i < logCollection.size(); ++i)
122  nDoubles += logCollection[ i ].getNumDoubles();
123 
124  return nDoubles;
125 
126  cout << "LogCollection contains " << nDoubles << "doubles.\n";
127  return SUCCESSFUL_RETURN;
128 }
129 
130 //
131 // PROTECTED MEMBER FUNCTIONS:
132 //
133 
135 {
136  return SUCCESSFUL_RETURN;
137 }
138 
140 
141 /*
142  * end of file
143  */
LogFrequency getLogFrequency() const
returnValue printLoggingInfo() const
Definition: logging.cpp:108
int addLogRecord(LogRecord &record)
Definition: logging.cpp:58
Allows to pass back messages to the calling function.
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Definition: acado_types.hpp:42
int operator<<(LogRecord &record)
Definition: logging.cpp:52
#define CLOSE_NAMESPACE_ACADO
virtual ~Logging()
Definition: logging.cpp:49
Logging()
Definition: logging.cpp:44
returnValue updateLogRecord(LogRecord &_record) const
Definition: logging.cpp:89
virtual returnValue setupLogging()
Definition: logging.cpp:134
uint getNumLogRecords() const
Definition: logging.cpp:103
returnValue getLogRecord(LogRecord &_record) const
Definition: logging.cpp:77
returnValue printNumDoubles() const
Definition: logging.cpp:117
Allows to setup and store user-specified log records of algorithmic information.
Definition: log_record.hpp:72
#define BEGIN_NAMESPACE_ACADO
#define ACADOERROR(retval)


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