diff options
author | Yuta Doi <yuta-d@witz-inc.co.jp> | 2018-04-27 19:01:36 +0900 |
---|---|---|
committer | Yuta Doi <yuta-d@witz-inc.co.jp> | 2018-04-27 19:01:36 +0900 |
commit | 55be85ed4bdfea6fc037d781b8cd8f58487718d1 (patch) | |
tree | 279a88e26c74aee58f11e2a5d20348569ce34667 /src/json_helper.cpp | |
parent | d50188f726b15a0ae2777bf2d91ee88836feeac5 (diff) |
Add PolicyManager, related classes and some config files
- PolicyManager
Decide next layout by using occured event and current state
based on policy table.
This PolicyManger is reference and the OEMs can replace it.
- LayoutManager
Change the current layout to the layout
which decided by PolicyManager.
NOTE:
The functions of this class had been included in App class.
The part of function of this class remain there yet.
- LowCanClient
Receive the CAN signal from low level CAN service.
- app.db
Define the applications name and its role.
This file will be deleted
when the names and roles can be given by other module.
- layout.cb
Define the layouts and areas which are included by the layout.
- role.db
Define the roles of the applications.
Change-Id: I2f84bdf5e68355e022f516cee9a1db88efe58825
Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
Diffstat (limited to 'src/json_helper.cpp')
-rw-r--r-- | src/json_helper.cpp | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/src/json_helper.cpp b/src/json_helper.cpp index 193a187..ac3d2b0 100644 --- a/src/json_helper.cpp +++ b/src/json_helper.cpp @@ -14,9 +14,12 @@ * limitations under the License. */ -#include "json_helper.hpp" +#include <json-c/json.h> #include <json.h> +#include "json_helper.hpp" +#include "hmi-debug.h" + json_object *to_json(compositor::surface_properties const &s) { // auto j = json::object({ @@ -100,3 +103,52 @@ json_object *to_json(std::vector<uint32_t> const &v) { } return a; } + +namespace jh { + +const char* getStringFromJson(json_object* obj, const char* key) { + if ((nullptr == obj) || (nullptr == key)) { + HMI_ERROR("wm:jh", "Argument is nullptr!!!"); + return nullptr; + } + + json_object* tmp; + if (!json_object_object_get_ex(obj, key, &tmp)) { + HMI_DEBUG("wm:jh", "Not found key \"%s\"", key); + return nullptr; + } + + return json_object_get_string(tmp); +} + +int getIntFromJson(json_object* obj, const char* key) { + if ((nullptr == obj) || (nullptr == key)) { + HMI_ERROR("wm", "Argument is nullptr!!!"); + return 0; + } + + json_object* tmp; + if (!json_object_object_get_ex(obj, key, &tmp)) { + HMI_DEBUG("wm", "Not found key \"%s\"", key); + return 0; + } + + return json_object_get_int(tmp); +} + +json_bool getBoolFromJson(json_object* obj, const char* key) { + if ((nullptr == obj) || (nullptr == key)) { + HMI_ERROR("wm", "Argument is nullptr!!!"); + return 0; + } + + json_object* tmp; + if (!json_object_object_get_ex(obj, key, &tmp)) { + HMI_DEBUG("wm", "Not found key \"%s\"", key); + return 0; + } + + return json_object_get_boolean(tmp); +} + +} // namespace jh |