NUGU SDK Linux  1.7.6
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 #include <nugu.h>
24 
25 namespace NuguClientKit {
26 
38 #define CALL_FOCUS_TYPE "Call"
39 #define CALL_FOCUS_REQUEST_PRIORITY 100
40 #define CALL_FOCUS_RELEASE_PRIORITY 100
42 #define ASR_USER_FOCUS_TYPE "ASRUser"
43 #define ASR_USER_FOCUS_REQUEST_PRIORITY 100
44 #define ASR_USER_FOCUS_RELEASE_PRIORITY 200
46 #define ASR_DM_FOCUS_TYPE "ASRDM"
47 #define ASR_DM_FOCUS_REQUEST_PRIORITY 400
48 #define ASR_DM_FOCUS_RELEASE_PRIORITY 300
50 #define INFO_FOCUS_TYPE "Info"
51 #define INFO_FOCUS_REQUEST_PRIORITY 200
52 #define INFO_FOCUS_RELEASE_PRIORITY 300
54 #define ALERTS_FOCUS_TYPE "Alerts"
55 #define ALERTS_FOCUS_REQUEST_PRIORITY 200
56 #define ALERTS_FOCUS_RELEASE_PRIORITY 300
58 #define ASR_BEEP_FOCUS_TYPE "ASRBeep"
59 #define ASR_BEEP_FOCUS_REQUEST_PRIORITY 500
60 #define ASR_BEEP_FOCUS_RELEASE_PRIORITY 400
62 #define MEDIA_FOCUS_TYPE "Media"
63 #define MEDIA_FOCUS_REQUEST_PRIORITY 300
64 #define MEDIA_FOCUS_RELEASE_PRIORITY 500
66 #define SOUND_FOCUS_TYPE "Sound"
67 #define SOUND_FOCUS_REQUEST_PRIORITY 500
68 #define SOUND_FOCUS_RELEASE_PRIORITY 500
70 #define DUMMY_FOCUS_TYPE "Dummy"
71 #define DUMMY_FOCUS_REQUEST_PRIORITY 600
72 #define DUMMY_FOCUS_RELEASE_PRIORITY 500
77 enum class FocusState {
78  FOREGROUND,
79  BACKGROUND,
80  NONE
81 };
82 
86 typedef struct _FocusConfiguration {
87  std::string type;
88  int priority;
90 
95 class NUGU_API IFocusResourceListener {
96 public:
97  virtual ~IFocusResourceListener() = default;
98 
103  virtual void onFocusChanged(FocusState state) = 0;
104 };
105 
110 class NUGU_API IFocusManagerObserver {
111 public:
112  virtual ~IFocusManagerObserver() = default;
113 
120  virtual void onFocusChanged(const FocusConfiguration& configuration, FocusState state, const std::string& name) = 0;
121 };
122 
128 class NUGU_API IFocusManager {
129 public:
137  virtual bool requestFocus(const std::string& type, const std::string& name, IFocusResourceListener* listener) = 0;
138 
145  virtual bool releaseFocus(const std::string& type, const std::string& name) = 0;
146 
152  virtual bool holdFocus(const std::string& type) = 0;
153 
159  virtual bool unholdFocus(const std::string& type) = 0;
160 
166  virtual void setConfigurations(std::vector<FocusConfiguration>& request, std::vector<FocusConfiguration>& release) = 0;
167 
171  virtual void stopAllFocus() = 0;
172 
176  virtual void stopForegroundFocus() = 0;
177 
183  virtual std::string getStateString(FocusState state) = 0;
184 
191  virtual FocusState convertToFocusState(const std::string& state_text) = 0;
192 
197  virtual void addObserver(IFocusManagerObserver* observer) = 0;
198 
203  virtual void removeObserver(IFocusManagerObserver* observer) = 0;
204 };
205 
206 } // NuguClientKit
207 
208 #endif /* __NUGU_FOCUS_MANAGER_INTERFACE_H__ */
IFocusManagerObserver.
Definition: focus_manager_interface.hh:110
IFocusManager.
Definition: focus_manager_interface.hh:128
IFocusResourceListener.
Definition: focus_manager_interface.hh:95
FocusState
FocusState.
Definition: focus_manager_interface.hh:77
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:87
virtual FocusState convertToFocusState(const std::string &state_text)=0
Convert state text to matched FocusState enum.
int priority
Definition: focus_manager_interface.hh:88
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:86