Ipopt Documentation  
 
Loading...
Searching...
No Matches
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// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
6
7#ifndef __IPJOURNALIST_HPP__
8#define __IPJOURNALIST_HPP__
9
10#include "IpoptConfig.h"
11#include "IpTypes.hpp"
12#include "IpReferenced.hpp"
13#include "IpSmartPtr.hpp"
14
15#include <cstdarg>
16#include <cstdio>
17#include <string>
18#include <vector>
19#include <ostream>
20
21namespace Ipopt
22{
23
24// forward declarations
25class Journal;
26class FileJournal;
27
30
49
87
88
117{
118public:
121
123
125 virtual ~Journalist();
127
133
134#ifdef __GNUC__
135 __attribute__((format(printf, 4, 5)))
136#endif
137 virtual void Printf(
138 EJournalLevel level,
139 EJournalCategory category,
140 const char* format,
141 ...
142 ) const;
143
154 EJournalLevel level,
155 EJournalCategory category,
156 Index indent_spaces,
157 Index max_length,
158 const std::string& line
159 ) const;
160
162#ifdef __GNUC__
163 __attribute__((format(printf, 5, 6)))
164#endif
165 virtual void PrintfIndented(
166 EJournalLevel level,
167 EJournalCategory category,
168 Index indent_level,
169 const char* format,
170 ...
171 ) const;
172
174 virtual void VPrintf(
175 EJournalLevel level,
176 EJournalCategory category,
177 const char* pformat,
178 va_list ap
179 ) const;
180
182 virtual void VPrintfIndented(
183 EJournalLevel level,
184 EJournalCategory category,
185 Index indent_level,
186 const char* pformat,
187 va_list ap
188 ) const;
189
197 virtual bool ProduceOutput(
198 EJournalLevel level,
199 EJournalCategory category
200 ) const;
201
208 virtual void FlushBuffer() const;
210
222
223 virtual bool AddJournal(
224 const SmartPtr<Journal> jrnl
225 );
226
232 const std::string& location_name,
233 const std::string& fname,
234 EJournalLevel default_level = J_WARNING,
235 bool file_append = false
236 );
237
243 const std::string& location_name
244 );
245
247 virtual void DeleteAllJournals();
249
250private:
261
263 const Journalist&
264 );
265
268 const Journalist&
269 );
271
272 //** Private Data Members. */
274 std::vector<SmartPtr<Journal> > journals_;
276};
277
284{
285public:
288 const std::string& name,
289 EJournalLevel default_level
290 );
291
293 virtual ~Journal();
294
296 virtual std::string Name();
297
299 virtual void SetPrintLevel(
300 EJournalCategory category,
301 EJournalLevel level
302 );
303
305 virtual void SetAllPrintLevels(
306 EJournalLevel level
307 );
308
319
320 virtual bool IsAccepted(
321 EJournalCategory category,
322 EJournalLevel level
323 ) const;
324
326 virtual void Print(
327 EJournalCategory category,
328 EJournalLevel level,
329 const char* str
330 )
331 {
332 PrintImpl(category, level, str);
333 }
334
336 virtual void Printf(
337 EJournalCategory category,
338 EJournalLevel level,
339 const char* pformat,
340 va_list ap
341 )
342 {
343 PrintfImpl(category, level, pformat, ap);
344 }
345
347 virtual void FlushBuffer()
348 {
350 }
351
352
353protected:
359
360 virtual void PrintImpl(
361 EJournalCategory category,
362 EJournalLevel level,
363 const char* str
364 ) = 0;
365
367 virtual void PrintfImpl(
368 EJournalCategory category,
369 EJournalLevel level,
370 const char* pformat,
371 va_list ap
372 ) = 0;
373
375 virtual void FlushBufferImpl() = 0;
377
378private:
389
391
394 const Journal&
395 );
396
399 const Journal&
400 );
402
404 std::string name_;
405
408};
409
417{
418public:
421 const std::string& name,
422 EJournalLevel default_level
423 );
424
426 virtual ~FileJournal();
427
435 virtual bool Open(
436 const char* fname,
437 bool fappend = false
438 );
439
440protected:
446
447 virtual void PrintImpl(
448 EJournalCategory /*category*/,
449 EJournalLevel /*level*/,
450 const char* str
451 );
452
454 virtual void PrintfImpl(
455 EJournalCategory /*category*/,
456 EJournalLevel /*level*/,
457 const char* pformat,
458 va_list ap
459 );
460
462 virtual void FlushBufferImpl();
464
465private:
476
478
481 const FileJournal&
482 );
483
486 const FileJournal&
487 );
489
491 FILE* file_;
492};
493
499{
500public:
503 const std::string& name,
504 EJournalLevel default_level
505 );
506
509 { }
510
513 std::ostream* os
514 );
515
516protected:
522
523 virtual void PrintImpl(
524 EJournalCategory /*category*/,
525 EJournalLevel /*level*/,
526 const char* str
527 );
528
530 virtual void PrintfImpl(
531 EJournalCategory /*category*/,
532 EJournalLevel /*level*/,
533 const char* pformat,
534 va_list ap
535 );
536
538 virtual void FlushBufferImpl();
540
541private:
552
554
557 const StreamJournal&
558 );
559
562 const StreamJournal&
563 );
565
567 std::ostream* os_;
568
570 char buffer_[32768];
571};
572
573} // namespace
574
575#endif
FileJournal class.
virtual bool Open(const char *fname, bool fappend=false)
Open a new file for the output location.
FileJournal()
Default Constructor.
virtual ~FileJournal()
Destructor.
virtual void FlushBufferImpl()
Flush output buffer.
FILE * file_
FILE pointer for the output destination.
FileJournal(const std::string &name, EJournalLevel default_level)
Constructor.
virtual void PrintImpl(EJournalCategory, EJournalLevel, const char *str)
Print to the designated output location.
FileJournal(const FileJournal &)
Copy Constructor.
void operator=(const FileJournal &)
Default Assignment Operator.
virtual void PrintfImpl(EJournalCategory, EJournalLevel, const char *pformat, va_list ap)
Printf to the designated output location.
Journal class (part of the Journalist implementation.).
virtual void Printf(EJournalCategory category, EJournalLevel level, const char *pformat, va_list ap)
Printf to the designated output location.
void operator=(const Journal &)
Default Assignment Operator.
virtual void SetPrintLevel(EJournalCategory category, EJournalLevel level)
Set the print level for a particular category.
Journal()
Default Constructor.
virtual void Print(EJournalCategory category, EJournalLevel level, const char *str)
Print to the designated output location.
virtual std::string Name()
Get the name of the Journal.
virtual void PrintImpl(EJournalCategory category, EJournalLevel level, const char *str)=0
Print to the designated output location.
virtual bool IsAccepted(EJournalCategory category, EJournalLevel level) const
Ask if a particular print level/category is accepted by the journal.
Journal(const Journal &)
Copy Constructor.
std::string name_
Name of the output location.
Journal(const std::string &name, EJournalLevel default_level)
Constructor.
virtual void FlushBufferImpl()=0
Flush output buffer.
Index print_levels_[J_LAST_CATEGORY]
vector of integers indicating the level for each category
virtual ~Journal()
Destructor.
virtual void SetAllPrintLevels(EJournalLevel level)
Set the print level for all category.
virtual void PrintfImpl(EJournalCategory category, EJournalLevel level, const char *pformat, va_list ap)=0
Printf to the designated output location.
virtual void FlushBuffer()
Flush output buffer.
virtual SmartPtr< Journal > AddFileJournal(const std::string &location_name, const std::string &fname, EJournalLevel default_level=J_WARNING, bool file_append=false)
Add a new FileJournal.
virtual void VPrintf(EJournalLevel level, EJournalCategory category, const char *pformat, va_list ap) const
Method to print a formatted string using the va_list argument.
Journalist(const Journalist &)
Copy Constructor.
virtual bool AddJournal(const SmartPtr< Journal > jrnl)
Add a new journal.
virtual SmartPtr< Journal > GetJournal(const std::string &location_name)
Get an existing journal.
virtual void FlushBuffer() const
Method that flushes the current buffer for all Journalists.
void operator=(const Journalist &)
Default Assignment Operator.
virtual void VPrintfIndented(EJournalLevel level, EJournalCategory category, Index indent_level, const char *pformat, va_list ap) const
Method to print a formatted string with indentation, using the va_list argument.
virtual void DeleteAllJournals()
Delete all journals currently known by the journalist.
virtual void PrintfIndented(EJournalLevel level, EJournalCategory category, Index indent_level, const char *format,...) const
Method to print a formatted string with indentation.
std::vector< SmartPtr< Journal > > journals_
virtual void PrintStringOverLines(EJournalLevel level, EJournalCategory category, Index indent_spaces, Index max_length, const std::string &line) const
Method to print a long string including indentation.
virtual void Printf(EJournalLevel level, EJournalCategory category, const char *format,...) const
Method to print a formatted string.
virtual ~Journalist()
Destructor...
virtual bool ProduceOutput(EJournalLevel level, EJournalCategory category) const
Method that returns true if there is a Journal that would write output for the given JournalLevel and...
Journalist()
Constructor.
Template class for Smart Pointers.
virtual void PrintImpl(EJournalCategory, EJournalLevel, const char *str)
Print to the designated output location.
virtual void FlushBufferImpl()
Flush output buffer.
virtual void PrintfImpl(EJournalCategory, EJournalLevel, const char *pformat, va_list ap)
Printf to the designated output location.
virtual ~StreamJournal()
Destructor.
char buffer_[32768]
buffer for sprintf.
StreamJournal(const std::string &name, EJournalLevel default_level)
Constructor.
StreamJournal(const StreamJournal &)
Copy Constructor.
StreamJournal()
Default Constructor.
void SetOutputStream(std::ostream *os)
Setting the output stream pointer.
void operator=(const StreamJournal &)
Default Assignment Operator.
std::ostream * os_
pointer to output stream for the output destination
#define IPOPTLIB_EXPORT
Definition config.h:94
This file contains a base class for all exceptions and a set of macros to help with exceptions.
ipindex Index
Type of all indices of vectors, matrices etc.
Definition IpTypes.hpp:20
EJournalCategory
Category Selection Enum.
@ J_USER16
This can be used by the user's application.
@ J_USER4
This can be used by the user's application.
@ J_USER7
This can be used by the user's application.
@ J_USER13
This can be used by the user's application.
@ J_INITIALIZATION
@ J_USER14
This can be used by the user's application.
@ J_LINEAR_ALGEBRA
@ J_USER_APPLICATION
This can be used by the user's application.
@ J_TIMING_STATISTICS
@ J_USER9
This can be used by the user's application.
@ J_LINE_SEARCH
@ J_USER11
This can be used by the user's application.
@ J_DOCUMENTATION
@ J_USER2
This can be used by the user's application.
@ J_USER1
This can be used by the user's application.
@ J_FRAC_TO_BOUND
@ J_USER17
This can be used by the user's application.
@ J_USER15
This can be used by the user's application.
@ J_BARRIER_UPDATE
@ J_LAST_CATEGORY
@ J_USER3
This can be used by the user's application.
@ J_USER12
This can be used by the user's application.
@ J_SOLVE_PD_SYSTEM
@ J_USER8
This can be used by the user's application.
@ J_USER10
This can be used by the user's application.
@ J_USER6
This can be used by the user's application.
@ J_USER5
This can be used by the user's application.
@ J_HESSIAN_APPROXIMATION
EJournalLevel
Print Level Enum.
@ J_ITERSUMMARY
@ J_STRONGWARNING
@ J_MOREDETAILED
@ J_INSUPPRESSIBLE