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
VirtualDevice.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
3  *
4  * This software is dual-licensed to you under the MIT License (MIT) and
5  * the Universal Permissive License (UPL). See the LICENSE file in the root
6  * directory for license terms. You may choose either license, or both.
7  */
8 
9 #pragma once
10 
12 #include <Alert.hpp>
13 #include <Data.hpp>
14 #include <string>
15 #include "iotcs_virtual_device.h"
16 #include "iotcs_config.h"
17 #include <NamedValue.hpp>
18 #include <vector>
19 #include <stdexcept>
20 
21 #ifdef __GNUC__
22 #define DEPRECATED(func,msg) func __attribute__ ((deprecated(msg))) = 0
23 #elif defined(_MSC_VER)
24 #define DEPRECATED(func,msg) __declspec(deprecated(msg)) func = 0
25 #else
26 #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
27 #define DEPRECATED(func) func
28 #endif
29 
35 namespace iotdcl {
36  class Callable;
37 
38  class VirtualDevice: public AbstractVirtualDevice<VirtualDevice> {
39  public:
40  virtual ~VirtualDevice();
57  template <typename T> VirtualDevice& set(const std::string &attributeName, const T& value) throw(std::invalid_argument);
58 
59 #if defined IOTCS_IMPLICIT_EDGE_COMPUTING || defined IOTCS_DOXYGEN
60 
73  template <typename T> VirtualDevice& offer(const std::string &attributeName, const T& value) throw(std::invalid_argument);
74 #endif
75 
91  VirtualDevice& set(const std::string &attributeName, StorageObject* value) throw(std::invalid_argument);
92 
102  template <typename T> T get(const std::string &attributeName);
109  virtual Alert& createAlert(const std::string &format) = 0;
116  virtual Data& createData(const std::string &format) = 0;
128  virtual void setOnAction(const std::string &actionName, const ActionCallback *callback) = 0;
129 
140  virtual void setOnAction(const ActionCallback *callback) = 0;
141 
147  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)");
148  protected:
149  iotcs_virtual_device_handle handle;
150  std::vector<StorageObject*> eo_list;
151  };
156  class Callable {
157  public:
168  virtual void call( VirtualDevice *virtualDevice, const NamedValue &data) const = 0;
172  virtual ~Callable() {
173  }
174  };
175 };
virtual void call(VirtualDevice *virtualDevice, const NamedValue &data) const =0
The method called for handling a device model action.
Callback interface for actions in the device model.
Definition: VirtualDevice.hpp:156
VirtualDevice & offer(const std::string &attributeName, const T &value)
Offer to set the value of an attribute.
Represents a set of custom data fields (key/value pair) to be sent to the server. ...
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.
An Alert to be sent to the server.
virtual Data & createData(const std::string &format)=0
Create a custom iotdcl::Data object for this VirtualDevice.
Definition: NamedValue.hpp:24
virtual ~Callable()
Desctructor.
Definition: VirtualDevice.hpp:172
Definition: VirtualDevice.hpp:38
VirtualDevice & set(const std::string &attributeName, const T &value)
Set the value of an attribute.
A callback interface for receiving notification of an Action.
Definition: AbstractVirtualDevice.hpp:99
Definition: Data.hpp:37
virtual Alert & createAlert(const std::string &format)=0
Create an iotdcl::Alert for this VirtualDevice.
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.
AbstractVirtualDevice is a representation of a device model implemented by an endpoint.
Definition: AbstractVirtualDevice.hpp:202
Definition: Alert.hpp:35
Definition: StorageObject.hpp:158