diff options
Diffstat (limited to 'src/policy_manager/policy_manager.hpp')
-rw-r--r-- | src/policy_manager/policy_manager.hpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/policy_manager/policy_manager.hpp b/src/policy_manager/policy_manager.hpp new file mode 100644 index 0000000..500120c --- /dev/null +++ b/src/policy_manager/policy_manager.hpp @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2018 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TMCAGLWM_POLICY_MANAGER_HPP +#define TMCAGLWM_POLICY_MANAGER_HPP + + +#include <unordered_map> +#include <vector> + +//namespace stm { +extern "C" { +#include "dummy_stm.h" +} +//} // namespace stm + +class PolicyManager { + +public: + explicit PolicyManager(); + ~PolicyManager() = default; + + int initialize(); + int checkPolicy(json_object* json_in, json_object** json_out); + std::string roleToCategory(const char* role); +private: + // Disable copy and move + PolicyManager(PolicyManager const &) = delete; + PolicyManager &operator=(PolicyManager const &) = delete; + PolicyManager(PolicyManager &&) = delete; + PolicyManager &operator=(PolicyManager &&) = delete; + + // Convert map + std::unordered_map<std::string, int> eventname2no_; + std::unordered_map<std::string, int> categoryname2no_; + std::unordered_map<std::string, int> areaname2no_; + + std::unordered_map<std::string, std::string> role2category_; + std::unordered_map<std::string, std::string> category2role_; + std::unordered_map<std::string, std::string> role2defaultarea_; + + stm_state_t current_state_; + + // Load role.db + int loadRoleDb(); + + const char* getStringFromJson(json_object* obj, const char* key); + int getIntFromJson(json_object* obj, const char* key); + void addStateToJson(const char* key, int is_changed, const char* state, json_object** json_out); + std::vector<std::string> parseString(std::string str, char delimiter); + std::string deleteSpace(std::string str); +}; + +#endif // TMCAGLWM_POLICY_MANAGER_HPP |