NUGU SDK Linux  1.7.6
routine_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_ROUTINE_MANAGER_INTERFACE_H__
18 #define __NUGU_ROUTINE_MANAGER_INTERFACE_H__
19 
20 #include <functional>
21 #include <njson/njson.h>
22 
23 #include <base/nugu_directive.h>
24 #include <nugu.h>
25 
26 namespace NuguClientKit {
27 
42 enum class RoutineActivity {
43  IDLE,
44  PLAYING,
45  INTERRUPTED,
46  FINISHED,
47  STOPPED,
48  SUSPENDED
49 };
50 
55 class NUGU_API IRoutineManagerListener {
56 public:
57  virtual ~IRoutineManagerListener() = default;
58 
63  virtual void onActivity(RoutineActivity activity) = 0;
64 
69  virtual void onActionTimeout(bool last_action = false) = 0;
70 };
71 
76 class NUGU_API IRoutineManager {
77 public:
78  using TextRequester = std::function<std::string(const std::string&, const std::string&, const std::string&)>;
79  using DataRequester = std::function<std::string(const std::string&, const NJson::Value&)>;
80 
81 public:
82  virtual ~IRoutineManager() = default;
83 
88  virtual void addListener(IRoutineManagerListener* listener) = 0;
89 
94  virtual void removeListener(IRoutineManagerListener* listener) = 0;
95 
100  virtual void setTextRequester(TextRequester requester) = 0;
101 
106  virtual void setDataRequester(DataRequester requester) = 0;
107 
113  virtual bool start(const std::string& token, const NJson::Value& actions) = 0;
114 
118  virtual void stop() = 0;
119 
123  virtual void interrupt() = 0;
124 
128  virtual void resume() = 0;
129 
137  virtual bool move(unsigned int index) = 0;
138 
142  virtual void finish() = 0;
143 
148  virtual std::string getCurrentActionToken() = 0;
149 
154  virtual unsigned int getCurrentActionIndex() = 0;
155 
160  virtual unsigned int getCountableActionSize() = 0;
161 
166  virtual unsigned int getCountableActionIndex() = 0;
167 
172  virtual bool isActionValid(const NJson::Value& action) = 0;
173 
178  virtual bool isRoutineProgress() = 0;
179 
184  virtual bool isRoutineAlive() = 0;
185 
191  virtual bool isActionProgress(const std::string& dialog_id) = 0;
192 
198  virtual bool hasRoutineDirective(const NuguDirective* ndir) = 0;
199 
205  virtual bool isConditionToStop(const NuguDirective* ndir) = 0;
206 
212  virtual bool isConditionToFinishAction(const NuguDirective* ndir) = 0;
213 
219  virtual bool isConditionToCancel(const NuguDirective* ndir) = 0;
220 
227  virtual bool isMuteDelayed() = 0;
228 
232  virtual void presetActionTimeout() = 0;
233 
238  virtual void setPendingStop(const NuguDirective* ndir) = 0;
239 
247  virtual bool hasToSkipMedia(const std::string& dialog_id) = 0;
248 };
249 
254 } // NuguClientKit
255 
256 #endif /* __NUGU_ROUTINE_MANAGER_INTERFACE_H__ */
IRoutineManagerListener interface.
Definition: routine_manager_interface.hh:55
virtual void onActionTimeout(bool last_action=false)=0
Receive callback when the action timeout is ended.
virtual void onActivity(RoutineActivity activity)=0
Receive callback when the routine activity state is changed.
IRoutineManager interface.
Definition: routine_manager_interface.hh:76
virtual void interrupt()=0
Interrupt routine.
virtual bool isActionProgress(const std::string &dialog_id)=0
Check whether action is in progress currently.
virtual void setTextRequester(TextRequester requester)=0
Set TextRequester delegate for handling text type action.
virtual void setDataRequester(DataRequester requester)=0
Set DataRequester delegate for handling data type action.
virtual void presetActionTimeout()=0
Set default time (5 sec) when action timeout is not set.
virtual bool move(unsigned int index)=0
Move to the specific action and process.
virtual void resume()=0
Resume routine.
virtual void setPendingStop(const NuguDirective *ndir)=0
Set pending stop after checking whether Routine.Stop directive exists.
virtual bool hasRoutineDirective(const NuguDirective *ndir)=0
Check whether routine directive exist in NuguDirective.
virtual bool isRoutineProgress()=0
Check whether routine is in progress currently.
virtual void stop()=0
Stop routine.
virtual bool isConditionToCancel(const NuguDirective *ndir)=0
Check whether current condition is to cancel directive.
virtual bool start(const std::string &token, const NJson::Value &actions)=0
Start routine.
virtual bool isActionValid(const NJson::Value &action)=0
Check whether the action is valid.
virtual bool isMuteDelayed()=0
Check whether mute delay is processed.
virtual void addListener(IRoutineManagerListener *listener)=0
Add IRoutineManagerListener.
virtual unsigned int getCountableActionIndex()=0
Get index of current countable action.
virtual std::string getCurrentActionToken()=0
Get token of current active action.
virtual void finish()=0
Finish action.
virtual bool isRoutineAlive()=0
Check whether routine has remained action to execute.
virtual unsigned int getCurrentActionIndex()=0
Get index of current active action.
virtual bool isConditionToStop(const NuguDirective *ndir)=0
Check whether current condition is to stop routine.
virtual bool hasToSkipMedia(const std::string &dialog_id)=0
Check whether current condition should skip media play.
virtual bool isConditionToFinishAction(const NuguDirective *ndir)=0
Check whether current condition is possible to finish progressing action.
virtual void removeListener(IRoutineManagerListener *listener)=0
Remove IRoutineManagerListener.
virtual unsigned int getCountableActionSize()=0
Get size of countable actions.
struct _nugu_directive NuguDirective
Directive object.
Definition: nugu_directive.h:48
RoutineActivity
Routine Activity list.
Definition: routine_manager_interface.hh:42