2 * Copyright (c) 2018 TOYOTA MOTOR CORPORATION
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef TMCAGLWM_POLICY_MANAGER_HPP
18 #define TMCAGLWM_POLICY_MANAGER_HPP
21 #include <unordered_map>
32 explicit PolicyManager();
33 ~PolicyManager() = default;
35 using Handler = std::function<void(json_object *)>;
38 Handler onStateTransitioned;
43 void registerCallback(CallbackTable callback_table);
44 int inputEvent(json_object* json_in);
47 // Disable copy and move
48 PolicyManager(PolicyManager const &) = delete;
49 PolicyManager &operator=(PolicyManager const &) = delete;
50 PolicyManager(PolicyManager &&) = delete;
51 PolicyManager &operator=(PolicyManager &&) = delete;
54 std::unordered_map<std::string, int> eventname2no_;
55 std::unordered_map<std::string, int> categoryname2no_;
56 std::unordered_map<std::string, int> areaname2no_;
58 std::unordered_map<std::string, std::string> role2category_;
59 std::unordered_map<std::string, std::string> category2role_;
60 std::unordered_map<std::string, std::string> role2defaultarea_;
62 int initializeSdEventLoop();
70 const char* getStringFromJson(json_object* obj, const char* key);
71 int inputJsonFilie(const char* file, json_object** obj);
72 std::vector<std::string> parseString(std::string str, char delimiter);
73 std::string deleteSpace(std::string str);
78 extern const char* getStringFromJson(json_object* obj, const char* key);
79 extern int getIntFromJson(json_object* obj, const char* key);
82 #endif // TMCAGLWM_POLICY_MANAGER_HPP