revise essential map
authorYoungjae Shin <yj99.shin@samsung.com>
Tue, 25 Feb 2020 06:24:12 +0000 (15:24 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Wed, 18 Mar 2020 08:53:50 +0000 (17:53 +0900)
supervisor/Action.cpp
supervisor/ActionObserver.h
supervisor/ModeCareTaker.cpp
supervisor/ModeCareTaker.h

index c6224bc5f47b01152f0d6cfa1e03155383085c39..66003f69916160224199d7a6465f8122ca19626d 100644 (file)
@@ -133,7 +133,7 @@ void Action::notifyObservers()
        isChanged = true;
 
        for (auto it = observers.begin(); it != observers.end(); ++it)
-               (*it)->update(ruleName);
+               (*it)->update(reinterpret_cast<int*>(this));
 }
 
 void Action::valueChangedCallback(void *userData)
index 2e2a3d503148709f38696602bf945ab83e67d8ee..bb1681e24ea870d5cdf5152d66b9c639043661e9 100644 (file)
@@ -22,7 +22,7 @@ MODES_NAMESPACE_BEGIN
 
 class ActionObserver {
 public:
-       virtual void update(const std::string &rule) = 0;
+       virtual void update(int *key) = 0;
 };
 
 MODES_NAMESPACE_END
index c362511bbe8068a3e11f9e8e60f86ce6b052f799..f8343af8ffec6759ad3aee8438cc9f7b64bed36c 100644 (file)
@@ -121,17 +121,18 @@ void ModeCareTaker::handleEssentialAction(const Mode &mode)
        for (auto it = actionList.begin(); it != actionList.end(); it++) {
                if ((*it)->getRestrict() == Action::ESSENTIAL) {
                        DBG("Essential Action(%s)", (*it)->getRuleName().c_str());
-                       essentialMap.insert(std::make_pair((*it)->getRuleName(), mode.getName()));
+                       essentialMap.insert(std::make_pair((*it).get(), mode.getName()));
                        (*it)->attachObserver(this);
                }
        }
 }
 
-void ModeCareTaker::update(const std::string &rule)
+void ModeCareTaker::update(int *key)
 {
-       auto found = essentialMap.find(rule);
+       Action *action = reinterpret_cast<Action*>(key);
+       auto found = essentialMap.find(action);
        if (essentialMap.end() == found) {
-               ERR("No Mode related with essential rule(%s)", rule.c_str());
+               ERR("No Mode related with essential rule(%s)", action->getRuleName().c_str());
                return;
        }
 
index 7803dbf09d679a287118b14dab82f0ecf11a6457..50d975bacfe2ecbacd9324942632c9971e7fdef7 100644 (file)
@@ -34,12 +34,12 @@ public:
        int popMode(const std::string &name, Mode &mode);
        bool isSavedMode(const std::string &name);
        bool checkConflictAction(const Mode &mode);
-       void update(const std::string &rule);
+       void update(int *key);
 private:
        void handleEssentialAction(const Mode &mode);
        bool findLockedAction(const std::string &ruleName);
        std::map<std::string, Mode> savedModes;
-       std::multimap<std::string, std::string> essentialMap;
+       std::multimap<Action*, std::string> essentialMap;
        std::string undoDir;
 };