Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using TEventId = const std::string*;
- class TEventStorer: public std::unordered_set<std::string> {
- public:
- TEventId Add(const std::string& event) {
- return &(*this->insert(event).first);
- }
- TEventId Find(const std::string& event) {
- auto it = this->find(event);
- return it != this->end() ? &(*it) : nullptr;
- }
- };
- class SuperFastObject
- {
- public:
- int execute(TEventId event) const
- {
- auto it = _events.find(event);
- if(it!=_events.end())
- {
- return it->second.execute();
- }
- return 0;
- }
- void addevent(TEventId event, Script script)
- {
- _events.insert(make_pair(event, script));
- }
- private:
- std::map<TEventId, Script> _events;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement