游戏.消息管理器
来源:互联网 发布:adobe muse mac 网盘 编辑:程序博客网 时间:2024/05/17 09:36
/**************************************************
WinMain.cpp
堆栈式的函数管理器
http://blog.csdn.net/chinayaosir
**************************************************/
//0.头文件
#include <windows.h>
#include <stdio.h>
//1.管理器类定义
class cProcessManager
{
// A structure that stores a function pointer and linked list
typedef struct sProcess {
void (*Function)();
sProcess *Next;
} sProcess;
protected:
sProcess *m_ProcessParent; // The top state in the stack
// (the head of the stack)
public:
cProcessManager() { m_ProcessParent = NULL; }
~cProcessManager() {
sProcess *ProcessPtr;
// Remove all processes from the stack
while((ProcessPtr = m_ProcessParent) != NULL) {
m_ProcessParent = ProcessPtr->Next;
delete ProcessPtr;
}
}
// Add function on to the stack
void Add(void (*Process)())
{
// Don't push a NULL value
if(Process != NULL) {
// Allocate a new process and push it on stack
sProcess *ProcessPtr = new sProcess;
ProcessPtr->Next = m_ProcessParent;
m_ProcessParent = ProcessPtr;
ProcessPtr->Function = Process;
}
}
// Process all functions
void Process()
{
sProcess *ProcessPtr = m_ProcessParent;
while(ProcessPtr != NULL) {
ProcessPtr->Function();
ProcessPtr = ProcessPtr->Next;
}
}
};
//3.生成此类的一个对象g_ProcessManager
cProcessManager g_ProcessManager;
//4.WinMain主函数
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int nCmdShow);
// Macro to ease the use of MessageBox function
#define MB(s) MessageBox(NULL, s, s, MB_OK);
// Processfunction prototypes - must follow this prototype!
void Func1() { MB("function1"); }
void Func2() { MB("function2"); }
void Func3() { MB("function3"); }
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int nCmdShow)
{
g_ProcessManager.Add(Func1);//函数压入堆栈
g_ProcessManager.Add(Func2);//函数压入堆栈
g_ProcessManager.Add(Func3);//函数压入堆栈
g_ProcessManager.Process();//依次遍历堆栈中的函数
return 0;
}
- 游戏.消息管理器
- 游戏管理器
- Delta3D之通过游戏管理器组件和消息的扩展创建自定义行为
- 简易消息管理器EventCenter
- 游戏.状态管理器
- 游戏管理器(1)
- 游戏管理器(2)
- 游戏中时间管理器
- 消息队列管理器抽象工厂
- 飞信消息管理器2011
- rtems 的消息与消息队列管理器
- 游戏及学习控制管理器
- 巧用Windows 7游戏管理器
- 巧用Windows 7游戏管理器
- 游戏对象数据存储管理器
- 终于导出TM消息管理器中的表情
- 飞信消息管理器2010 0.1
- 飞信消息管理器2010 V2.0
- 《PHP和MySQL Web 开发,原书第4版》光盘/源代码/资源/下载
- Java 常用 数据转换
- 局域网的IP地址选择
- proteus7.2SP6下载、安装、说明
- 几个字符串转数字的函数
- 游戏.消息管理器
- ubuntu下用jsvc把java程序做为linux服务启动
- javascript 接收页面传值
- 目录间复制文件的线程实现
- 时间管理
- 企业是怎么做大的.
- java连接数据库大全
- 无法安装数据库关系图支持对象
- goto语句的使用