Ipopt
3.11.8
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Common
IpJournalist.hpp
Go to the documentation of this file.
1
// Copyright (C) 2004, 2009 International Business Machines and others.
2
// All Rights Reserved.
3
// This code is published under the Eclipse Public License.
4
//
5
// $Id: IpJournalist.hpp 2204 2013-04-13 13:49:26Z stefan $
6
//
7
// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8
9
#ifndef __IPJOURNALIST_HPP__
10
#define __IPJOURNALIST_HPP__
11
12
#include "
IpoptConfig.h
"
13
#include "
IpTypes.hpp
"
14
#include "
IpReferenced.hpp
"
15
#include "
IpSmartPtr.hpp
"
16
17
#ifdef HAVE_CSTDARG
18
# include <cstdarg>
19
#else
20
# ifdef HAVE_STDARG_H
21
# include <stdarg.h>
22
# else
23
# include <cstdarg>
// if this header is included by someone who does not define HAVE_CSTDARG or HAVE_STDARG, let's hope that cstdarg is available
24
# endif
25
#endif
26
27
#ifdef HAVE_CSTDIO
28
# include <cstdio>
29
#else
30
# ifdef HAVE_STDIO_H
31
# include <stdio.h>
32
# else
33
# include <cstdio>
// if this header is included by someone who does not define HAVE_CSTDIO or HAVE_STDIO, let's hope that cstdio is available
34
# endif
35
#endif
36
37
#include <string>
38
#include <vector>
39
#include <ostream>
40
41
namespace
Ipopt
42
{
43
44
// forward declarations
45
class
Journal;
46
class
FileJournal;
47
51
enum
EJournalLevel
{
52
J_INSUPPRESSIBLE
=-1,
53
J_NONE
=0,
54
J_ERROR
,
55
J_STRONGWARNING
,
56
J_SUMMARY
,
57
J_WARNING
,
58
J_ITERSUMMARY
,
59
J_DETAILED
,
60
J_MOREDETAILED
,
61
J_VECTOR
,
62
J_MOREVECTOR
,
63
J_MATRIX
,
64
J_MOREMATRIX
,
65
J_ALL
,
66
J_LAST_LEVEL
67
};
68
70
enum
EJournalCategory
{
71
J_DBG
=0,
72
J_STATISTICS
,
73
J_MAIN
,
74
J_INITIALIZATION
,
75
J_BARRIER_UPDATE
,
76
J_SOLVE_PD_SYSTEM
,
77
J_FRAC_TO_BOUND
,
78
J_LINEAR_ALGEBRA
,
79
J_LINE_SEARCH
,
80
J_HESSIAN_APPROXIMATION
,
81
J_SOLUTION
,
82
J_DOCUMENTATION
,
83
J_NLP
,
84
J_TIMING_STATISTICS
,
85
J_USER_APPLICATION
,
86
J_USER1
,
87
J_USER2
,
88
J_USER3
,
89
J_USER4
,
90
J_USER5
,
91
J_USER6
,
92
J_USER7
,
93
J_USER8
,
94
J_USER9
,
95
J_USER10
,
96
J_USER11
,
97
J_USER12
,
98
J_USER13
,
99
J_USER14
,
100
J_USER15
,
101
J_USER16
,
102
J_USER17
,
103
J_LAST_CATEGORY
104
};
106
134
class
Journalist
:
public
ReferencedObject
135
{
136
public
:
140
Journalist
();
141
143
virtual
~Journalist
();
145
152
virtual
void
Printf
(
EJournalLevel
level,
EJournalCategory
category,
153
const
char
* format, ...)
const
;
154
162
virtual
void
PrintStringOverLines
(
EJournalLevel
level,
EJournalCategory
category,
163
Index
indent_spaces,
Index
max_length,
164
const
std::string& line)
const
;
165
167
virtual
void
PrintfIndented
(
EJournalLevel
level,
168
EJournalCategory
category,
169
Index
indent_level,
170
const
char
* format, ...)
const
;
171
174
virtual
void
VPrintf
(
EJournalLevel
level,
175
EJournalCategory
category,
176
const
char
* pformat,
177
va_list ap)
const
;
178
181
virtual
void
VPrintfIndented
(
EJournalLevel
level,
182
EJournalCategory
category,
183
Index
indent_level,
184
const
char
* pformat,
185
va_list ap)
const
;
186
193
virtual
bool
ProduceOutput
(
EJournalLevel
level,
194
EJournalCategory
category)
const
;
195
196
201
virtual
void
FlushBuffer
()
const
;
203
222
virtual
bool
AddJournal
(
const
SmartPtr<Journal>
jrnl);
223
231
virtual
SmartPtr<Journal>
AddFileJournal
(
232
const
std::string& location_name,
233
const
std::string& fname,
234
EJournalLevel
default_level =
J_WARNING
235
);
236
240
virtual
SmartPtr<Journal>
GetJournal
(
const
std::string& location_name);
241
243
virtual
void
DeleteAllJournals
();
245
246
private
:
256
Journalist
(
const
Journalist
&);
257
259
void
operator=
(
const
Journalist
&);
261
262
//** Private Data Members. */
264
std::vector< SmartPtr<Journal> >
journals_
;
266
};
267
273
class
Journal
:
public
ReferencedObject
274
{
275
public
:
277
Journal
(
const
std::string& name,
EJournalLevel
default_level);
278
280
virtual
~Journal
();
281
283
virtual
std::string
Name
();
284
286
virtual
void
SetPrintLevel
(
287
EJournalCategory
category,
EJournalLevel
level
288
);
289
291
virtual
void
SetAllPrintLevels
(
292
EJournalLevel
level
293
);
294
306
virtual
bool
IsAccepted
(
307
EJournalCategory
category,
EJournalLevel
level
308
)
const
;
309
311
virtual
void
Print
(
EJournalCategory
category,
EJournalLevel
level,
312
const
char
* str)
313
{
314
PrintImpl
(category, level, str);
315
}
316
318
virtual
void
Printf
(
EJournalCategory
category,
EJournalLevel
level,
319
const
char
* pformat, va_list ap)
320
{
321
PrintfImpl
(category, level, pformat, ap);
322
}
323
325
virtual
void
FlushBuffer
()
326
{
327
FlushBufferImpl
();
328
}
330
331
protected
:
337
virtual
void
PrintImpl
(
EJournalCategory
category,
EJournalLevel
level,
338
const
char
* str)=0;
339
341
virtual
void
PrintfImpl
(
EJournalCategory
category,
EJournalLevel
level,
342
const
char
* pformat, va_list ap)=0;
343
345
virtual
void
FlushBufferImpl
()=0;
347
348
private
:
358
Journal
();
359
361
Journal
(
const
Journal
&);
362
364
void
operator=
(
const
Journal
&);
366
368
std::string
name_
;
369
371
Index
print_levels_
[
J_LAST_CATEGORY
];
372
};
373
374
379
class
FileJournal
:
public
Journal
380
{
381
public
:
383
FileJournal
(
const
std::string& name,
EJournalLevel
default_level);
384
386
virtual
~FileJournal
();
387
395
virtual
bool
Open
(
const
char
* fname);
396
397
protected
:
403
virtual
void
PrintImpl
(
EJournalCategory
category,
EJournalLevel
level,
404
const
char
* str);
405
407
virtual
void
PrintfImpl
(
EJournalCategory
category,
EJournalLevel
level,
408
const
char
* pformat, va_list ap);
409
411
virtual
void
FlushBufferImpl
();
413
414
private
:
424
FileJournal
();
425
427
FileJournal
(
const
FileJournal
&);
428
430
void
operator=
(
const
FileJournal
&);
432
434
FILE*
file_
;
435
};
436
440
class
StreamJournal
:
public
Journal
441
{
442
public
:
444
StreamJournal
(
const
std::string& name,
EJournalLevel
default_level);
445
447
virtual
~StreamJournal
()
448
{}
449
451
void
SetOutputStream
(std::ostream* os);
452
453
protected
:
459
virtual
void
PrintImpl
(
EJournalCategory
category,
EJournalLevel
level,
460
const
char
* str);
461
463
virtual
void
PrintfImpl
(
EJournalCategory
category,
EJournalLevel
level,
464
const
char
* pformat, va_list ap);
465
467
virtual
void
FlushBufferImpl
();
469
470
private
:
480
StreamJournal
();
481
483
StreamJournal
(
const
StreamJournal
&);
484
486
void
operator=
(
const
StreamJournal
&);
488
490
std::ostream*
os_
;
491
493
char
buffer_
[32768];
494
};
495
}
496
497
#endif
Generated by
1.8.3.1