TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
rcContext Class Reference

#include <Recast.h>

Public Member Functions

 rcContext (bool state=true)
 
virtual ~rcContext ()
 
void enableLog (bool state)
 
void resetLog ()
 Clears all log entries. More...
 
void log (const rcLogCategory category, const char *format,...)
 
void enableTimer (bool state)
 
void resetTimers ()
 Clears all peformance timers. (Resets all to unused.) More...
 
void startTimer (const rcTimerLabel label)
 
void stopTimer (const rcTimerLabel label)
 
int getAccumulatedTime (const rcTimerLabel label) const
 

Protected Member Functions

virtual void doResetLog ()
 Clears all log entries. More...
 
virtual void doLog (const rcLogCategory, const char *, const int)
 
virtual void doResetTimers ()
 Clears all timers. (Resets all to unused.) More...
 
virtual void doStartTimer (const rcTimerLabel)
 
virtual void doStopTimer (const rcTimerLabel)
 
virtual int doGetAccumulatedTime (const rcTimerLabel) const
 

Protected Attributes

bool m_logEnabled
 True if logging is enabled. More...
 
bool m_timerEnabled
 True if the performance timers are enabled. More...
 

Detailed Description

Provides an interface for optional logging and performance tracking of the Recast build process.

This class does not provide logging or timer functionality on its own. Both must be provided by a concrete implementation by overriding the protected member functions. Also, this class does not provide an interface for extracting log messages. (Only adding them.) So concrete implementations must provide one.

If no logging or timers are required, just pass an instance of this class through the Recast build process.

Constructor & Destructor Documentation

rcContext::rcContext ( bool  state = true)
inline

Contructor.

Parameters
[in]stateTRUE if the logging and performance timers should be enabled. [Default: true]
107 : m_logEnabled(state), m_timerEnabled(state) {}
bool m_logEnabled
True if logging is enabled.
Definition: Recast.h:170
bool m_timerEnabled
True if the performance timers are enabled.
Definition: Recast.h:173
virtual rcContext::~rcContext ( )
inlinevirtual
108 {}

Member Function Documentation

virtual int rcContext::doGetAccumulatedTime ( const rcTimerLabel  ) const
inlineprotectedvirtual

Returns the total accumulated time of the specified performance timer.

Parameters
[in]labelThe category of the timer.
Returns
The accumulated time of the timer, or -1 if timers are disabled or the timer has never been started.
167 { return -1; }

+ Here is the caller graph for this function:

virtual void rcContext::doLog ( const rcLogCategory  ,
const char *  ,
const int   
)
inlineprotectedvirtual

Logs a message.

Parameters
[in]categoryThe category of the message.
[in]msgThe formatted message.
[in]lenThe length of the formatted message.
151 {}

+ Here is the caller graph for this function:

virtual void rcContext::doResetLog ( )
inlineprotectedvirtual

Clears all log entries.

145 {}

+ Here is the caller graph for this function:

virtual void rcContext::doResetTimers ( )
inlineprotectedvirtual

Clears all timers. (Resets all to unused.)

154 {}

+ Here is the caller graph for this function:

virtual void rcContext::doStartTimer ( const rcTimerLabel  )
inlineprotectedvirtual

Starts the specified performance timer.

Parameters
[in]labelThe category of timer.
158 {}

+ Here is the caller graph for this function:

virtual void rcContext::doStopTimer ( const rcTimerLabel  )
inlineprotectedvirtual

Stops the specified performance timer.

Parameters
[in]labelThe category of the timer.
162 {}

+ Here is the caller graph for this function:

void rcContext::enableLog ( bool  state)
inline

Enables or disables logging.

Parameters
[in]stateTRUE if logging should be enabled.
112 { m_logEnabled = state; }
bool m_logEnabled
True if logging is enabled.
Definition: Recast.h:170
void rcContext::enableTimer ( bool  state)
inline

Enables or disables the performance timers.

Parameters
[in]stateTRUE if timers should be enabled.
124 { m_timerEnabled = state; }
bool m_timerEnabled
True if the performance timers are enabled.
Definition: Recast.h:173
int rcContext::getAccumulatedTime ( const rcTimerLabel  label) const
inline

Returns the total accumulated time of the specified performance timer.

Parameters
labelThe category of the timer.
Returns
The accumulated time of the timer, or -1 if timers are disabled or the timer has never been started.
140 { return m_timerEnabled ? doGetAccumulatedTime(label) : -1; }
bool m_timerEnabled
True if the performance timers are enabled.
Definition: Recast.h:173
virtual int doGetAccumulatedTime(const rcTimerLabel) const
Definition: Recast.h:167

+ Here is the call graph for this function:

void rcContext::log ( const rcLogCategory  category,
const char *  format,
  ... 
)

Logs a message.

Parameters
[in]categoryThe category of the message.
[in]formatThe message.

Example:

// Where ctx is an instance of rcContext and filepath is a char array.
ctx->log(RC_LOG_ERROR, "buildTiledNavigation: Could not load '%s'", filepath);
56 {
57  if (!m_logEnabled)
58  return;
59  static const int MSG_SIZE = 512;
60  char msg[MSG_SIZE];
61  va_list ap;
62  va_start(ap, format);
63  int len = vsnprintf(msg, MSG_SIZE, format, ap);
64  if (len >= MSG_SIZE)
65  {
66  len = MSG_SIZE-1;
67  msg[MSG_SIZE-1] = '\0';
68  }
69  va_end(ap);
70  doLog(category, msg, len);
71 }
void format(BasicFormatter< Char > &f, const Char *&format_str, const T &value)
Definition: format.h:2963
bool m_logEnabled
True if logging is enabled.
Definition: Recast.h:170
#define vsnprintf
Definition: Common.h:78
virtual void doLog(const rcLogCategory, const char *, const int)
Definition: Recast.h:151

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void rcContext::resetLog ( )
inline

Clears all log entries.

115 { if (m_logEnabled) doResetLog(); }
bool m_logEnabled
True if logging is enabled.
Definition: Recast.h:170
virtual void doResetLog()
Clears all log entries.
Definition: Recast.h:145

+ Here is the call graph for this function:

void rcContext::resetTimers ( )
inline

Clears all peformance timers. (Resets all to unused.)

127 { if (m_timerEnabled) doResetTimers(); }
bool m_timerEnabled
True if the performance timers are enabled.
Definition: Recast.h:173
virtual void doResetTimers()
Clears all timers. (Resets all to unused.)
Definition: Recast.h:154

+ Here is the call graph for this function:

void rcContext::startTimer ( const rcTimerLabel  label)
inline

Starts the specified performance timer.

Parameters
labelThe category of timer.
131 { if (m_timerEnabled) doStartTimer(label); }
bool m_timerEnabled
True if the performance timers are enabled.
Definition: Recast.h:173
virtual void doStartTimer(const rcTimerLabel)
Definition: Recast.h:158

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void rcContext::stopTimer ( const rcTimerLabel  label)
inline

Stops the specified performance timer.

Parameters
labelThe category of the timer.
135 { if (m_timerEnabled) doStopTimer(label); }
bool m_timerEnabled
True if the performance timers are enabled.
Definition: Recast.h:173
virtual void doStopTimer(const rcTimerLabel)
Definition: Recast.h:162

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

bool rcContext::m_logEnabled
protected

True if logging is enabled.

bool rcContext::m_timerEnabled
protected

True if the performance timers are enabled.


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