NUGU SDK Linux  1.7.6
NuguClientKit::Capability Class Reference

Capability. More...

#include <capability.hh>

+ Inheritance diagram for NuguClientKit::Capability:
+ Collaboration diagram for NuguClientKit::Capability:

Public Member Functions

void addBlockingPolicy (const std::string &dname, BlockingPolicy policy)
 Add blocking policy for directive name. More...
 
void addEventResultCallback (const std::string &ename, EventResultCallback callback) override
 Add event result callback for error handling. More...
 
void addReferrerEvents (const std::string &ename, const std::string &dname)
 Add event name and directive name for referred dialog request id. More...
 
void cancelDirective (NuguDirective *ndir) override
 Receive a directive cancellation from the Directive sequencer. More...
 
 Capability (const std::string &name, const std::string &ver="1.0")
 
void deInitialize () override
 Deinitialize the current object.
 
void destroyDirective (NuguDirective *ndir, bool is_cancel=false)
 Destroy directive received from Directive Sequencer. More...
 
ICapabilityHelpergetCapabilityHelper ()
 Get ICapabilityHelper instance for using NuguCore functions. More...
 
virtual std::string getContextInfo ()
 Get current context info. More...
 
InteractionMode getInteractionMode (const NJson::Value &interaction_control)
 Get interaction mode which is included in interactionControl. More...
 
std::string getName () override
 Get the capability name of the current object. More...
 
NuguDirectivegetNuguDirective ()
 Get directive received from Directive Sequencer. More...
 
std::string getPlayServiceIdInStackControl (const char *payload)
 Get play service id which is managed by play stack control. More...
 
std::string getPlayServiceIdInStackControl (const NJson::Value &playstack_control)
 Get play service id which is managed by play stack control. More...
 
bool getProperties (const std::string &property, std::list< std::string > &values) override
 It is possible to share own property values among objects. More...
 
bool getProperty (const std::string &property, std::string &value) override
 It is possible to share own property value among objects. More...
 
std::string getReferrerDialogRequestId (const std::string &ename)
 Get referred dialog request id. More...
 
std::string getVersion () override
 Get the capability version of the current object. More...
 
void initialize () override
 Initialize the current object.
 
void notifyEventResponse (const std::string &msg_id, const std::string &data, bool success) override
 Notify event response info. More...
 
void notifyEventResult (const std::string &event_desc) override
 Notify event result. More...
 
virtual void parsingDirective (const char *dname, const char *message)
 Parsing directive and do the required action. More...
 
void preprocessDirective (NuguDirective *ndir) override
 Receive a directive preprocessing request from Directive sequencer. More...
 
void processDirective (NuguDirective *ndir) override final
 Receive a directive processing request from Directive sequencer. More...
 
bool receiveCommand (const std::string &from, const std::string &command, const std::string &param) override
 Process command from other objects. More...
 
void receiveCommandAll (const std::string &command, const std::string &param) override
 Process command received from capability manager. More...
 
void removeEventResultCallback (const std::string &ename) override
 Remove event result callback. More...
 
void restore () override
 Restore previous suspended action.
 
void sendAttachmentEvent (CapabilityEvent *event, bool is_end, size_t size, unsigned char *data)
 Send attachment event to server. More...
 
void sendEvent (CapabilityEvent *event, const std::string &context, const std::string &payload, EventResultCallback cb=nullptr)
 Send event to server. More...
 
std::string sendEvent (const std::string &name, const std::string &context, const std::string &payload, EventResultCallback cb=nullptr)
 Send event to server. More...
 
void setCancelPolicy (bool cancel_previous_dialog, DirectiveCancelPolicy &&cancel_policy={ true }) override
 Set directive cancel policy. More...
 
void setCapabilityListener (ICapabilityListener *clistener) override
 Set the listener object. More...
 
void setName (const std::string &name)
 Set the capability name of the current object. More...
 
void setNuguCoreContainer (INuguCoreContainer *core_container) override
 Set INuguCoreContainer for using functions in NuguCore. More...
 
void setReferrerDialogRequestId (const std::string &dname, const std::string &id)
 Set referred dialog request id. More...
 
void setSuspendPolicy (SuspendPolicy policy=SuspendPolicy::STOP) override
 Set capability suspend policy. More...
 
void setVersion (const std::string &ver)
 Set the capability version of the current object. More...
 
void suspend () override
 Suspend current action.
 
virtual void updateCompactContext (NJson::Value &ctx) override
 Update the compact context information of the capability agent. More...
 
- Public Member Functions inherited from NuguClientKit::ICapabilityInterface
virtual void updateInfoForContext (NJson::Value &ctx)=0
 Update the current context information of the capability agent. More...
 

Protected Attributes

ICapabilityHelpercapa_helper = nullptr
 ICapabilityHelper instance for using NuguCore functions.
 
INuguCoreContainercore_container = nullptr
 INuguCoreContainer instance for using NuguCore functions.
 
bool destroy_directive_by_agent = false
 whether destroy received directive by agent
 
IDirectiveSequencerdirective_sequencer = nullptr
 IDirectiveSequencer instance for directive sequence management.
 
IFocusManagerfocus_manager = nullptr
 IFocusManager instance for using audio focus.
 
bool initialized = false
 whether capability initialized
 
IInteractionControlManagerinteraction_control_manager = nullptr
 IInteractionControlManager instance for using interaction control management.
 
IPlaySyncManagerplaysync_manager = nullptr
 IPlaySyncManager instance for using playsync management.
 
IRoutineManagerroutine_manager = nullptr
 IRoutineManager instance for using routine management.
 
ISessionManagersession_manager = nullptr
 ISessionManager instance for using session management.
 
SuspendPolicy suspend_policy = SuspendPolicy::STOP
 SuspendPolicy variable for deciding suspend action (default:STOP)
 
bool suspended = false
 whether capability suspend
 

Additional Inherited Members

- Public Types inherited from NuguClientKit::ICapabilityInterface
using EventResultCallback = std::function< void(const std::string &, const std::string &, const std::string &, int, int)>
 Event result callback for error handling. More...
 
enum class  SuspendPolicy { STOP , PAUSE }
 Capability suspend policy. More...
 

Detailed Description

Member Function Documentation

◆ setNuguCoreContainer()

void NuguClientKit::Capability::setNuguCoreContainer ( INuguCoreContainer core_container)
overridevirtual

Set INuguCoreContainer for using functions in NuguCore.

Parameters
[in]core_containerNuguCoreContainer instance

Implements NuguClientKit::ICapabilityInterface.

◆ setSuspendPolicy()

void NuguClientKit::Capability::setSuspendPolicy ( SuspendPolicy  policy = SuspendPolicy::STOP)
overridevirtual

Set capability suspend policy.

Parameters
[in]policysuspend policy

Implements NuguClientKit::ICapabilityInterface.

◆ addEventResultCallback()

void NuguClientKit::Capability::addEventResultCallback ( const std::string &  ename,
EventResultCallback  callback 
)
overridevirtual

Add event result callback for error handling.

Parameters
[in]enameevent name
[in]callbackevent result callback

Implements NuguClientKit::ICapabilityInterface.

◆ removeEventResultCallback()

void NuguClientKit::Capability::removeEventResultCallback ( const std::string &  ename)
overridevirtual

Remove event result callback.

Parameters
[in]enameevent name

Implements NuguClientKit::ICapabilityInterface.

◆ notifyEventResult()

void NuguClientKit::Capability::notifyEventResult ( const std::string &  event_desc)
overridevirtual

Notify event result.

Parameters
[in]event_descevent result description (format: 'cname.ename.msgid.dialogid.success.code')

Implements NuguClientKit::ICapabilityInterface.

◆ notifyEventResponse()

void NuguClientKit::Capability::notifyEventResponse ( const std::string &  msg_id,
const std::string &  data,
bool  success 
)
overridevirtual

Notify event response info.

Parameters
[in]msg_idmessage id which is sent with event
[in]dataraw data which is received from server about event (json format)
[in]successwhether receive event response

Implements NuguClientKit::ICapabilityInterface.

◆ addReferrerEvents()

void NuguClientKit::Capability::addReferrerEvents ( const std::string &  ename,
const std::string &  dname 
)

Add event name and directive name for referred dialog request id.

Parameters
[in]enameevent name
[in]dnamedirective name

◆ addBlockingPolicy()

void NuguClientKit::Capability::addBlockingPolicy ( const std::string &  dname,
BlockingPolicy  policy 
)

Add blocking policy for directive name.

Parameters
[in]dnamedirective name
[in]policyBlockingPolicy information

◆ getReferrerDialogRequestId()

std::string NuguClientKit::Capability::getReferrerDialogRequestId ( const std::string &  ename)

Get referred dialog request id.

Parameters
[in]enameevent name
Returns
referred dialog request id

◆ setReferrerDialogRequestId()

void NuguClientKit::Capability::setReferrerDialogRequestId ( const std::string &  dname,
const std::string &  id 
)

Set referred dialog request id.

Parameters
[in]dnamedirective name
[in]idreferred dialog request id

◆ setName()

void NuguClientKit::Capability::setName ( const std::string &  name)

Set the capability name of the current object.

Parameters
[in]namecapability name

◆ getName()

std::string NuguClientKit::Capability::getName ( )
overridevirtual

Get the capability name of the current object.

Returns
capability name of the object

Implements NuguClientKit::ICapabilityInterface.

◆ setVersion()

void NuguClientKit::Capability::setVersion ( const std::string &  ver)

Set the capability version of the current object.

Parameters
[in]vercapability version

◆ getVersion()

std::string NuguClientKit::Capability::getVersion ( )
overridevirtual

Get the capability version of the current object.

Returns
capability version of the object

Implements NuguClientKit::ICapabilityInterface.

◆ getPlayServiceIdInStackControl() [1/2]

std::string NuguClientKit::Capability::getPlayServiceIdInStackControl ( const NJson::Value &  playstack_control)

Get play service id which is managed by play stack control.

Parameters
[in]playstack_controljson object which has playStackControl field
Returns
current play service id

◆ getPlayServiceIdInStackControl() [2/2]

std::string NuguClientKit::Capability::getPlayServiceIdInStackControl ( const char *  payload)

Get play service id which is managed by play stack control.

  • Parameters
    [in]payloadraw json data
    Returns
    current play service id

◆ getInteractionMode()

InteractionMode NuguClientKit::Capability::getInteractionMode ( const NJson::Value &  interaction_control)

Get interaction mode which is included in interactionControl.

Returns
interaction mode (NONE, MULTI_TURN,...)

◆ preprocessDirective()

void NuguClientKit::Capability::preprocessDirective ( NuguDirective ndir)
overridevirtual

Receive a directive preprocessing request from Directive sequencer.

Parameters
[in]ndirdirective

Implements NuguClientKit::ICapabilityInterface.

◆ cancelDirective()

void NuguClientKit::Capability::cancelDirective ( NuguDirective ndir)
overridevirtual

Receive a directive cancellation from the Directive sequencer.

Parameters
[in]ndirdirective

Implements NuguClientKit::ICapabilityInterface.

◆ processDirective()

void NuguClientKit::Capability::processDirective ( NuguDirective ndir)
finaloverridevirtual

Receive a directive processing request from Directive sequencer.

Parameters
[in]ndirdirective

Implements NuguClientKit::ICapabilityInterface.

◆ destroyDirective()

void NuguClientKit::Capability::destroyDirective ( NuguDirective ndir,
bool  is_cancel = false 
)

Destroy directive received from Directive Sequencer.

Parameters
[in]ndirdirective
[in]is_cancelwhether to destroy by cancel

◆ getNuguDirective()

NuguDirective* NuguClientKit::Capability::getNuguDirective ( )

Get directive received from Directive Sequencer.

Returns
received directive

◆ sendEvent() [1/2]

std::string NuguClientKit::Capability::sendEvent ( const std::string &  name,
const std::string &  context,
const std::string &  payload,
EventResultCallback  cb = nullptr 
)

Send event to server.

Parameters
[in]nameevent name
[in]contextcontext info
[in]payloadpayload info
Returns
event's request dialog id

◆ sendEvent() [2/2]

void NuguClientKit::Capability::sendEvent ( CapabilityEvent event,
const std::string &  context,
const std::string &  payload,
EventResultCallback  cb = nullptr 
)

Send event to server.

Parameters
[in]eventCapabilityEvent instance
[in]contextcontext info
[in]payloadpayload info

◆ sendAttachmentEvent()

void NuguClientKit::Capability::sendAttachmentEvent ( CapabilityEvent event,
bool  is_end,
size_t  size,
unsigned char *  data 
)

Send attachment event to server.

Parameters
[in]eventCapabilityEvent instance
[in]is_endwhether final attachment event
[in]sizeattachment data size
[in]dataattachment data

◆ getProperty()

bool NuguClientKit::Capability::getProperty ( const std::string &  property,
std::string &  value 
)
overridevirtual

It is possible to share own property value among objects.

Parameters
[in]propertycapability property
[in]valuecapability property value
Returns
property get result
Return values
trueThe property is valid
falseThe property is invalid

Implements NuguClientKit::ICapabilityInterface.

◆ getProperties()

bool NuguClientKit::Capability::getProperties ( const std::string &  property,
std::list< std::string > &  values 
)
overridevirtual

It is possible to share own property values among objects.

Parameters
[in]propertycapability property
[in]valuescapability property values
Returns
property get result
Return values
trueThe property is valid
falseThe property is invalid

Implements NuguClientKit::ICapabilityInterface.

◆ setCapabilityListener()

void NuguClientKit::Capability::setCapabilityListener ( ICapabilityListener clistener)
overridevirtual

Set the listener object.

Parameters
[in]clistenerlistener

Implements NuguClientKit::ICapabilityInterface.

◆ setCancelPolicy()

void NuguClientKit::Capability::setCancelPolicy ( bool  cancel_previous_dialog,
DirectiveCancelPolicy &&  cancel_policy = { true } 
)
overridevirtual

Set directive cancel policy.

Parameters
[in]cancel_previous_dialogwhether canceling previous dialog or not
[in]cancel_policypolicy object

Implements NuguClientKit::ICapabilityInterface.

◆ receiveCommand()

bool NuguClientKit::Capability::receiveCommand ( const std::string &  from,
const std::string &  command,
const std::string &  param 
)
overridevirtual

Process command from other objects.

Parameters
[in]fromcapability who send the command
[in]commandcommand
[in]paramcommand parameter
Returns
command result
Return values
trueThe command is valid
falseThe command is invalid

Implements NuguClientKit::ICapabilityInterface.

◆ receiveCommandAll()

void NuguClientKit::Capability::receiveCommandAll ( const std::string &  command,
const std::string &  param 
)
overridevirtual

Process command received from capability manager.

Parameters
[in]commandcommand
[in]paramcommand parameter

Implements NuguClientKit::ICapabilityInterface.

◆ parsingDirective()

virtual void NuguClientKit::Capability::parsingDirective ( const char *  dname,
const char *  message 
)
virtual

Parsing directive and do the required action.

Parameters
[in]dnamedirective name
[in]messagedirective data

◆ getContextInfo()

virtual std::string NuguClientKit::Capability::getContextInfo ( )
virtual

Get current context info.

Returns
context info

◆ updateCompactContext()

virtual void NuguClientKit::Capability::updateCompactContext ( NJson::Value &  ctx)
overridevirtual

Update the compact context information of the capability agent.

Parameters
[in]ctxcapability agent's context

Implements NuguClientKit::ICapabilityInterface.

◆ getCapabilityHelper()

ICapabilityHelper* NuguClientKit::Capability::getCapabilityHelper ( )

Get ICapabilityHelper instance for using NuguCore functions.

Returns
ICapabilityHelper instance

The documentation for this class was generated from the following file: