#include<vector>
#include "ResourceAttributes.h"
-#include "PrimitiveResource.h"
namespace OIC
{
*/
enum class ResourceState
{
- NOT_WATCHING,
+ NOT_MONITORING,
ALIVE, REQUESTED,
LOST_SIGNAL,
DESTROYED
*/
class RCSException;
class RemoteResourceObject;
+ class PrimitiveResource;
/**
* @class BadRequestException
RemoteResourceObject(std::shared_ptr<PrimitiveResource> pResource);
/**
- * Typedef for callback of startWatching API
+ * Typedef for callback of startMonitoring API
*
* @see ResourceState
*/
RemoteAttributesSetCallback;
/**
- * Check current watching state.
+ * Check monitoring state.
*
- * @details This API checks the current watching state for the resource of interest.
+ * @details This API checks the current monitoring state for the resource of interest.
*
- * @return bool - true if Watching otherwise false.
+ * @return bool - true if monitoring the resource otherwise false.
*/
- bool isWatching() const;
+ bool isMonitoring() const;
/**
* Check current Caching state.
bool isObservable() const;
/**
- * Start watching the resource.
+ * Start Monitoring the resource.
*
* @details This API will start monitoring the resource of interest.
* Once this API is called it will check whether the particular resource
typedef unsigned int BrokerID;
/**
- * Flag to check watching state.
+ * Flag to check monitoring state.
*/
- bool m_watchingFlag;
+ bool m_monitoringFlag;
/**
* Flag to check caching state.
{
return ResourceState::DESTROYED;
}
-
+ else if (state == BROKER_STATE::NONE)
+ {
+ return ResourceState::NOT_MONITORING;
+ }
OC_LOG(ERROR, CLIENT_W_TAG, "getResourceStateFromBrokerState ERROR");
//Default return value
- return ResourceState::DESTROYED;
+ return ResourceState::NOT_MONITORING;
}
CacheState getCacheState(CACHE_STATE state)
{
RemoteResourceObject:: RemoteResourceObject(std::shared_ptr<PrimitiveResource> pResource) :
- m_watchingFlag(false), m_cachingFlag(false), m_observableFlag(pResource->isObservable()),
+ m_monitoringFlag(false), m_cachingFlag(false), m_observableFlag(pResource->isObservable()),
m_primitiveResource(pResource), m_cacheId(0), m_brokerId(0) {}
- bool RemoteResourceObject::isWatching() const
+ bool RemoteResourceObject::isMonitoring() const
{
- return m_watchingFlag;
+ return m_monitoringFlag;
}
bool RemoteResourceObject::isCaching() const
void RemoteResourceObject::startMonitoring(ResourceStateChangedCallback cb)
{
- OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::startWatching entry");
- if (true == m_watchingFlag)
+ OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::startMonitoring entry");
+ if (true == m_monitoringFlag)
{
- OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::startWatching : Already started");
+ OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::startMonitoring : Already started");
}
else
{
BrokerID brokerId = ResourceBroker::getInstance()->hostResource(m_primitiveResource,
std::bind(hostingCallback, std::placeholders::_1,
cb));
- m_watchingFlag = true;
+ m_monitoringFlag = true;
m_brokerId = brokerId;
}
catch (std::exception &exception)
throw InvalidParameterException {exception.what()};
}
}
- OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::startWatching exit");
+ OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::startMonitoring exit");
}
void RemoteResourceObject::stopMonitoring()
{
- OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::stopWatching entry");
- if (true == m_watchingFlag)
+ OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::stopMonitoring entry");
+ if (true == m_monitoringFlag)
{
try
{
ResourceBroker::getInstance()->cancelHostResource(m_brokerId);
- m_watchingFlag = false;
+ m_monitoringFlag = false;
}
catch (std::exception &exception)
{
- OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::stopWatching InvalidParameterException");
+ OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::stopMonitoring InvalidParameterException");
}
}
else
{
- OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject:: stopWatching : already terminated");
+ OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject:: stopMonitoring : already terminated");
}
- OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::stopWatching exit");
+ OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::stopMonitoring exit");
}
ResourceState RemoteResourceObject::getState() const