nmsgnode.h

来自「奇迹世界公用文件源代码,研究网络游戏的朋友可以研究下」· C头文件 代码 · 共 82 行

H
82
字号
#ifndef N_MSGNODE_H
#define N_MSGNODE_H
//------------------------------------------------------------------------------
/**
    @briefA doubly linked list node which can carry a msg.

    @author
    - RadonLabs GmbH 

    @since
    - 2005.6.30
    @remarks
    - 瘤肯 眠啊 
*/

#include <string.h>
#include "nnode.h"

//------------------------------------------------------------------------------
class nMsgNode : public nNode 
{
public:
    /// constructor
    nMsgNode(void* buf, int size);
    /// destructor
    ~nMsgNode();
    /// get pointer to message
    void* GetMsgPtr() const;
    /// get size of message
    int GetMsgSize() const;

private:
    char *msgBuf;
    int msgSize;
};

//------------------------------------------------------------------------------
/**
*/
inline 
nMsgNode::nMsgNode(void *buf, int size)
{
    ASSERT(buf);
    ASSERT(size > 0);
    this->msgBuf  = (char*) n_malloc(size);
    this->msgSize = size;
    ASSERT(this->msgBuf);
    memcpy(this->msgBuf, buf, size);
}

//------------------------------------------------------------------------------
/**
*/
inline 
nMsgNode::~nMsgNode()
{
    n_free(this->msgBuf);
}     

//------------------------------------------------------------------------------
/**
*/
inline 
void*
nMsgNode::GetMsgPtr() const
{
    return this->msgBuf;
}

//------------------------------------------------------------------------------
/**
*/
inline 
int 
nMsgNode::GetMsgSize() const
{
    return this->msgSize;
}

//------------------------------------------------------------------------------
#endif

⌨️ 快捷键说明

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