Advertisement
Guest User

Untitled

a guest
Sep 14th, 2014
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. using TEventId = const std::string*;
  2. class TEventStorer: public std::unordered_set<std::string> {
  3. public:
  4.     TEventId Add(const std::string& event) {
  5.         return &(*this->insert(event).first);
  6.     }
  7.     TEventId Find(const std::string& event) {
  8.         auto it = this->find(event);
  9.         return it != this->end() ? &(*it) : nullptr;
  10.     }
  11. };
  12.  
  13. class SuperFastObject
  14. {
  15. public:
  16.     int execute(TEventId event) const
  17.     {
  18.         auto it = _events.find(event);
  19.         if(it!=_events.end())
  20.         {
  21.             return it->second.execute();
  22.         }
  23.         return 0;
  24.     }
  25.     void addevent(TEventId event, Script script)
  26.     {
  27.         _events.insert(make_pair(event, script));
  28.     }
  29. private:
  30.     std::map<TEventId, Script> _events;
  31. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement