1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/*
* Copyright (c) 2019 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 HOMESCREEN_VUIADAPTER_H
#define HOMESCREEN_VUIADAPTER_H
#include <map>
#include <memory>
#include <utility>
#include "hs-helper.h"
#include "hs-clientmanager.h"
class Vui_ModuleBase {
public:
explicit Vui_ModuleBase(std::string uid) : m_uid(uid) {}
virtual ~Vui_ModuleBase() {}
virtual void init(afb_api_t api) = 0;
virtual int onEvent(afb_api_t api, const char *event, struct json_object *object) = 0;
std::string mouduleId(void) {return m_uid;}
private:
std::string m_uid;
};
class Vui_Navigation : public Vui_ModuleBase, public listener_interface {
public:
explicit Vui_Navigation(std::string uid) : Vui_ModuleBase(uid), listener_interface(uid) {}
~Vui_Navigation() = default;
virtual void init(afb_api_t api);
virtual int onEvent(afb_api_t api, const char *event, struct json_object *object);
virtual void notify(afb_api_t api, std::string appid = "");
private:
void set_destination(afb_api_t api, struct json_object *object);
void cancel_navigation(afb_api_t api, struct json_object *object);
void set_destination2poi(afb_api_t api);
void start_navigation(afb_api_t api);
typedef void (Vui_Navigation::*func_handler)(afb_api_t, struct json_object *object);
static const std::map<std::string, func_handler> func_list;
std::pair<double, double> m_dest;
std::pair<bool, bool> m_start_flg;
};
class HS_VuiAdapter {
public:
HS_VuiAdapter() = default;
~HS_VuiAdapter() = default;
HS_VuiAdapter(HS_VuiAdapter const &) = delete;
HS_VuiAdapter &operator=(HS_VuiAdapter const &) = delete;
HS_VuiAdapter(HS_VuiAdapter &&) = delete;
HS_VuiAdapter &operator=(HS_VuiAdapter &&) = delete;
static HS_VuiAdapter* instance(void);
void init(afb_api_t api);
int onEvent(afb_api_t api, const char *event, struct json_object *object);
private:
static HS_VuiAdapter* me;
std::map<std::string, Vui_ModuleBase*> module_list;
};
#endif // HOMESCREEN_VUIADAPTER_H
|