//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-/// @file OCResource.h
-
-/// @brief This file contains the declaration of classes and its members related to
-/// Resource.
+/**
+ * @file
+ *
+ * This file contains the declaration of classes and its members related to
+ * Resource.
+ */
#ifndef __OCRESOURCE_H
#define __OCRESOURCE_H
{
class OCResource;
class OCResourceIdentifier;
- ostream& operator <<(ostream& os, const OCResourceIdentifier& ri);
+ std::ostream& operator <<(std::ostream& os, const OCResourceIdentifier& ri);
/**
* @brief OCResourceIdentifier represents the identity information for a server. This
* object combined with the OCResource's URI property uniquely identify an
class OCResourceIdentifier
{
friend class OCResource;
- friend ostream& operator <<(ostream& os, const OCResourceIdentifier& ri);
+ friend std::ostream& operator <<(std::ostream& os, const OCResourceIdentifier& ri);
public:
+ OCResourceIdentifier() = delete;
+
+ OCResourceIdentifier(const OCResourceIdentifier&) = default;
+
+ OCResourceIdentifier(OCResourceIdentifier&&) = default;
+
+ OCResourceIdentifier& operator=(const OCResourceIdentifier&) = delete;
+
+ OCResourceIdentifier& operator=(OCResourceIdentifier&&) = delete;
+
bool operator==(const OCResourceIdentifier &other) const;
bool operator!=(const OCResourceIdentifier &other) const;
const std::string& resourceUri );
private:
- uint32_t m_representation;
+ std::string m_representation;
const std::string& m_resourceUri;
};
* The callback function will be invoked with a map of attribute name and values.
* The callback function will also have the result from this Get operation
* This will have error codes
- * @param QualityOfService the quality of communication
* @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
* NOTE: OCStackResult is defined in ocstack.h.
*/
OCStackResult get(const QueryParamsMap& queryParametersMap, GetCallback attributeHandler);
+ /**
+ * Function to get the attributes of a resource.
+ * @param queryParametersMap map which can have the query parameter name and value
+ * @param attributeHandler handles callback
+ * The callback function will be invoked with a map of attribute name and values.
+ * The callback function will also have the result from this Get operation
+ * This will have error codes
+ * @param QoS the quality of communication
+ * @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
+ * NOTE: OCStackResult is defined in ocstack.h.
+ */
OCStackResult get(const QueryParamsMap& queryParametersMap, GetCallback attributeHandler,
QualityOfService QoS);
* resource container (list will be empty if not a container)
* The callback function will also have the result from this Get operation. This will
* have error codes
- * @param QualityOfService the quality of communication
* @return OCStackResult return value of this API. Returns OC_STACK_OK if success. <br>
* NOTE: OCStackResult is defined in ocstack.h.<br>
* <b>Example:</b><br>
*/
OCStackResult get(const std::string& resourceType, const std::string& resourceInterface,
const QueryParamsMap& queryParametersMap, GetCallback attributeHandler);
+ /**
+ * Function to get the attributes of a resource.
+ *
+ * @param resourceType resourceType of the resource operate on
+ * @param resourceInterface interface type of the resource to operate on
+ * @param queryParametersMap map which can have the query parameter name and value
+ * @param attributeHandler handles callback
+ * The callback function will be invoked with a map of attribute name and values.
+ * The callback function will be invoked with a list of URIs if 'get' is invoked on a
+ * resource container (list will be empty if not a container)
+ * The callback function will also have the result from this Get operation. This will
+ * have error codes
+ * @param QoS the quality of communication
+ * @return OCStackResult return value of this API. Returns OC_STACK_OK if success. <br>
+ * NOTE: OCStackResult is defined in ocstack.h.<br>
+ * <b>Example:</b><br>
+ * Consider resource "a/home" (with link interface and resource type as home) contains links
+ * to "a/kitchen" and "a/room".
+ * Step 1: get("home", Link_Interface, &onGet)<br>
+ * Callback onGet will receive a) Empty attribute map because there are no attributes for
+ * a/home b) list with
+ * full URI of "a/kitchen" and "a/room" resources and their properties c) error code for GET
+ * operation<br>
+ * NOTE: A resource may contain single or multiple resource types. Also, a resource may
+ * contain single or multiple interfaces.<br>
+ * Currently, single GET request is allowed to do operate on single resource type or resource
+ * interface. In future, a single GET <br>
+ * can operate on multiple resource types and interfaces. <br>
+ * NOTE: A client can traverse a tree or graph by doing successive GETs on the returned
+ * resources at a node.<br>
+ */
OCStackResult get(const std::string& resourceType, const std::string& resourceInterface,
const QueryParamsMap& queryParametersMap, GetCallback attributeHandler,
QualityOfService QoS);
* This will have error codes
* @param queryParametersMap map which can have the query parameter name and value
* @param attributeHandler attribute handler
- * @param QualityOfService the quality of communication
* @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
* NOTE: OCStackResult is defined in ocstack.h.
*/
OCStackResult put(const OCRepresentation& representation,
const QueryParamsMap& queryParametersMap, PutCallback attributeHandler);
+ /**
+ * Function to set the representation of a resource (via PUT)
+ * @param representation which can either have all the attribute names and values
+ (which will represent entire state of the resource) or a
+ * set of attribute names and values which needs to be modified
+ * The callback function will be invoked with a map of attribute name and values.
+ * The callback function will also have the result from this Put operation
+ * This will have error codes
+ * @param queryParametersMap map which can have the query parameter name and value
+ * @param attributeHandler attribute handler
+ * @param QoS the quality of communication
+ * @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
+ * NOTE: OCStackResult is defined in ocstack.h.
+ */
OCStackResult put(const OCRepresentation& representation,
const QueryParamsMap& queryParametersMap, PutCallback attributeHandler,
QualityOfService QoS);
* and values
* (which will represent entire state of the resource) or a
* set of attribute names and values which needs to be modified
- * @param QualityOfService the quality of communication
* @return OCStackResult return value of this API. Returns OC_STACK_OK if success. <br>
* NOTE: OCStackResult is defined in ocstack.h. <br>
*/
OCStackResult put(const std::string& resourceType, const std::string& resourceInterface,
const OCRepresentation& representation, const QueryParamsMap& queryParametersMap,
PutCallback attributeHandler);
+ /**
+ * Function to set the attributes of a resource (via PUT)
+ * @param resourceType resource type of the resource to operate on
+ * @param resourceInterface interface type of the resource to operate on
+ * @param representation representation of the resource
+ * @param queryParametersMap Map which can have the query parameter name and value
+ * @param attributeHandler attribute handler
+ * The callback function will be invoked with a map of attribute name and values.
+ * The callback function will also have the result from this Put operation
+ * This will have error codes.
+ * The Representation parameter maps which can either have all the attribute names
+ * and values
+ * (which will represent entire state of the resource) or a
+ * set of attribute names and values which needs to be modified
+ * @param QoS the quality of communication
+ * @return OCStackResult return value of this API. Returns OC_STACK_OK if success. <br>
+ * NOTE: OCStackResult is defined in ocstack.h. <br>
+ */
OCStackResult put(const std::string& resourceType, const std::string& resourceInterface,
const OCRepresentation& representation, const QueryParamsMap& queryParametersMap,
PutCallback attributeHandler, QualityOfService QoS);
/**
* Function to post on a resource
* @param representation which can either have all the attribute names and values
- (which will represent entire state of the resource) or a
+ * (which will represent entire state of the resource) or a
* set of attribute names and values which needs to be modified
* The callback function will be invoked with a map of attribute name and values.
* The callback function will also have the result from this Put operation
* This will have error codes
* @param queryParametersMap map which can have the query parameter name and value
* @param attributeHandler attribute handler
- * @param QualityOfService the quality of communication
* @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
* NOTE: OCStackResult is defined in ocstack.h.
*/
OCStackResult post(const OCRepresentation& representation,
const QueryParamsMap& queryParametersMap, PostCallback attributeHandler);
+ /**
+ * Function to post on a resource
+ * @param representation which can either have all the attribute names and values
+ * (which will represent entire state of the resource) or a
+ * set of attribute names and values which needs to be modified
+ * The callback function will be invoked with a map of attribute name and values.
+ * The callback function will also have the result from this Put operation
+ * This will have error codes
+ * @param queryParametersMap map which can have the query parameter name and value
+ * @param attributeHandler attribute handler
+ * @param QoS the quality of communication
+ * @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
+ * NOTE: OCStackResult is defined in ocstack.h.
+ */
OCStackResult post(const OCRepresentation& representation,
const QueryParamsMap& queryParametersMap, PostCallback attributeHandler,
QualityOfService QoS);
* and values
* (which will represent entire state of the resource) or a
* set of attribute names and values which needs to be modified
- * @param QualityOfService the quality of communication
* @return OCStackResult return value of this API. Returns OC_STACK_OK if success. <br>
* NOTE: OCStackResult is defined in ocstack.h. <br>
*/
OCStackResult post(const std::string& resourceType, const std::string& resourceInterface,
const OCRepresentation& representation, const QueryParamsMap& queryParametersMap,
PostCallback attributeHandler);
+ /**
+ * Function to post on a resource
+ * @param resourceType resource type of the resource to operate on
+ * @param resourceInterface interface type of the resource to operate on
+ * @param representation representation of the resource
+ * @param queryParametersMap Map which can have the query parameter name and value
+ * @param attributeHandler attribute handler
+ * The callback function will be invoked with a map of attribute name and values.
+ * The callback function will also have the result from this Put operation
+ * This will have error codes.
+ * The Representation parameter maps which can either have all the attribute names
+ * and values
+ * (which will represent entire state of the resource) or a
+ * set of attribute names and values which needs to be modified
+ * @param QoS the quality of communication
+ * @return OCStackResult return value of this API. Returns OC_STACK_OK if success. <br>
+ * NOTE: OCStackResult is defined in ocstack.h. <br>
+ */
OCStackResult post(const std::string& resourceType, const std::string& resourceInterface,
const OCRepresentation& representation, const QueryParamsMap& queryParametersMap,
PostCallback attributeHandler, QualityOfService QoS);
/**
* Function to perform DELETE operation
- * @param observeHandler handles callback
+ * @param deleteHandler handles callback
* The callback function will have headerOptions and result from this Delete
* operation. This will have error codes
* @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
* The callback function will be invoked with a map of attribute name and values.
* The callback function will also have the result from this observe operation
* This will have error codes
- * @param QualityOfService the quality of communication
* @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
* NOTE: OCStackResult is defined in ocstack.h.
*/
OCStackResult observe(ObserveType observeType, const QueryParamsMap& queryParametersMap,
ObserveCallback observeHandler);
+ /**
+ * Function to set observation on the resource
+ * @param observeType allows the client to specify how it wants to observe.
+ * @param queryParametersMap map which can have the query parameter name and value
+ * @param observeHandler handles callback
+ * The callback function will be invoked with a map of attribute name and values.
+ * The callback function will also have the result from this observe operation
+ * This will have error codes
+ * @param qos the quality of communication
+ * @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
+ * NOTE: OCStackResult is defined in ocstack.h.
+ */
OCStackResult observe(ObserveType observeType, const QueryParamsMap& queryParametersMap,
ObserveCallback observeHandler, QualityOfService qos);
/**
* Function to get the connectivity type of this resource
- * @return uint8_t connectivity type
+ * @return enum connectivity type (flags and adapter)
*/
OCConnectivityType connectivityType() const;
// TODO-CA Revisit this since we are exposing two identifiers
/**
- * Function to get a unqiue identifier for this
+ * Function to get a unique identifier for this
* resource across network interfaces. This will
* be guaranteed unique for every resource-per-server
* independent of how this was discovered.
std::weak_ptr<IClientWrapper> m_clientWrapper;
std::string m_uri;
OCResourceIdentifier m_resourceId;
- std::string m_host;
- OCConnectivityType m_connectivityType;
+ OCDevAddr m_devAddr;
bool m_isObservable;
bool m_isCollection;
std::vector<std::string> m_resourceTypes;
HeaderOptions m_headerOptions;
private:
- OCResource(std::weak_ptr<IClientWrapper> clientWrapper, const std::string& host,
- const std::string& uri, const std::string& serverId,
- OCConnectivityType m_connectivityType, bool observable,
- const std::vector<std::string>& resourceTypes,
- const std::vector<std::string>& interfaces);
+ OCResource(std::weak_ptr<IClientWrapper> clientWrapper,
+ const OCDevAddr& devAddr, const std::string& uri,
+ const std::string& serverId, bool observable,
+ const std::vector<std::string>& resourceTypes,
+ const std::vector<std::string>& interfaces);
+
+ OCResource(std::weak_ptr<IClientWrapper> clientWrapper,
+ const std::string& host, const std::string& uri,
+ const std::string& serverId,
+ OCConnectivityType connectivityType, bool observable,
+ const std::vector<std::string>& resourceTypes,
+ const std::vector<std::string>& interfaces);
};
} // namespace OC
#endif //__OCRESOURCE_H
+