CPP Device Virtualization API Reference for Oracle Internet of Things Cloud Service Client Software Library. Release 21.1.1.0.0-3. E92477-09
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
iotdcl::VirtualDevice Class Referenceabstract
+ Inheritance diagram for iotdcl::VirtualDevice:

Public Member Functions

template<typename T >
VirtualDeviceset (const std::string &attributeName, const T &value) throw (std::invalid_argument)
 Set the value of an attribute. More...
 
template<typename T >
VirtualDeviceoffer (const std::string &attributeName, const T &value) throw (std::invalid_argument)
 Offer to set the value of an attribute. More...
 
VirtualDeviceset (const std::string &attributeName, StorageObject *value) throw (std::invalid_argument)
 Set the value of an StorageObject attribute. More...
 
template<typename T >
get (const std::string &attributeName)
 Get the value of an attribute. More...
 
virtual AlertcreateAlert (const std::string &format)=0
 Create an iotdcl::Alert for this VirtualDevice. More...
 
virtual DatacreateData (const std::string &format)=0
 Create a custom iotdcl::Data object for this VirtualDevice. More...
 
virtual void setOnAction (const std::string &actionName, const ActionCallback *callback)=0
 Set a callback that is invoked when an action for the given name is received. More...
 
virtual void setOnAction (const ActionCallback *callback)=0
 Set a callback that is invoked when any action in the device model is received. More...
 
 DEPRECATED (virtual void setCallable(const std::string &actionName, const Callable *callback),"This API does not support actions with multiple arguments. Use setOnAction(std::string, iotdcl::ActionCallback)")
 Set callback for handling an action. More...
 
- Public Member Functions inherited from iotdcl::AbstractVirtualDevice< VirtualDevice >
virtual ~AbstractVirtualDevice ()
 Destructor.
 
virtual const DeviceModelgetDeviceModel ()=0
 Get the device model of this device object. More...
 
virtual const std::string & getEndpointId () const =0
 Get the endpoint id of the device. More...
 
VirtualDeviceset (const std::string &attributeName, T &value)
 Set the value of an attribute. More...
 
get (const std::string &attributeName)
 Get the value of an attribute. More...
 
virtual VirtualDeviceupdate (void)=0
 Set a mark for beginning an update transaction. More...
 
virtual void finish (void)=0
 Causes the values set in an update transaction to be sent to the server and clears the update-transaction mark. More...
 
virtual void setOnChange (const ChangeCallback *callback)=0
 Set a callback that is invoked when the value of any attribute in the device model is changed from the outside. More...
 
virtual void setOnChange (const std::string &attributeName, const ChangeCallback *callback)=0
 Set a callback that is invoked when the value of the given attribute in the device model is changed from the outside. More...
 
virtual void setOnError (const ErrorCallback *callback)=0
 Set a callback that is invoked if an error occurs when setting the value of any attribute in the device model, or an error occurs when raising an. More...
 
virtual void setOnError (const std::string &attributeName, const ErrorCallback *callback)=0
 Set a callback that is invoked if an error occurs when setting the value of any attribute in the device model or an error occurs when raising an. More...
 

Protected Attributes

iotcs_virtual_device_handle handle
 
std::vector< StorageObject * > eo_list
 

Member Function Documentation

virtual Alert& iotdcl::VirtualDevice::createAlert ( const std::string &  format)
pure virtual

Create an iotdcl::Alert for this VirtualDevice.

The alert will be created with the given format URN.

Parameters
formatthe alert format URN.
Returns
an iotdcl::Alert
virtual Data& iotdcl::VirtualDevice::createData ( const std::string &  format)
pure virtual

Create a custom iotdcl::Data object for this VirtualDevice.

The custom iotdcl::Data object will be created with the given format URN.

Parameters
formatthe custom data message format URN.
Returns
a custom iotdcl::Data object
iotdcl::VirtualDevice::DEPRECATED ( virtual void   setCallableconst std::string &actionName, const Callable *callback,
"This API does not support actions with multiple arguments. Use setOnAction(std::string, iotdcl::ActionCallback)"   
)

Set callback for handling an action.

Parameters
actionNameThe action name
callableThe interface to invoke
template<typename T >
T iotdcl::VirtualDevice::get ( const std::string &  attributeName)

Get the value of an attribute.

This method returns the current value held by the virtual device model. For an enterprise client, no REST API call is made to the server. For a device client, no call is made to the physical device.

Parameters
attributeNamethe name of an attribute from the device type model
Returns
the attribute value
template<typename T >
VirtualDevice& iotdcl::VirtualDevice::offer ( const std::string &  attributeName,
const T &  value 
)
throw (std::invalid_argument
)

Offer to set the value of an attribute.

The attribute value is set depending upon any policy that may have been configured for the attribute. If there is no policy for the given attribute, offer behaves as if the VirtualDevice::set() method were called. The value is validated according to the constraints in the device model.

Parameters
attributeNamethe name of an attribute from the device type model
valuethe value to set
Returns
this iotdcl::AbstractVirtualDevice instance
Exceptions
std::invalid_argumentif the value is not valid, or attributeName is NULL
template<typename T >
VirtualDevice& iotdcl::VirtualDevice::set ( const std::string &  attributeName,
const T &  value 
)
throw (std::invalid_argument
)

Set the value of an attribute.

This method is used by the application to synchronize the #AbstractVirtualDevice state with the physical device. This results in a REST API call to the server. For an enterprise client, an endpoint resource REST API call is made to the server. For a device client, an endpoint DATA message REST API call is made to the server. The value is validated according to the constraints in the device model.

Parameters
attributeNamethe name of an attribute from the device type model
valuethe value to set
Returns
this iotdcl::AbstractVirtualDevice instance
Exceptions
std::invalid_argumentif the value is not valid, or attributeName is NULL
VirtualDevice& iotdcl::VirtualDevice::set ( const std::string &  attributeName,
StorageObject value 
)
throw (std::invalid_argument
)

Set the value of an StorageObject attribute.

This method is used by the application to synchronize the #AbstractVirtualDevice state with the physical device. This results in a REST API call to the server. For an enterprise client, an endpoint resource REST API call is made to the server. For a device client, an endpoint DATA message REST API call is made to the server. The value is validated according to the constraints in the device model.

Parameters
attributeNamethe name of an attribute from the device type model
valueStorageObject value to set
Returns
this iotdcl::AbstractVirtualDevice instance
Exceptions
std::invalid_argumentif the value is not valid, or attributeName is NULL
virtual void iotdcl::VirtualDevice::setOnAction ( const std::string &  actionName,
const ActionCallback callback 
)
pure virtual

Set a callback that is invoked when an action for the given name is received.

Note that it is possible to set a callback for a specific action and to set a callback for all actions via setOnAction(iotdcl::ActionCallback). If there is a callback for the specific action and for all actions, both callbacks will be invoked, with the specific action invoked first.

Parameters
actionNameThe action name from the device model
callbacka callback to invoke when an action is received, if
null
, the existing callback will be removed
virtual void iotdcl::VirtualDevice::setOnAction ( const ActionCallback callback)
pure virtual

Set a callback that is invoked when any action in the device model is received.

Note that it is possible to set a callback for a specific action via setOnAction(std::string, iotdcl::ActionCallback). If there is a callback for the specific action and for all actions, both callbacks will be invoked, wiht the specific action invoked first.

Parameters
callbacka callback to invoke when an action is received, if
null
, the existing callback will be removed

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