Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- typedef void * (*EveFunc)(void *param);
- void * WindowEventCallBack (void * param);
- void * SystemEventCallBack (void * param);
- void handle_events();
- struct Event
- {
- EveFunc type;
- void *param ;
- Event(void *param,EveFunc type) : param(param),type(type) {}
- };
- std::vector <Event> events;
- int main()
- {
- int i = 5;
- Event event((void*)&i,WindowEventCallBack);
- events.push_back(event);
- std::pair<int,int> vars = std::make_pair(6,6);
- Event event2((void*)&vars,SystemEventCallBack);
- events.push_back(event2);
- handle_events();
- return 0;
- }
- void * SystemEventCallBack (void * param)
- {
- int var1 = static_cast<std::pair<int,int>*>(param)->first;
- int var2 = static_cast<std::pair<int,int>*>(param)->second;
- std::cout << var1 << std::endl;
- std::cout << var2 << std::endl;
- }
- void * WindowEventCallBack (void * param)
- {
- int WindowId = * static_cast<int*>(param);
- std::cout << WindowId << std::endl;
- }
- void handle_events()
- {
- for( int i = 0 ; i < events.size(); i++)
- {
- events[i].type(events[i].param);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement