#include <vector>
#include "RCSResourceAttributes.h"
+#include "RCSRepresentation.h"
namespace OC
{
LOST_SIGNAL, /**< Failed to reach the resource. */
};
+ enum class CacheMode
+ {
+ OBSERVE_ONLY,
+ OBSERVE_WITH_POLLING
+ };
+
/**
* The states of monitoring.
*
* @see RCSDiscoveryManager
*
*/
- class RCSRemoteResourceObject
+ class RCSRemoteResourceObject : public std::enable_shared_from_this<RCSRemoteResourceObject>
{
public:
typedef std::shared_ptr< RCSRemoteResourceObject > Ptr;
*
* @param attrs the updated attributes
*/
- typedef std::function< void(const RCSResourceAttributes& attrs) > CacheUpdatedCallback;
+ typedef std::function< void(const RCSResourceAttributes& attrs, int eCode) >
+ CacheUpdatedCallback;
/**
* Callback definition to be invoked when the response of getRemoteAttributes is
std::shared_ptr< OC::OCResource > ocResource);
/**
+ * Returns an equivalent OCResource using RCSRemoteResourceObject instance.
+ *
+ * @throw RCSInvalidParameterException If rcsResource is nullptr.
+ */
+ static std::shared_ptr< OC::OCResource > toOCResource(
+ RCSRemoteResourceObject::Ptr rcsResource);
+
+ /**
* Returns whether monitoring is enabled.
*
* @see startMonitoring()
* updates the cached data accordingly.
*
* @param cb If non-empty function, it will be invoked whenever the cache updated.
+ * @param mode if CacheMode is OBSERVE_ONLY, it will be invoked when receive observe response only.
*
* @throws BadRequestException If caching is already started.
*
* @see getCachedAttribute(const std::string&) const
*
*/
- void startCaching(CacheUpdatedCallback cb);
+ void startCaching(CacheUpdatedCallback cb, CacheMode mode = CacheMode::OBSERVE_WITH_POLLING);
/**
* Stops caching.
SetCallback cb);
/**
+ * Sends a set request with resource representation to the server.
+ *
+ * The SetRequest behavior depends on query parameters and the server.
+ *
+ * @param queryParams Query parameters
+ * @param rep Representation to set
+ * @param cb A callback to receive the response.
+ *
+ * @throws PlatformException If the operation failed
+ * @throws InvalidParameterException If cb is an empty function or null.
+ *
+ * @see RCSResourceObject
+ * @see RCSResourceObject::SetRequestHandlerPolicy
+ *
+ * @note The callback will be invoked in an internal thread.
+ */
+ void set(const RCSQueryParams& queryParams, const RCSRepresentation &rep,
+ SetCallback cb);
+
+ /**
* Returns the uri of the resource.
*
*/