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
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(
140 const char* format,
141 ...
142 ) const;
143
158 const std::string& line
159 ) const;
160
162#ifdef __GNUC__
163 __attribute__((format(printf, 5, 6)))
164#endif
165 virtual void PrintfIndented(
169 const char* format,
170 ...
171 ) const;
172
174 virtual void VPrintf(
177 const char* pformat,
178 va_list ap
179 ) const;
180
182 virtual void VPrintfIndented(
186 const char* pformat,
187 va_list ap
188 ) const;
189
197 virtual bool ProduceOutput(
200 ) const;
201
208 virtual void FlushBuffer() const;
210
222
223 virtual bool AddJournal(
225 );
226
232 const std::string& location_name,
233 const std::string& fname,
234 EJournalLevel default_level = J_WARNING
235 );
236
242 const std::string& location_name
243 );
244
246 virtual void DeleteAllJournals();
248
249private:
260
262 const Journalist&
263 );
264
267 const Journalist&
268 );
270
271 //** Private Data Members. */
273 std::vector<SmartPtr<Journal> > journals_;
275};
276
283{
284public:
287 const std::string& name,
289 );
290
292 virtual ~Journal();
293
295 virtual std::string Name();
296
298 virtual void SetPrintLevel(
301 );
302
304 virtual void SetAllPrintLevels(
306 );
307
318
319 virtual bool IsAccepted(
322 ) const;
323
325 virtual void Print(
328 const char* str
329 )
330 {
331 PrintImpl(category, level, str);
332 }
333
335 virtual void Printf(
338 const char* pformat,
339 va_list ap
340 )
341 {
342 PrintfImpl(category, level, pformat, ap);
343 }
344
346 virtual void FlushBuffer()
347 {
348 FlushBufferImpl();
349 }
351
352protected:
358
359 virtual void PrintImpl(
362 const char* str
363 ) = 0;
364
366 virtual void PrintfImpl(
369 const char* pformat,
370 va_list ap
371 ) = 0;
372
374 virtual void FlushBufferImpl() = 0;
376
377private:
388
390
393 const Journal&
394 );
395
398 const Journal&
399 );
401
403 std::string name_;
404
406 Index print_levels_[J_LAST_CATEGORY];
407};
408
416{
417public:
420 const std::string& name,
422 );
423
425 virtual ~FileJournal();
426
434 virtual bool Open(
435 const char* fname
436 );
437
438protected:
444
445 virtual void PrintImpl(
446 EJournalCategory /*category*/,
447 EJournalLevel /*level*/,
448 const char* str
449 );
450
452 virtual void PrintfImpl(
453 EJournalCategory /*category*/,
454 EJournalLevel /*level*/,
455 const char* pformat,
456 va_list ap
457 );
458
460 virtual void FlushBufferImpl();
462
463private:
474
476
479 const FileJournal&
480 );
481
484 const FileJournal&
485 );
487
490};
491
497{
498public:
501 const std::string& name,
503 );
504
507 { }
508
511 std::ostream* os
512 );
513
514protected:
520
521 virtual void PrintImpl(
522 EJournalCategory /*category*/,
523 EJournalLevel /*level*/,
524 const char* str
525 );
526
528 virtual void PrintfImpl(
529 EJournalCategory /*category*/,
530 EJournalLevel /*level*/,
531 const char* pformat,
532 va_list ap
533 );
534
536 virtual void FlushBufferImpl();
538
539private:
550
552
555 const StreamJournal&
556 );
557
560 const StreamJournal&
561 );
563
565 std::ostream* os_;
566
568 char buffer_[32768];
569};
570
571} // namespace
572
573#endif
Templated class which stores one entry for the CachedResult class.
FileJournal class.
FileJournal()
Default Constructor.
virtual ~FileJournal()
Destructor.
virtual void FlushBufferImpl()
Flush output buffer.
FILE * file_
FILE pointer for the output destination.
virtual bool Open(const char *fname)
Open a new file for the output location.
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.
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.
Class responsible for all message output.
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 SmartPtr< Journal > AddFileJournal(const std::string &location_name, const std::string &fname, EJournalLevel default_level=J_WARNING)
Add a new FileJournal.
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.
Storing the reference count of all the smart pointers that currently reference it.
StreamJournal class.
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.
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