OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Attributes | List of all members
ossimStdOutProgress Class Reference

#include <ossimStdOutProgress.h>

Inheritance diagram for ossimStdOutProgress:
ossimProcessListener ossimListener

Public Member Functions

 ossimStdOutProgress (ossim_uint32 precision=0, bool flushStream=false)
 
virtual void processProgressEvent (ossimProcessProgressEvent &event)
 
virtual void setFlushStreamFlag (bool flag)
 
- Public Member Functions inherited from ossimProcessListener
 ossimProcessListener ()
 
virtual ~ossimProcessListener ()
 
virtual void processEvent (ossimEvent &event)
 ProcessEvent. More...
 
- Public Member Functions inherited from ossimListener
 ossimListener ()
 
virtual ~ossimListener ()
 
void enableListener ()
 
void disableListener ()
 
void setListenerEnableFlag (bool flag)
 
bool isListenerEnabled () const
 
bool getListenerEnableFlag () const
 

Protected Attributes

ossim_uint32 thePrecision
 
bool theFlushStreamFlag
 
bool theRunningInConsoleFlag
 
- Protected Attributes inherited from ossimListener
bool theListenerEnableFlag
 

Detailed Description

Definition at line 19 of file ossimStdOutProgress.h.

Constructor & Destructor Documentation

◆ ossimStdOutProgress()

ossimStdOutProgress::ossimStdOutProgress ( ossim_uint32  precision = 0,
bool  flushStream = false 
)

Definition at line 29 of file ossimStdOutProgress.cpp.

References FILENO, ossimPreferences::findPreference(), ossimPreferences::instance(), ISATTY, ossimString::size(), theRunningInConsoleFlag, and ossimString::toBool().

31  :
33  thePrecision(precision),
34  theFlushStreamFlag(flushStream),
36 {
37  // Determine if running in a terminal window. Progress reports are only written to console if
38  // running in one.
39 
40  ossimString stdOutConsole;
41  stdOutConsole = ossimPreferences::instance()->findPreference("ossim.std.out.progress");
42 
43  if ( stdOutConsole.size() )
44  {
45  // Override auto detected console.
46  theRunningInConsoleFlag = stdOutConsole.toBool();
47  }
48  else if ( !ISATTY(FILENO(stdout) ) )
49  {
51  }
52 }
#define ISATTY
const char * findPreference(const char *key) const
std::string::size_type size() const
Definition: ossimString.h:405
bool toBool() const
String to numeric methods.
static ossimPreferences * instance()
#define FILENO

Member Function Documentation

◆ processProgressEvent()

void ossimStdOutProgress::processProgressEvent ( ossimProcessProgressEvent event)
virtual

Reimplemented from ossimProcessListener.

Definition at line 54 of file ossimStdOutProgress.cpp.

References ossimString::c_str(), ossimString::empty(), ossimProcessProgressEvent::getOutputMessageFlag(), ossimNotify(), ossimNotifyLevel_NOTICE, theFlushStreamFlag, thePrecision, and theRunningInConsoleFlag.

55 {
57  return;
58 
59  if (event.getOutputMessageFlag())
60  {
61  ossimString s;
62  event.getMessage(s);
63  if (!s.empty())
64  {
65  ossimNotify(ossimNotifyLevel_NOTICE) << s.c_str() << std::endl;
66  }
67  return; // Don't output percentage on a message update.
68  }
69 
70  double p = event.getPercentComplete();
72  << std::setiosflags(std::ios::fixed)
73  << std::setprecision(thePrecision)
74  << p << "%\r";
75 
77  {
78  (p != 100.0) ?
81  }
82 }
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
bool empty() const
Definition: ossimString.h:411
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ setFlushStreamFlag()

void ossimStdOutProgress::setFlushStreamFlag ( bool  flag)
virtual

Definition at line 84 of file ossimStdOutProgress.cpp.

References theFlushStreamFlag.

85 {
86  theFlushStreamFlag = flag;
87 }

Member Data Documentation

◆ theFlushStreamFlag

bool ossimStdOutProgress::theFlushStreamFlag
protected

Definition at line 30 of file ossimStdOutProgress.h.

Referenced by processProgressEvent(), and setFlushStreamFlag().

◆ thePrecision

ossim_uint32 ossimStdOutProgress::thePrecision
protected

Definition at line 29 of file ossimStdOutProgress.h.

Referenced by processProgressEvent().

◆ theRunningInConsoleFlag

bool ossimStdOutProgress::theRunningInConsoleFlag
protected

Definition at line 31 of file ossimStdOutProgress.h.

Referenced by ossimStdOutProgress(), and processProgressEvent().


The documentation for this class was generated from the following files: