NUGU SDK Linux  1.7.5
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 
29 namespace NuguClientKit {
30 
45 typedef struct _DirectiveCancelPolicy {
46  bool cancel_all;
47  std::set<std::string> dir_groups;
49 
53 class ICapabilityInterface;
54 
60 public:
61  virtual ~ICapabilityListener() = default;
62 
68 
74 };
75 
82 public:
86  enum class SuspendPolicy {
87  STOP,
88  PAUSE
89  };
90 
99  using EventResultCallback = std::function<void(const std::string&, const std::string&, const std::string&, int, int)>;
100 
101 public:
102  virtual ~ICapabilityInterface() = default;
103 
108  virtual void setNuguCoreContainer(INuguCoreContainer* core_container) = 0;
109 
113  virtual void initialize() = 0;
114 
118  virtual void deInitialize() = 0;
119 
125 
129  virtual void suspend() = 0;
130 
134  virtual void restore() = 0;
135 
141  virtual void addEventResultCallback(const std::string& ename, EventResultCallback callback) = 0;
142 
147  virtual void removeEventResultCallback(const std::string& ename) = 0;
148 
153  virtual void notifyEventResult(const std::string& event_desc) = 0;
154 
161  virtual void notifyEventResponse(const std::string& msg_id, const std::string& data, bool success) = 0;
162 
167  virtual std::string getName() = 0;
168 
173  virtual std::string getVersion() = 0;
174 
179  virtual void preprocessDirective(NuguDirective* ndir) = 0;
180 
185  virtual void cancelDirective(NuguDirective* ndir) = 0;
186 
191  virtual void processDirective(NuguDirective* ndir) = 0;
192 
197  virtual void updateInfoForContext(NJson::Value& ctx) = 0;
198 
203  virtual void updateCompactContext(NJson::Value& ctx) = 0;
204 
214  virtual bool receiveCommand(const std::string& from, const std::string& command, const std::string& param) = 0;
215 
221  virtual void receiveCommandAll(const std::string& command, const std::string& param) = 0;
222 
231  virtual bool getProperty(const std::string& property, std::string& value) = 0;
232 
241  virtual bool getProperties(const std::string& property, std::list<std::string>& values) = 0;
242 
247  virtual void setCapabilityListener(ICapabilityListener* clistener) = 0;
248 
254  virtual void setCancelPolicy(bool cancel_previous_dialog, DirectiveCancelPolicy&& cancel_policy = { true }) = 0;
255 };
256 
261 } // NuguClientKit
262 
263 #endif /* __NUGU_CAPABILITY_INTERFACE_H__ */
capability interface
Definition: capability_interface.hh:81
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:86
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:99
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:59
virtual ICapabilityInterface * getCapabilityHandler()
Get capability interface object.
virtual void setCapabilityHandler(ICapabilityInterface *handler)
Set capability interface object.
NuguCoreContainer interface.
Definition: nugu_core_container_interface.hh:43
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:47
Policy about canceling directives which are belong to the specific dialog id.
Definition: capability_interface.hh:45
bool cancel_all
Definition: capability_interface.hh:46
std::set< std::string > dir_groups
Definition: capability_interface.hh:47