Add to Null checking log in IsSameEowner
[platform/upstream/iotivity.git] / resource / include / OCResourceResponse.h
index ee660e3..754f1ac 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,9 +45,45 @@ namespace OC
     public:
         typedef std::shared_ptr<OCResourceResponse> Ptr;
 
-        OCResourceResponse()
-        {}
+        OCResourceResponse():
+            m_newResourceUri{},
+            m_errorCode{},
+            m_headerOptions{},
+            m_interface{},
+            m_representation{},
+            m_requestHandle{0},
+            m_resourceHandle{nullptr},
+            m_responseResult{}
+        {
+        }
 
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
+        OCResourceResponse(OCResourceResponse&& o):
+            m_newResourceUri(std::move(o.m_newResourceUri)),
+            m_errorCode(o.m_errorCode),
+            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_errorCode = o.m_errorCode;
+            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) {}
 
         /**
@@ -88,30 +120,57 @@ namespace OC
         }
 
         /**
+        * 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 rep reference to the resource's representation
         *  @param interface 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 rep rvalue reference to the resource's representation
         *  @param interface 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 +180,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
@@ -134,11 +192,14 @@ namespace OC
         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,14 +240,17 @@ namespace OC
 
             }
 
-            return inf.getJSONRepresentation(OCInfoFormat::ExcludeOC);
+            return inf.getPayload();
         }
     public:
 
         /**
         * Get error code
         */
-        int getErrorCode() const;
+        int getErrorCode() const
+        {
+            return m_errorCode;
+        }
 
         /**
          * Get the Response Representation
@@ -202,8 +266,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_