AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
agx::Notify Class Reference

Class for handling logging of messages. More...

#include <Notify.h>

+ Inheritance diagram for agx::Notify:

Public Types

enum  NotifyLevel {
  NOTIFY_DEBUG = 1 << 0 , NOTIFY_INFO = 1 << 1 , NOTIFY_WARNING = 1 << 2 , NOTIFY_ERROR = 1 << 3 ,
  NOTIFY_END = 1 << 4 , NOTIFY_CLEAR = 1 << 5 , NOTIFY_PUSH = 1 << 6 , NOTIFY_LOGONLY = 1 << 7
}
 
enum  NotifySelection {
  PRINT_NONE = 0 , PRINT_FILE = 1 , PRINT_TAG = 2 , PRINT_LINE = 4 ,
  PRINT_FUNCTION = 8 , PRINT_SELECTION_END = 8 , PRINT_DEFAULT = PRINT_TAG | PRINT_FUNCTION , PRINT_ALL = PRINT_FILE | PRINT_TAG | PRINT_LINE | PRINT_FUNCTION
}
 
- Public Types inherited from agx::Singleton
enum  Priority { HIGHEST_PRIORITY = 2147483647 , LOWEST_PRIORITY = 10000 , DEFAULT_PRIORITY = 1073741824 }
 Specifies the ranges of the priority which can be assigned to a singleton at the time of creation. More...
 

Public Member Functions

 Notify (std::ostream &out_stream=std::cerr)
 Constructor.
 
virtual ~Notify ()
 
void addCallback (NotifyCallback *callback, NotifyLevel l)
 Add a callback class that will be printed to if the notify level less or equal to l.
 
void addStream (std::ostream *stream, NotifyLevel l)
 Add a stream that will be printed to if the notify level less or equal to l, the memory will NOT be managed by this class.
 
agx::String buildString ()
 
bool getBreakOnError () const
 
NotifyLevel getNotifyLevel () const
 
NotifyLevel getOutputMode () const
 
bool getThrowOnError () const
 
bool getToLogOnly () const
 
agx::LogStream & logStream ()
 
const agx::LogStream & logStream () const
 
bool openLog (const agx::String &filename)
 Open a log file (in the LogStream)
 
std::ostream & outStream ()
 
bool removeCallback (NotifyCallback *callback)
 Remove a callback from list of callbacks to report messages to.
 
bool removeStream (std::ostream *stream)
 Remove a stream from list of streams to report messages to.
 
void setBreakOnError (bool f)
 WIN32 specific: If set to true, a breakpoint will be set in debug build.
 
agx::String setDebugStrings (NotifyLevel l, const char *function, int line, const char *file)
 
void setLogNotifyLevel (NotifyLevel l)
 Set the notify level for the LogStream.
 
bool setNotifyLevel (NotifyCallback *callback, NotifyLevel l)
 Set the notify level for a specific callback.
 
void setNotifyLevel (NotifyLevel level)
 Set the current notify level.
 
bool setNotifyLevel (std::ostream *stream, NotifyLevel l)
 Set the notify level for a specific stream.
 
void setOutputMode (NotifyLevel l)
 Set the current output mode, do not use! (used internally)
 
void setThrowOnError (bool v)
 Specify whether we should Throw an exception upon calling error?
 
void setToLogOnly (bool f)
 If f==true, logging will occur only to the LogStream, not to any of the associated ostreams.
 
void shutdown () override
 Implement this method to cleanup your Singleton class.
 
- Public Member Functions inherited from agx::Singleton
 Singleton (int priority=DEFAULT_PRIORITY)
 Default constructor.
 
virtual std::string getClassName () const =0
 
int getPriority () const
 Return the shutdown priority of the singleton instance.
 
virtual void shutdown ()=0
 Implement this method to cleanup your Singleton class.
 

Static Public Member Functions

static Notify * instance ()
 

Protected Member Functions

void clear ()
 
std::string str () const
 
void str (const std::string &text)
 
- Protected Member Functions inherited from agx::Singleton
virtual ~Singleton ()
 Destructor.
 
void _shutdown ()
 

Protected Attributes

Clear m_clear
 
End m_end
 
LogOnly m_log
 
Push m_push
 

Detailed Description

Class for handling logging of messages.

Definition at line 63 of file Notify.h.

Member Enumeration Documentation

◆ NotifyLevel

Enumerator
NOTIFY_DEBUG 

DEBUG (lowest) level.

NOTIFY_INFO 

INFO level.

NOTIFY_WARNING 

WARNING level.

NOTIFY_ERROR 

ERROR (highest) level.

NOTIFY_END 
NOTIFY_CLEAR 
NOTIFY_PUSH 
NOTIFY_LOGONLY 

Definition at line 67 of file Notify.h.

◆ NotifySelection

Enumerator
PRINT_NONE 
PRINT_FILE 
PRINT_TAG 
PRINT_LINE 
PRINT_FUNCTION 
PRINT_SELECTION_END 
PRINT_DEFAULT 
PRINT_ALL 

Definition at line 77 of file Notify.h.

Constructor & Destructor Documentation

◆ Notify()

agx::Notify::Notify ( std::ostream &  out_stream = std::cerr)

Constructor.

Parameters
out_stream- Connect the default output to a specified stream, default is std::cerr

◆ ~Notify()

virtual agx::Notify::~Notify ( )
virtual

Member Function Documentation

◆ addCallback()

void agx::Notify::addCallback ( NotifyCallback *  callback,
NotifyLevel  l 
)

Add a callback class that will be printed to if the notify level less or equal to l.

◆ addStream()

void agx::Notify::addStream ( std::ostream *  stream,
NotifyLevel  l 
)

Add a stream that will be printed to if the notify level less or equal to l, the memory will NOT be managed by this class.

◆ buildString()

agx::String agx::Notify::buildString ( )

◆ clear()

void agx::Notify::clear ( )
protected

◆ getBreakOnError()

bool agx::Notify::getBreakOnError ( ) const
Returns
true if an a breakpoint should be set upon calling error

◆ getNotifyLevel()

NotifyLevel agx::Notify::getNotifyLevel ( ) const
Returns
the current notify level

◆ getOutputMode()

NotifyLevel agx::Notify::getOutputMode ( ) const
Returns
the current notify level

◆ getThrowOnError()

bool agx::Notify::getThrowOnError ( ) const
Returns
true if an exception should be thrown upon calling error?

◆ getToLogOnly()

bool agx::Notify::getToLogOnly ( ) const
Returns
true if logging occurs to the LogStream ONLY.

◆ instance()

static Notify * agx::Notify::instance ( )
static
Returns
pointer to the singleton instance of a Notify

◆ logStream() [1/2]

agx::LogStream & agx::Notify::logStream ( )
Returns
a reference to the LogStream used for streaming messages to function callbacks, files..

◆ logStream() [2/2]

const agx::LogStream & agx::Notify::logStream ( ) const
Returns
a reference to the LogStream used for streaming messages to function callbacks, files..

◆ openLog()

bool agx::Notify::openLog ( const agx::String &  filename)

Open a log file (in the LogStream)

◆ outStream()

std::ostream & agx::Notify::outStream ( )

◆ removeCallback()

bool agx::Notify::removeCallback ( NotifyCallback *  callback)

Remove a callback from list of callbacks to report messages to.

Returns
true if the stream was removed

◆ removeStream()

bool agx::Notify::removeStream ( std::ostream *  stream)

Remove a stream from list of streams to report messages to.

NO memory will be deallocated.

Returns
true if the stream was removed

◆ setBreakOnError()

void agx::Notify::setBreakOnError ( bool  f)

WIN32 specific: If set to true, a breakpoint will be set in debug build.

This makes it easier to debug problems in VisualStudio. A call to this method has effect only if:

  • Built in VisualStudio
  • Build in DEBUG mode

Observe, if this is set to true, NO exception will be generated if the above conditions are met.

◆ setDebugStrings()

agx::String agx::Notify::setDebugStrings ( NotifyLevel  l,
const char *  function,
int  line,
const char *  file 
)

◆ setLogNotifyLevel()

void agx::Notify::setLogNotifyLevel ( NotifyLevel  l)

Set the notify level for the LogStream.

◆ setNotifyLevel() [1/3]

bool agx::Notify::setNotifyLevel ( NotifyCallback *  callback,
NotifyLevel  l 
)

Set the notify level for a specific callback.

Returns
true if the stream exists

◆ setNotifyLevel() [2/3]

void agx::Notify::setNotifyLevel ( NotifyLevel  level)

Set the current notify level.

◆ setNotifyLevel() [3/3]

bool agx::Notify::setNotifyLevel ( std::ostream *  stream,
NotifyLevel  l 
)

Set the notify level for a specific stream.

Returns
true if the stream exists

◆ setOutputMode()

void agx::Notify::setOutputMode ( NotifyLevel  l)

Set the current output mode, do not use! (used internally)

◆ setThrowOnError()

void agx::Notify::setThrowOnError ( bool  v)

Specify whether we should Throw an exception upon calling error?

◆ setToLogOnly()

void agx::Notify::setToLogOnly ( bool  f)

If f==true, logging will occur only to the LogStream, not to any of the associated ostreams.

◆ shutdown()

void agx::Notify::shutdown ( )
overridevirtual

Implement this method to cleanup your Singleton class.

Implements agx::Singleton.

◆ str() [1/2]

std::string agx::Notify::str ( ) const
protected

◆ str() [2/2]

void agx::Notify::str ( const std::string &  text)
protected

Member Data Documentation

◆ m_clear

Clear agx::Notify::m_clear
protected

Definition at line 365 of file Notify.h.

◆ m_end

End agx::Notify::m_end
protected

Definition at line 364 of file Notify.h.

◆ m_log

LogOnly agx::Notify::m_log
protected

Definition at line 367 of file Notify.h.

◆ m_push

Push agx::Notify::m_push
protected

Definition at line 366 of file Notify.h.


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