2 * Copyright (c) 2018 Panasonic 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.
16 #ifndef ACTIVITY_MANAGER_HPP
17 #define ACTIVITY_MANAGER_HPP
23 #include <afb/afb-binding.h>
29 #define LCM_EVENT_STATUS_CHANGED "statusChanged"
30 #define LCM_API_GET_ACTIVITY_STATUS "getActivityStatus"
32 #define LCM_TARGET "target"
33 #define LCM_STATE "state"
39 CREATED, // after ON_CREATE
40 DESTROYED,// after ON_DESTROY
42 STARTED, // after ON_START, ON_RESTART
43 STOPPED, // after ON_STOP
45 FOREGROUND, // after ON_FOREGROUND
46 BACKGROUND, // after ON_BACKGROUND
51 #define ACTIVITY_FILTER_ALL_SET "111111" // For demo, always notify all states
53 struct _observer_context {
54 afb_event_t event; // onStatusChanged
55 std::bitset<NUM_STATUS> filter; // not supported yet
58 using observer = struct _observer_context;
60 // map of <"id:appid", "context of observer">
61 using observers = std::map<std::string, observer>;
66 explicit ActivityManager();
67 ~ActivityManager() = default;
69 void api_register_activity_observer (afb_req_t req);
70 void api_unregister_activity_observer (afb_req_t req);
71 wm::result<json_object *> api_get_activity_status(const char *appid);
74 void emit_activity_status_changed(const char* appid, const char* state);
76 // map of <"id:target", "registered observers">
77 std::map<std::string, observers> map_observers;
78 // map of <"id:target", "current_state">
79 std::map<std::string, int> states;
81 const char *states_s[NUM_STATUS];
85 #endif /* ACTIVITY_MANAGER_HPP */