NUGU SDK Linux  1.7.6
capability_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_CAPABILITY_INTERFACE_H__
18 #define __NUGU_CAPABILITY_INTERFACE_H__
19 
20 #include <functional>
21 #include <list>
22 #include <njson/njson.h>
23 #include <set>
24 #include <string>
25 
26 #include <base/nugu_directive.h>
28 #include <nugu.h>
29 
30 namespace NuguClientKit {
31 
46 typedef struct _DirectiveCancelPolicy {
47  bool cancel_all;
48  std::set<std::string> dir_groups;
50 
54 class NUGU_API ICapabilityInterface;
55 
60 class NUGU_API ICapabilityListener {
61 public:
62  virtual ~ICapabilityListener() = default;
63 
69 
75 };
76 
82 class NUGU_API ICapabilityInterface {
83 public:
87  enum class SuspendPolicy {
88  STOP,
89  PAUSE
90  };
91 
100  using EventResultCallback = std::function<void(const std::string&, const std::string&, const std::string&, int, int)>;
101 
102 public:
103  virtual ~ICapabilityInterface() = default;
104 
109  virtual void setNuguCoreContainer(INuguCoreContainer* core_container) = 0;
110 
114  virtual void initialize() = 0;
115 
119  virtual void deInitialize() = 0;
120 
125  virtual void setSuspendPolicy(SuspendPolicy policy = SuspendPolicy::STOP) = 0;
126 
130  virtual void suspend() = 0;
131 
135  virtual void restore() = 0;
136 
142  virtual void addEventResultCallback(const std::string& ename, EventResultCallback callback) = 0;
143 
148  virtual void removeEventResultCallback(const std::string& ename) = 0;
149 
154  virtual void notifyEventResult(const std::string& event_desc) = 0;
155 
162  virtual void notifyEventResponse(const std::string& msg_id, const std::string& data, bool success) = 0;
163 
168  virtual std::string getName() = 0;
169 
174  virtual std::string getVersion() = 0;
175 
180  virtual void preprocessDirective(NuguDirective* ndir) = 0;
181 
186  virtual void cancelDirective(NuguDirective* ndir) = 0;
187 
192  virtual void processDirective(NuguDirective* ndir) = 0;
193 
198  virtual void updateInfoForContext(NJson::Value& ctx) = 0;
199 
204  virtual void updateCompactContext(NJson::Value& ctx) = 0;
205 
215  virtual bool receiveCommand(const std::string& from, const std::string& command, const std::string& param) = 0;
216 
222  virtual void receiveCommandAll(const std::string& command, const std::string& param) = 0;
223 
232  virtual bool getProperty(const std::string& property, std::string& value) = 0;
233 
242  virtual bool getProperties(const std::string& property, std::list<std::string>& values) = 0;
243 
248  virtual void setCapabilityListener(ICapabilityListener* clistener) = 0;
249 
255  virtual void setCancelPolicy(bool cancel_previous_dialog, DirectiveCancelPolicy&& cancel_policy = { true }) = 0;
256 };
257 
262 } // NuguClientKit
263 
264 #endif /* __NUGU_CAPABILITY_INTERFACE_H__ */
capability interface
Definition: capability_interface.hh:82
virtual void deInitialize()=0
Deinitialize the current object.
virtual void updateInfoForContext(NJson::Value &ctx)=0
Update the current context information of the capability agent.
SuspendPolicy
Capability suspend policy.
Definition: capability_interface.hh:87
virtual void notifyEventResult(const std::string &event_desc)=0
Notify event result.
virtual void preprocessDirective(NuguDirective *ndir)=0
Receive a directive preprocessing request from Directive sequencer.
virtual void processDirective(NuguDirective *ndir)=0
Receive a directive processing request from Directive sequencer.
virtual void setCancelPolicy(bool cancel_previous_dialog, DirectiveCancelPolicy &&cancel_policy={ true })=0
Set directive cancel policy.
virtual void initialize()=0
Initialize the current object.
virtual void updateCompactContext(NJson::Value &ctx)=0
Update the compact context information of the capability agent.
virtual std::string getVersion()=0
Get the capability version of the current object.
virtual bool getProperty(const std::string &property, std::string &value)=0
It is possible to share own property value among objects.
virtual void notifyEventResponse(const std::string &msg_id, const std::string &data, bool success)=0
Notify event response info.
std::function< void(const std::string &, const std::string &, const std::string &, int, int)> EventResultCallback
Event result callback for error handling.
Definition: capability_interface.hh:100
virtual bool getProperties(const std::string &property, std::list< std::string > &values)=0
It is possible to share own property values among objects.
virtual void cancelDirective(NuguDirective *ndir)=0
Receive a directive cancellation from the Directive sequencer.
virtual void removeEventResultCallback(const std::string &ename)=0
Remove event result callback.
virtual void setSuspendPolicy(SuspendPolicy policy=SuspendPolicy::STOP)=0
Set capability suspend policy.
virtual void receiveCommandAll(const std::string &command, const std::string &param)=0
Process command received from capability manager.
virtual void setCapabilityListener(ICapabilityListener *clistener)=0
Set the listener object.
virtual bool receiveCommand(const std::string &from, const std::string &command, const std::string &param)=0
Process command from other objects.
virtual void restore()=0
Restore previous suspended action.
virtual void suspend()=0
Suspend current action.
virtual void addEventResultCallback(const std::string &ename, EventResultCallback callback)=0
Add event result callback for error handling.
virtual std::string getName()=0
Get the capability name of the current object.
virtual void setNuguCoreContainer(INuguCoreContainer *core_container)=0
Set INuguCoreContainer for using functions in NuguCore.
capability listener interface
Definition: capability_interface.hh:60
virtual ICapabilityInterface * getCapabilityHandler()
Get capability interface object.
virtual void setCapabilityHandler(ICapabilityInterface *handler)
Set capability interface object.
NuguCoreContainer interface.
Definition: nugu_core_container_interface.hh:44
class NUGU_API ICapabilityInterface
capability interface
Definition: capability_interface.hh:54
struct NuguClientKit::_DirectiveCancelPolicy DirectiveCancelPolicy
Policy about canceling directives which are belong to the specific dialog id.
struct _nugu_directive NuguDirective
Directive object.
Definition: nugu_directive.h:48
Policy about canceling directives which are belong to the specific dialog id.
Definition: capability_interface.hh:46
bool cancel_all
Definition: capability_interface.hh:47
std::set< std::string > dir_groups
Definition: capability_interface.hh:48