NUGU SDK Linux  1.7.5
focus_manager_interface.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 SK Telecom Co., Ltd. All rights reserved.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 
17 #ifndef __NUGU_FOCUS_MANAGER_INTERFACE_H__
18 #define __NUGU_FOCUS_MANAGER_INTERFACE_H__
19 
20 #include <iostream>
21 #include <vector>
22 
23 namespace NuguClientKit {
24 
36 #define CALL_FOCUS_TYPE "Call"
37 #define CALL_FOCUS_REQUEST_PRIORITY 100
38 #define CALL_FOCUS_RELEASE_PRIORITY 100
40 #define ASR_USER_FOCUS_TYPE "ASRUser"
41 #define ASR_USER_FOCUS_REQUEST_PRIORITY 100
42 #define ASR_USER_FOCUS_RELEASE_PRIORITY 200
44 #define ASR_DM_FOCUS_TYPE "ASRDM"
45 #define ASR_DM_FOCUS_REQUEST_PRIORITY 400
46 #define ASR_DM_FOCUS_RELEASE_PRIORITY 300
48 #define INFO_FOCUS_TYPE "Info"
49 #define INFO_FOCUS_REQUEST_PRIORITY 200
50 #define INFO_FOCUS_RELEASE_PRIORITY 300
52 #define ALERTS_FOCUS_TYPE "Alerts"
53 #define ALERTS_FOCUS_REQUEST_PRIORITY 200
54 #define ALERTS_FOCUS_RELEASE_PRIORITY 300
56 #define ASR_BEEP_FOCUS_TYPE "ASRBeep"
57 #define ASR_BEEP_FOCUS_REQUEST_PRIORITY 500
58 #define ASR_BEEP_FOCUS_RELEASE_PRIORITY 400
60 #define MEDIA_FOCUS_TYPE "Media"
61 #define MEDIA_FOCUS_REQUEST_PRIORITY 300
62 #define MEDIA_FOCUS_RELEASE_PRIORITY 500
64 #define SOUND_FOCUS_TYPE "Sound"
65 #define SOUND_FOCUS_REQUEST_PRIORITY 500
66 #define SOUND_FOCUS_RELEASE_PRIORITY 500
68 #define DUMMY_FOCUS_TYPE "Dummy"
69 #define DUMMY_FOCUS_REQUEST_PRIORITY 600
70 #define DUMMY_FOCUS_RELEASE_PRIORITY 500
75 enum class FocusState {
76  FOREGROUND,
77  BACKGROUND,
78  NONE
79 };
80 
84 typedef struct _FocusConfiguration {
85  std::string type;
86  int priority;
88 
94 public:
95  virtual ~IFocusResourceListener() = default;
96 
101  virtual void onFocusChanged(FocusState state) = 0;
102 };
103 
109 public:
110  virtual ~IFocusManagerObserver() = default;
111 
118  virtual void onFocusChanged(const FocusConfiguration& configuration, FocusState state, const std::string& name) = 0;
119 };
120 
127 public:
135  virtual bool requestFocus(const std::string& type, const std::string& name, IFocusResourceListener* listener) = 0;
136 
143  virtual bool releaseFocus(const std::string& type, const std::string& name) = 0;
144 
150  virtual bool holdFocus(const std::string& type) = 0;
151 
157  virtual bool unholdFocus(const std::string& type) = 0;
158 
164  virtual void setConfigurations(std::vector<FocusConfiguration>& request, std::vector<FocusConfiguration>& release) = 0;
165 
169  virtual void stopAllFocus() = 0;
170 
174  virtual void stopForegroundFocus() = 0;
175 
181  virtual std::string getStateString(FocusState state) = 0;
182 
189  virtual FocusState convertToFocusState(const std::string& state_text) = 0;
190 
195  virtual void addObserver(IFocusManagerObserver* observer) = 0;
196 
201  virtual void removeObserver(IFocusManagerObserver* observer) = 0;
202 };
203 
204 } // NuguClientKit
205 
206 #endif /* __NUGU_FOCUS_MANAGER_INTERFACE_H__ */
IFocusManagerObserver.
Definition: focus_manager_interface.hh:108
IFocusManager.
Definition: focus_manager_interface.hh:126
IFocusResourceListener.
Definition: focus_manager_interface.hh:93
FocusState
FocusState.
Definition: focus_manager_interface.hh:75
virtual void removeObserver(IFocusManagerObserver *observer)=0
Remove the Observer object.
virtual void onFocusChanged(FocusState state)=0
Notify the resource of focus state change.
virtual bool unholdFocus(const std::string &type)=0
Unhold focus.
struct NuguClientKit::_FocusConfiguration FocusConfiguration
FocusConfiguration.
virtual void stopForegroundFocus()=0
Stop highest priority of focus that is foreground state.
virtual bool holdFocus(const std::string &type)=0
Hold focus. If requested to hold focus, the low priority focus is not preempted.
std::string type
Definition: focus_manager_interface.hh:85
virtual FocusState convertToFocusState(const std::string &state_text)=0
Convert state text to matched FocusState enum.
int priority
Definition: focus_manager_interface.hh:86
virtual void addObserver(IFocusManagerObserver *observer)=0
Add the Observer object.
virtual std::string getStateString(FocusState state)=0
Get state string.
virtual bool requestFocus(const std::string &type, const std::string &name, IFocusResourceListener *listener)=0
Request Focus.
virtual void stopAllFocus()=0
Stop all focus.
virtual void onFocusChanged(const FocusConfiguration &configuration, FocusState state, const std::string &name)=0
Support to monitor the change of focus state for all resources.
virtual void setConfigurations(std::vector< FocusConfiguration > &request, std::vector< FocusConfiguration > &release)=0
Set focus configurations.
virtual bool releaseFocus(const std::string &type, const std::string &name)=0
Release focus.
FocusConfiguration.
Definition: focus_manager_interface.hh:84