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
StorageObject.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017, 2019, 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 <string>
12 #include <VirtualDevice.hpp>
13 #include <ExternalObject.hpp>
14 #include "iotcs_storage_object.h"
15 #include <Exception.hpp>
16 #include <time.h>
17 
18 #ifdef __MBED__
19 #include "mbed.h"
20 #endif
21 
68 namespace iotdcl {
69  class StorageObject;
73  enum SyncStatus {
78  IN_SYNC = 0,
79 
85 
91 
97  };
98 
105  template<class V> class SyncEvent {
106  public:
112  virtual V* getVirtualDevice() const = 0;
113 
120  virtual const std::string& getName() const = 0;
121 
126  virtual StorageObject* getSource() const = 0;
127 
131  virtual ~SyncEvent() {};
132  };
133 
141  class SyncCallback {
142  public:
149  virtual void onSync(const SyncEvent<VirtualDevice>& event) const = 0;
150 
154  virtual ~SyncCallback() {
155  }
156  };
157 
158  class StorageObject : public ExternalObject {
159  public:
163  virtual ~StorageObject();
164 
169  virtual const std::string& getName() const;
170 
176  virtual const std::string& getType() const;
177 
182  virtual const std::string& getEncoding() const;
183 
189  virtual long getLength() const;
190 
198  virtual time_t getDate() const;
199 
204  virtual SyncStatus getSyncStatus() const;
205 
210  virtual const std::string& getInputPath() const;
211 
224  virtual void setInputPath(const std::string& inputPath) throw (GeneralException, std::invalid_argument);
225 
230  virtual const std::string& getOutputPath() const;
231 
245  virtual void setOutputPath(const std::string& outputPath) throw (GeneralException, std::invalid_argument);
246 
258  virtual void setCustomMetadata(const std::string& key, const std::string& value) throw (std::invalid_argument);
279  virtual void sync() throw (GeneralException, std::invalid_argument);
280 
287  virtual void setOnSync(const SyncCallback *callback);
288 
293  virtual const std::string& getURI();
294 #ifndef IOTCS_DOXYGEN
295  protected:
296  VirtualDevice *vd;
297  void setVirtualDevice(VirtualDevice *vd);
298  iotcs_storage_object_handle c_handler() const;
299  StorageObject() {};
300  std::string *name;
301  std::string *outPath;
302  std::string *inPath;
303  std::string *type;
304  std::string *encoding;
305  friend VirtualDevice;
306  friend Alert;
307  friend Data;
308 #endif
309  };
310 };
iotdcl::ExternalObject represents the value of a URI type in a device model.
virtual const std::string & getName() const =0
Get the name of the attribute, action, or format that this event is associated with.
virtual const std::string & getOutputPath() const
Get the output path.
VirtualDevice for a device-client adds methods to handle write-only and executable actions...
virtual void setOutputPath(const std::string &outputPath)
Set the output path for downloading content from the storage cloud.
virtual ~SyncEvent()
Destructor.
Definition: StorageObject.hpp:131
virtual const std::string & getName() const
Get the the name of this object in the storage cloud.
The content is not in sync with the storage cloud because it has not yet been uploaded or download...
Definition: StorageObject.hpp:90
Common exception.
Definition: Exception.hpp:34
The content is in sync with the storage cloud.
Definition: StorageObject.hpp:78
virtual long getLength() const
Get the length of the content in bytes.
virtual StorageObject * getSource() const =0
Get the iotdcl::StorageObject} that is the source of this event.
virtual ~StorageObject()
Destructor.
virtual const std::string & getInputPath() const
Get the input path.
An event passed to the setOnSync(SyncCallback) SyncCallback when content referred to by an attribute ...
Definition: StorageObject.hpp:105
virtual void setCustomMetadata(const std::string &key, const std::string &value)
Sets the metadata for the StorageObject.
virtual void sync()
Notify the library to sync content with the storage cloud.
virtual void setOnSync(const SyncCallback *callback)
Set a iotdcl::SyncCallback that is invoked when the content referred to by this StorageObject is sync...
virtual time_t getDate() const
Get the date and time the content was created or last modified in cloud storage.
Definition: VirtualDevice.hpp:38
virtual ~SyncCallback()
Desctructor.
Definition: StorageObject.hpp:154
Definition: Data.hpp:37
virtual const std::string & getURI()
Get the URI value.
The content is not in sync with the storage cloud, but a sync is pending.
Definition: StorageObject.hpp:96
virtual void onSync(const SyncEvent< VirtualDevice > &event) const =0
Callback for receiving an event when content referred to by an attribute value has been successfully ...
Definition: ExternalObject.hpp:21
The content is not in sync with the storage cloud because the upload or download failed.
Definition: StorageObject.hpp:84
A syncCallback interface for receiving an event when content referred to by an attribute value has be...
Definition: StorageObject.hpp:141
virtual const std::string & getType() const
Get the mime-type of the content.
Definition: Alert.hpp:35
virtual const std::string & getEncoding() const
Get the compression scheme of the content.
virtual SyncStatus getSyncStatus() const
Get the status of whether or not the content is in sync with the storage cloud.
virtual void setInputPath(const std::string &inputPath)
Set the input path for uploading content to the storage cloud.
virtual V * getVirtualDevice() const =0
Get the virtual device that is the source of the event.
Definition: StorageObject.hpp:158
SyncStatus
The status of whether or not the content is in sync with the storage cloud.
Definition: StorageObject.hpp:73