#31 Squashed merge of commits relating to the plugin system and IContext redesign, from the 'interconnect' branch.

This commit is contained in:
Mathew Sutcliffe
2013-04-17 01:26:54 +01:00
parent 4e812975b4
commit 9916419678
57 changed files with 1517 additions and 1092 deletions

View File

@@ -3,8 +3,8 @@
//! License, v. 2.0. If a copy of the MPL was not distributed with this
//! file, You can obtain one at http://mozilla.org/MPL/2.0/
#ifndef DEBUG_H
#define DEBUG_H
#ifndef BLACKMISC_DEBUG_H
#define BLACKMISC_DEBUG_H
#include "blackmisc/context.h"
#include "blackmisc/log.h"
@@ -15,133 +15,111 @@
namespace BlackMisc
{
//! class CDebug
/*! This class implements the logging of the library. It holds a list of displays
takes care of any additional information needed, e.g. timestamps, filename etc.
To use the logging use the default displayer or implement your own one and
register it with this class.
*/
class CDebug
{
public:
//! class CDebug
/*! This class implements the logging of the library. It holds a list of displays
takes care of any additional information needed, e.g. timestamps, filename etc.
To use the logging use the default displayer or implement your own one and
register it with this class.
*/
class CDebug : public QObject
{
Q_OBJECT
public:
BLACK_INTERFACE(BlackMisc::CDebug)
CDebug();
// internal use only
void create(const char *logPath = "", bool logInFile = true, bool eraseLastLog = false);
// internal use only
void create (const char *logPath = "", bool logInFile = true, bool eraseLastLog = false);
// init Debug
void init(bool logInFile);
// init Debug
void init(bool logInFile);
/// Do not call this, unless you know what you're trying to do (it kills debug)!
void destroy() {}
/// Do not call this, unless you know what you're trying to do (it kills debug)!
void destroy() {}
void changeLogDirectory(const QString &dir) { Q_UNUSED(dir); }
QString getLogDirectory();
QString getLogDirectory();
// Assert function
//! Method returns the pointer to the global assert log object
/*!
\return Pointer to CLog object
*/
CLog *getAssertLog();
//! Pure virtual function to set the global assert log object
/*!
\param Pointer to CLog object
*/
void setAssertLog(CLog *assertLog);
//! Pure virtual method returns the pointer to the global error log object
/*!
\return Pointer to CLog object
*/
//! Pure virtual method returns the pointer to the global error log object
/*!
\return Pointer to CLog object
*/
CLog *getErrorLog();
//! Pure virtual function to set the global error log object
/*!
\param Pointer to CLog object
*/
//! Pure virtual function to set the global error log object
/*!
\param Pointer to CLog object
*/
void setErrorLog(CLog *errorLog);
//! Pure virtual method returns the pointer to the global warning log object
/*!
\return Pointer to CLog object
*/
//! Pure virtual method returns the pointer to the global warning log object
/*!
\return Pointer to CLog object
*/
CLog *getWarningLog();
//! Pure virtual function to set the global warning log object
/*!
\param Pointer to CLog object
*/
//! Pure virtual function to set the global warning log object
/*!
\param Pointer to CLog object
*/
void setWarningLog(CLog *warningLog);
//! Pure virtual method returns the pointer to the global info log object
/*!
\return Pointer to CLog object
*/
//! Pure virtual method returns the pointer to the global info log object
/*!
\return Pointer to CLog object
*/
CLog *getInfoLog();
//! Pure virtual function to set the global info log object
/*!
\param Pointer to CLog object
*/
//! Pure virtual function to set the global info log object
/*!
\param Pointer to CLog object
*/
void setInfoLog(CLog *infoLog);
//! Pure virtual method returns the pointer to the global debug log object
/*!
\return Pointer to CLog object
*/
//! Pure virtual method returns the pointer to the global debug log object
/*!
\return Pointer to CLog object
*/
CLog *getDebugLog();
//! Pure virtual function to set the global debug log object
/*!
\param Pointer to CLog object
*/
//! Pure virtual function to set the global debug log object
/*!
\param Pointer to CLog object
*/
void setDebugLog(CLog *debugLog);
void assertFailed(int line, const char *file, const char* function, const char *exp);
void assertFailedString(int line, const char *fileName, const char *methodName, const char* exp, const char* string);
CLogMessage blackInfo(int line, const char *fileName, const char *methodName);
CLogMessage blackWarning(int line, const char *fileName, const char *methodName);
CLogMessage blackDebug(int line, const char *fileName, const char *methodName);
CLogMessage blackError(int line, const char *fileName, const char *methodName);
CLogMessage blackAssert(int line, const char *fileName, const char *methodName);
CLogMessage blackAssertqstr(int line, const char *fileName, const char *methodName);
private:
bool m_isInitialized;
CLogMessage blackInfo(int line, const char *fileName, const char *methodName);
CLogMessage blackWarning(int line, const char *fileName, const char *methodName);
CLogMessage blackDebug(int line, const char *fileName, const char *methodName);
CLogMessage blackError(int line, const char *fileName, const char *methodName);
private:
bool m_isInitialized;
CStdDisplay *stdDisplayer;
CFileDisplay *fileDisplayer;
QString m_logPath;
CLog *m_errorLog;
CLog *m_warningLog;
CLog *m_infoLog;
CLog *m_debugLog;
CLog *m_assertLog;
};
/*!
Macro is not defined in VC6
*/
#if _MSC_VER <= 1200
# define __FUNCTION__ NULL
#endif
#define bInfo ( BlackMisc::IContext::getInstance().getDebug()->blackInfo(__LINE__, __FILE__, __FUNCTION__ ) )
#define bWarning ( BlackMisc::IContext::getInstance().getDebug()->blackWarning(__LINE__, __FILE__, __FUNCTION__ ) )
#define bDebug ( BlackMisc::IContext::getInstance().getDebug()->blackDebug(__LINE__, __FILE__, __FUNCTION__ ) )
#define bError ( BlackMisc::IContext::getInstance().getDebug()->blackError(__LINE__, __FILE__, __FUNCTION__ ) )
#define bAssert(exp) if (!(exp)) BlackMisc::IContext::getInstance().getDebug()->assertFailed(__LINE__, __FILE__, __FUNCTION__, #exp)
#define bAssertstr(exp, str) if (!(exp)) BlackMisc::IContext::getInstance().getDebug()->assertFailedString(__LINE__, __FILE__, __FUNCTION__, #exp, #str)
QString m_logPath;
CLog *m_errorLog;
CLog *m_warningLog;
CLog *m_infoLog;
CLog *m_debugLog;
};
#define bInfo(CONTEXT) ( (CONTEXT).getDebug()->blackInfo(__LINE__, __FILE__, __FUNCTION__ ) )
#define bWarning(CONTEXT) ( (CONTEXT).getDebug()->blackWarning(__LINE__, __FILE__, __FUNCTION__ ) )
#define bDebug(CONTEXT) ( (CONTEXT).getDebug()->blackDebug(__LINE__, __FILE__, __FUNCTION__ ) )
#define bError(CONTEXT) ( (CONTEXT).getDebug()->blackError(__LINE__, __FILE__, __FUNCTION__ ) )
#define bAppInfo bInfo(BlackMisc::IContext::getInstance())
#define bAppWarning bWarning(BlackMisc::IContext::getInstance())
#define bAppDebug bDebug(BlackMisc::IContext::getInstance())
#define bAppError bError(BlackMisc::IContext::getInstance())
} // namespace BlackMisc
#endif DEBUG_H // DEBUG_H
#endif //BLACKMISC_DEBUG_H