SmartOS/Message/DataStore.h

43 lines
851 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __DataStore_H__
#define __DataStore_H__
#include "Sys.h"
#include "Stream.h"
// 数据存储适配器
class DataStore
{
public:
ByteArray Data; // 数据
bool Strict; // 是否严格限制存储区读写不许越界。默认true
// 初始化
DataStore();
// 写入数据
int Write(uint offset, ByteArray& bs);
// 读取数据
int Read(uint offset, ByteArray& bs);
typedef bool (*Handler)(DataStore& ds, uint offset, uint size, ByteArray& bs);
class Area
{
public:
uint Offset;
uint Size;
Handler Writing; // 写入之前
Handler Wrote; // 写入之后
Handler Read; // 读取之前
Area();
};
Area Areas[0x10];
// 注册某一块区域的读写钩子函数
void Register(uint offset, uint size, Handler writing, Handler wrote, Handler read);
};
#endif