#include <iostream>
#include <string>
#include <queue>
class Event {
public:
std::string name;
Event(const std::string &name_) :name(name_) {}
};
class KeyEvent : public Event {
public:
int key;
KeyEvent(const std::string &name_, int key_) : Event(name_), key(key_) {}
};
int main() {
std::queue<Event> eventsQueue;
eventsQueue.push(KeyEvent("keyPress", 16));
eventsQueue.push(Event("randomEvent"));
while(!eventsQueue.empty()) {
auto &e = eventsQueue.front();
std::cout << e.name;
if(e.name == "keyPress") {
std::cout << ": " << static_cast<KeyEvent &>(e).key;
}
eventsQueue.pop();
std::cout << std::endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8cXVldWU+CgpjbGFzcyBFdmVudCB7CnB1YmxpYzoKCXN0ZDo6c3RyaW5nIG5hbWU7CiAgICBFdmVudChjb25zdCBzdGQ6OnN0cmluZyAmbmFtZV8pIDpuYW1lKG5hbWVfKSB7fQp9OwoKY2xhc3MgS2V5RXZlbnQgOiBwdWJsaWMgRXZlbnQgewpwdWJsaWM6CiAgICBpbnQga2V5OwogICAgS2V5RXZlbnQoY29uc3Qgc3RkOjpzdHJpbmcgJm5hbWVfLCBpbnQga2V5XykgOiBFdmVudChuYW1lXyksIGtleShrZXlfKSB7fQp9OwoKaW50IG1haW4oKSB7CglzdGQ6OnF1ZXVlPEV2ZW50PiBldmVudHNRdWV1ZTsKCWV2ZW50c1F1ZXVlLnB1c2goS2V5RXZlbnQoImtleVByZXNzIiwgMTYpKTsKCWV2ZW50c1F1ZXVlLnB1c2goRXZlbnQoInJhbmRvbUV2ZW50IikpOwoJCgl3aGlsZSghZXZlbnRzUXVldWUuZW1wdHkoKSkgewoJCWF1dG8gJmUgPSBldmVudHNRdWV1ZS5mcm9udCgpOwoJCXN0ZDo6Y291dCA8PCBlLm5hbWU7CgkJaWYoZS5uYW1lID09ICJrZXlQcmVzcyIpIHsKCQkJc3RkOjpjb3V0IDw8ICI6ICIgPDwgc3RhdGljX2Nhc3Q8S2V5RXZlbnQgJj4oZSkua2V5OwoJCX0KCQlldmVudHNRdWV1ZS5wb3AoKTsKCQlzdGQ6OmNvdXQgPDwgc3RkOjplbmRsOwoJfQoJCglyZXR1cm4gMDsKfQ==