X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Factivity_manager.hpp;fp=src%2Factivity_manager.hpp;h=066300396795e9e92f4370f21c4189766ad58588;hb=e35c4bf9b16927829e1741b9d9c08294f0cbed29;hp=0000000000000000000000000000000000000000;hpb=2b1bf85afe0a8b24f75386f7c24df85f9b785bd3;p=apps%2Fagl-service-windowmanager.git diff --git a/src/activity_manager.hpp b/src/activity_manager.hpp new file mode 100644 index 0000000..0663003 --- /dev/null +++ b/src/activity_manager.hpp @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2018 Panasonic 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 ACTIVITY_MANAGER_HPP +#define ACTIVITY_MANAGER_HPP + +#include + +extern "C" +{ +#include +} + +namespace lcm +{ + +#define LCM_EVENT_STATUS_CHANGED "statusChanged" +#define LCM_API_GET_ACTIVITY_STATUS "getActivityStatus" +#define LCM_API "api" +#define LCM_TARGET "target" +#define LCM_STATE "state" + +enum activity_status +{ + NOTEXISTS, + + CREATED, // after ON_CREATE + DESTROYED,// after ON_DESTROY + + STARTED, // after ON_START, ON_RESTART + STOPPED, // after ON_STOP + + FOREGROUND, // after ON_FOREGROUND + BACKGROUND, // after ON_BACKGROUND + + NUM_STATUS, +}; + +#define ACTIVITY_FILTER_ALL_SET "111111" // For demo, always notify all states + +struct _observer_context { + afb_event_t event; // onStatusChanged + std::bitset filter; // not supported yet +}; + +using observer = struct _observer_context; + +// map of <"id:appid", "context of observer"> +using observers = std::map; + +class ActivityManager +{ + public: + explicit ActivityManager(); + ~ActivityManager() = default; + + void api_register_activity_observer (afb_req_t req); + void api_unregister_activity_observer (afb_req_t req); + wm::result api_get_activity_status(const char *appid); + + public: + void emit_activity_status_changed(const char* appid, const char* state); + + // map of <"id:target", "registered observers"> + std::map map_observers; + // map of <"id:target", "current_state"> + std::map states; + + const char *states_s[NUM_STATUS]; +}; + +} // namespace lcm +#endif /* ACTIVITY_MANAGER_HPP */