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
Alert.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 
11 #include "iotcs_virtual_device.h"
12 #include <string>
13 #include <stdexcept>
14 #include <mutex>
15 #include <map>
16 #ifdef __MBED__
17 #include "mbed.h"
18 #include "rtos.h"
19 #define MUTEX_TYPE Mutex
20 #else
21 #define MUTEX_TYPE std::mutex
22 #endif
23 
34 namespace iotdcl {
35  class Alert {
36  public:
40  virtual ~Alert();
56  template <typename T> Alert& set(const std::string &attributeName, const T& value) throw(std::invalid_argument);
67  void raise(void) throw(std::invalid_argument);
68 
77  virtual void setOnError(ErrorCallback *callback);
78  protected:
79  Alert(VirtualDevice* device, iotcs_virtual_device_handle handler, const std::string &alertName) throw (std::invalid_argument);
80  static void onErrorCallback(void* handler, iotcs_virtual_device_error_event *event);
81  private:
82  Alert();
83  iotcs_alert_handle handle;
84  VirtualDevice* device;
85  static MUTEX_TYPE mapMutex;
86  static std::map<void*, std::pair<VirtualDevice*, ErrorCallback*> > onErrorCallbacks;
87  };
88 };
A callback interface for errors in delivery of messages.
Definition: AbstractVirtualDevice.hpp:152
virtual ~Alert()
Destructor.
Definition: VirtualDevice.hpp:38
Alert & set(const std::string &attributeName, const T &value)
Set the value of a field in the.
virtual void setOnError(ErrorCallback *callback)
Set a callback that is invoked if an error occurs when raising an.
Definition: Alert.hpp:35