Initial
This commit is contained in:
100
guitar/GlobalDefs.hpp
Normal file
100
guitar/GlobalDefs.hpp
Normal file
@@ -0,0 +1,100 @@
|
||||
#ifndef _GUITAR_GLOBALDEFS_HPP_
|
||||
#define _GUITAR_GLOBALDEFS_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_FILE_HPP_
|
||||
#include <common/file.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_SYSTEMTIME_HPP_
|
||||
#include <common/systime.hpp>
|
||||
#endif
|
||||
#ifndef _GUITAR_INSTRUMENT_HPP_
|
||||
#include <guitar/Instrument.hpp>
|
||||
#endif
|
||||
|
||||
class GlobalDefs
|
||||
{
|
||||
public:
|
||||
typedef enum LogLevel{NoLog,Verbose,Info,Debug};
|
||||
enum{MicrosecondsPerQuarterNote=651578,ShowAction=1,ShowNotes=1};
|
||||
static void outDebug(const String &strDebug,LogLevel level=Debug);
|
||||
static LogLevel getLogLevel(void);
|
||||
static void setLogLevel(LogLevel logLevel);
|
||||
static bool setLogFile(const String &pathLogFile);
|
||||
static UINT getRegisteredClipboardFormat(void);
|
||||
static void setRegisteredClipboardFormat(UINT registeredClipboardFormat);
|
||||
static String translateLevel(LogLevel logLevel);
|
||||
private:
|
||||
GlobalDefs();
|
||||
virtual ~GlobalDefs();
|
||||
static UINT mRegisteredClipboardFormat;
|
||||
static LogLevel mLogLevel;
|
||||
static File mLogFile;
|
||||
};
|
||||
|
||||
inline
|
||||
GlobalDefs::GlobalDefs()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
GlobalDefs::~GlobalDefs()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
UINT GlobalDefs::getRegisteredClipboardFormat(void)
|
||||
{
|
||||
return mRegisteredClipboardFormat;
|
||||
}
|
||||
|
||||
inline
|
||||
void GlobalDefs::setRegisteredClipboardFormat(UINT registeredClipboardFormat)
|
||||
{
|
||||
mRegisteredClipboardFormat=registeredClipboardFormat;
|
||||
}
|
||||
|
||||
inline
|
||||
GlobalDefs::LogLevel GlobalDefs::getLogLevel(void)
|
||||
{
|
||||
return mLogLevel;
|
||||
}
|
||||
|
||||
inline
|
||||
void GlobalDefs::setLogLevel(LogLevel logLevel)
|
||||
{
|
||||
mLogLevel=logLevel;
|
||||
}
|
||||
|
||||
inline
|
||||
void GlobalDefs::outDebug(const String &strDebug,LogLevel logLevel)
|
||||
{
|
||||
if(NoLog==getLogLevel())return;
|
||||
if(mLogFile.isOkay()&&logLevel>=mLogLevel)
|
||||
{
|
||||
mLogFile.writeLine(translateLevel(logLevel)+strDebug);
|
||||
mLogFile.flush();
|
||||
}
|
||||
else if(logLevel>=mLogLevel)::OutputDebugString(String(translateLevel(logLevel)+strDebug+String("\n")).str());
|
||||
}
|
||||
|
||||
inline
|
||||
bool GlobalDefs::setLogFile(const String &pathLogFile)
|
||||
{
|
||||
return mLogFile.open(pathLogFile,"wb");
|
||||
}
|
||||
|
||||
inline
|
||||
String GlobalDefs::translateLevel(LogLevel logLevel)
|
||||
{
|
||||
SystemTime systemTime;
|
||||
if(NoLog==logLevel)return String("[Log.None][")+systemTime.toString()+String("]");
|
||||
else if(Verbose==logLevel)return String("[Log.Verbose][")+systemTime.toString()+String("]");
|
||||
else if(Debug==logLevel)return String("[Log.Debug][")+systemTime.toString()+String("]");
|
||||
else return String("[Log.Info]]")+systemTime.toString()+String("]");
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user