Use `URI` all caps in documentation
[iotivity.git] / resource / include / OCResourceResponse.h
index ee660e3..bbe5455 100644 (file)
 //
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
-/// @file OCResourceResponse.h
+/**
+ * @file
+ *
+ * This file contains the declaration of classes and its members related to
+ * ResourceResponse.
+ */
 
-/// @brief  This file contains the declaration of classes and its members related to
-///         ResourceResponse.
-
-#ifndef __OCRESOURCERESPONSE_H
-#define __OCRESOURCERESPONSE_H
+#ifndef OC_RESOURCERESPONSE_H_
+#define OC_RESOURCERESPONSE_H_
 
 #include "OCApi.h"
 #include <IServerWrapper.h>
 #include <ocstack.h>
 #include <OCRepresentation.h>
 
-using namespace std;
-
-
-void (processResourceResponse)(OCEntityHandlerFlag,
-                                 OCEntityHandlerRequest*,
-                                 std::shared_ptr<OC::OCResourceResponse> pResponse);
-
-
 namespace OC
 {
+    class InProcServerWrapper;
+
     /**
     *   @brief  OCResourceResponse provides APIs to set the response details
     */
@@ -49,20 +45,47 @@ namespace OC
     public:
         typedef std::shared_ptr<OCResourceResponse> Ptr;
 
-        OCResourceResponse()
-        {}
+        OCResourceResponse():
+            m_newResourceUri{},
+            m_headerOptions{},
+            m_interface{},
+            m_representation{},
+            m_requestHandle{nullptr},
+            m_resourceHandle{nullptr},
+            m_responseResult{}
+        {
+        }
 
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
+        OCResourceResponse(OCResourceResponse&& o):
+            m_newResourceUri(std::move(o.m_newResourceUri)),
+            m_headerOptions(std::move(o.m_headerOptions)),
+            m_interface(std::move(o.m_interface)),
+            m_representation(std::move(o.m_representation)),
+            m_requestHandle(std::move(o.m_requestHandle)),
+            m_resourceHandle(std::move(o.m_resourceHandle)),
+            m_responseResult(std::move(o.m_responseResult))
+        {
+        }
+        OCResourceResponse& operator=(OCResourceResponse&& o)
+        {
+            m_newResourceUri = std::move(o.m_newResourceUri);
+            m_headerOptions = std::move(o.m_headerOptions);
+            m_interface = std::move(o.m_interface);
+            m_representation = std::move(o.m_representation);
+            m_requestHandle = std::move(o.m_requestHandle);
+            m_resourceHandle = std::move(o.m_resourceHandle);
+            m_responseResult = std::move(o.m_responseResult);
+        }
+#else
+        OCResourceResponse(OCResourceResponse&&) = default;
+        OCResourceResponse& operator=(OCResourceResponse&&) = default;
+#endif
         virtual ~OCResourceResponse(void) {}
 
         /**
-        *  This API sets the error code for this response
-        *  @param eCode error code to set
-        */
-        void setErrorCode(const int eCode) { m_errorCode = eCode; }
-
-        /**
-        *  gets new resource uri
-        *  @return std::string new resource uri
+        *  gets new resource URI
+        *  @return std::string new resource URI
         */
         std::string getNewResourceUri(void)
         {
@@ -70,8 +93,8 @@ namespace OC
         }
 
         /**
-        *  sets new resource uri
-        *  @param newResourceUri specifies the resource uri of the resource created
+        *  sets new resource URI
+        *  @param newResourceUri specifies the resource URI of the resource created
         */
         void setNewResourceUri(const std::string newResourceUri)
         {
@@ -87,31 +110,58 @@ namespace OC
             m_headerOptions = headerOptions;
         }
 
+        /**
+        * This API allows to set request handle
+        *
+        * @param requestHandle - OCRequestHandle type used to set the request handle
+        */
+        void setRequestHandle(const OCRequestHandle& requestHandle)
+        {
+            m_requestHandle = requestHandle;
+        }
+
+        /**
+        * This API allows to set the resource handle
+        *
+        * @param resourceHandle - OCResourceHandle type used to set the resource handle
+        */
+        void setResourceHandle(const OCResourceHandle& resourceHandle)
+        {
+            m_resourceHandle = resourceHandle;
+        }
+
+        /**
+        * This API allows to set the EntityHandler response result
+        *
+        * @param responseResult - OCEntityHandlerResult type to set the result value
+        */
+        void setResponseResult(const OCEntityHandlerResult& responseResult)
+        {
+            m_responseResult = responseResult;
+        }
+
         /**
         *  API to set the entire resource attribute representation
-        *  @param attributeMap reference containing the name value pairs representing
-        *         the resource's attributes
-        *  @param interface specifies the interface
+        *  @param rep reference to the resource's representation
+        *  @param iface specifies the interface
         */
-        void setResourceRepresentation(OCRepresentation& rep, std::string interface) {
-            m_interface = interface;
+        void setResourceRepresentation(OCRepresentation& rep, std::string iface) {
+            m_interface = iface;
             m_representation = rep;
         }
 
         /**
         *  API to set the entire resource attribute representation
-        *  @param attributeMap rvalue reference containing the name value pairs representing
-        *         the resource's attributes
-        *  @param interface specifies the interface
+        *  @param rep rvalue reference to the resource's representation
+        *  @param iface specifies the interface
         */
-        void setResourceRepresentation(OCRepresentation&& rep, std::string interface) {
-            setResourceRepresentation(rep, interface);
+        void setResourceRepresentation(OCRepresentation&& rep, std::string iface) {
+            setResourceRepresentation(rep, iface);
         }
 
         /**
         *  API to set the entire resource attribute representation
-        *  @param attributeMap reference containing the name value pairs representing the resource's
-        *  attributes
+        *  @param rep reference to the resource's representation
         */
         void setResourceRepresentation(OCRepresentation& rep) {
             // Call the default
@@ -121,8 +171,7 @@ namespace OC
 
         /**
         *  API to set the entire resource attribute representation
-        *  @param attributeMap rvalue reference containing the name value pairs representing the
-        *  resource's attributes
+        *  @param rep rvalue reference to the resource's representation
         */
         void setResourceRepresentation(OCRepresentation&& rep) {
             // Call the above function
@@ -130,15 +179,17 @@ namespace OC
         }
     private:
         std::string m_newResourceUri;
-        int m_errorCode;
         HeaderOptions m_headerOptions;
         std::string m_interface;
         OCRepresentation m_representation;
+        OCRequestHandle m_requestHandle;
+        OCResourceHandle m_resourceHandle;
+        OCEntityHandlerResult m_responseResult;
+
     private:
-        friend void (::processResourceResponse)(OCEntityHandlerFlag,
-                            OCEntityHandlerRequest*,
-                            std::shared_ptr<OC::OCResourceResponse> pResponse);
-        std::string getPayload() const
+        friend class InProcServerWrapper;
+
+        OCRepPayload* getPayload() const
         {
             MessageContainer inf;
             OCRepresentation first(m_representation);
@@ -179,15 +230,10 @@ namespace OC
 
             }
 
-            return inf.getJSONRepresentation(OCInfoFormat::ExcludeOC);
+            return inf.getPayload();
         }
     public:
 
-        /**
-        * Get error code
-        */
-        int getErrorCode() const;
-
         /**
          * Get the Response Representation
          */
@@ -202,8 +248,38 @@ namespace OC
         {
             return m_headerOptions;
         }
+
+        /**
+        * This API retrieves the request handle
+        *
+        * @return OCRequestHandle value
+        */
+        const OCRequestHandle& getRequestHandle() const
+        {
+            return m_requestHandle;
+        }
+
+        /**
+        * This API retrieves the resource handle
+        *
+        * @return OCResourceHandle value
+        */
+        const OCResourceHandle& getResourceHandle() const
+        {
+            return m_resourceHandle;
+        }
+
+        /**
+        * This API retrieves the entity handle response result
+        *
+        * @return OCEntityHandler result value
+        */
+        OCEntityHandlerResult getResponseResult() const
+        {
+            return m_responseResult;
+        }
     };
 
 } // namespace OC
 
-#endif //__OCRESOURCERESPONSE_H
+#endif // OC_RESOURCERESPONSE_H_