|
CPP Device Virtualization API Reference for Oracle Internet of Things Cloud Service Client Software Library. Release 21.1.1.0.0-3. E92477-09
|
iotdcl::StorageObject provides information about content in the cloud storage. More...
#include <string>#include <VirtualDevice.hpp>#include <ExternalObject.hpp>#include "iotcs_storage_object.h"#include <Exception.hpp>#include <time.h>Go to the source code of this file.
Structures | |
| class | iotdcl::SyncEvent< V > |
| An event passed to the setOnSync(SyncCallback) SyncCallback when content referred to by an attribute value has been successfully synchronized, or has failed to be synchronized. More... | |
| class | iotdcl::SyncCallback |
| A syncCallback interface for receiving an event when content referred to by an attribute value has been successfully synchronized, or has failed to be synchronized. More... | |
| class | iotdcl::StorageObject |
Namespaces | |
| iotdcl | |
| A name-value pair in an event. | |
Enumerations | |
| enum | iotdcl::SyncStatus { iotdcl::IN_SYNC = 0, iotdcl::SYNC_FAILED, iotdcl::NOT_IN_SYNC, iotdcl::SYNC_PENDING } |
| The status of whether or not the content is in sync with the storage cloud. More... | |
iotdcl::StorageObject provides information about content in the cloud storage.
// Upload example
StorageObject lenna =
directlyConnectedDevice.createStorageObject("lenna.jpg", "image/jpeg");
lenna.setInputPath("../images/lenna.jpg"); // onSync is called when the content referenced by the storageObject
// is in sync with the storage cloud, or the sync has failed. class MySyncCallback: public SyncCallback<VirtualDevice> {
public:
void onSync(SyncEvent<VirtualDevice>& event) const {
StorageObject& storageObject = event.getSource();
if (storageObject.getSyncStatus() == IN_SYNC) {
// image was uploaded and can be deleted
} else if (storageObject.getSyncStatus() == SYNC_FAILED) {
// image was not uploaded, take action!
}
}
};
lenna.setOnSync(mySyncCallback);
virtualDevice.set("image", lenna); // Download example
// onChange is called when the attribute value changes.
class MyChangeCallback: public ChangeCallback {
public:
virtual void onChange(const ChangeEvent<VirtualDevice>& event) const {
NamedValue& namedValue = event.getNamedValue();
StorageObject& storageObject = (StorageObject)namedValue.getValue<StorageObject&>();
if (storageObject.getLength() < availableDiskSpace) {
// syncTo will kick off the async download of the content
storageObject.setOnSync(mySyncCallback);
storageObject.setOutputPath("../downloads/filename");
storageObject.sync();
}
}
}
};
virtualDevice.setOnChange(myChangeCallback);