class CRegAuto : public QObject { Q_OBJECT public: static CRegAuto *getInstance(); static void ClearInstance(); typedef void (CRegAuto::*Callback)(int value); QHash<int, Callback> cheatCommands; void Initialize(); void processCallBack(); void add(int value); void jian(int); void cheng(int); void chufa(int); } void CRegAuto::jian(int value) { int b = value; } void CRegAuto::cheng(int value) { int c = value; } void CRegAuto::chufa(int value) { int d = value; } void CRegAuto::Initialize() { if (cheatCommands.isEmpty()) { cheatCommands[0] = &CRegAuto::add; cheatCommands[1] = &CRegAuto::jian; cheatCommands[2] = &CRegAuto::cheng; cheatCommands[3] = &CRegAuto::chufa; } processCallBack(); } void CRegAuto::processCallBack() { for (int i = 0; i < 4; i++) { Callback callback = cheatCommands[i]; if (callback) { (this->*callback)(i); } } }
时间: 2024-11-03 21:18:26