⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loglist.cpp

📁 linux程序
💻 CPP
字号:
// LogList.cpp: implementation of the CLogList class.
//
//////////////////////////////////////////////////////////////////////
#include "LogList.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CLogList *CLogList::pHead = NULL;
CLogList *CLogList::pTail = NULL;

CLogList::CLogList(char *msg,Bool8 type)
{
	pNext = NULL;
	mIsError = type;
	memset(mLogMsg,0,sizeof(mLogMsg));
	if(msg != NULL)
	{
		if(strlen(msg) < MAX_LOG_MSG_LEN )
			strcpy(mLogMsg,msg);
	}

}

CLogList::~CLogList()
{

}

Bool8 CLogList::RemoveAll()
{
	CLogList *pNode;
	while(pHead != NULL)
	{
		pNode = RemoveHead();
		delete pNode;
	}
	return true;
}

Bool8 CLogList::IsEmpty()
{
	if(pHead == NULL)
		return true;
	else
		return false;
}

CLogList *CLogList::RemoveHead()
{
	mListLock.Lock();
	if(pHead != NULL)
	{
		CLogList *tp = pHead;
		pHead = pHead->pNext;
		mListLock.Unlock();
		return tp;
	}
	mListLock.Unlock();
	return NULL;
}

Bool8 CLogList::AddMsgIntoTail(char *msg,Bool8 type)
{
	CLogList *element = new CLogList(msg,type);
	Bool8 bRet = AddMsgIntoTail(element);
	return bRet;

}

Bool8 CLogList::AddMsgIntoTail(CLogList *msg)
{
	mListLock.Lock();
	if(pHead != NULL)
	{
		pTail->pNext = msg;
	    pTail = msg; 
	}
	else
	{
		pHead = msg;
		pTail = msg;
	}
	mListLock.Unlock();

	return false;
}

const char *CLogList::GetMsg()
{
	return mLogMsg;
}

Bool8 CLogList::SetMsgIsError(Bool8 type)
{
	mIsError = type;
	return true;
}

Bool8 CLogList::GetMsgIsError()
{
	return mIsError;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -