Implement a basic version of ResponseStatement
authorcoderhyme <jhyo.kim@samsung.com>
Fri, 12 Jun 2015 07:58:22 +0000 (16:58 +0900)
committerUze Choi <uzchoi@samsung.com>
Wed, 17 Jun 2015 09:03:03 +0000 (09:03 +0000)
Change-Id: I628e51183c8a22b6aca518432640b306eb0f1c2a
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1302
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: Uze Choi <uzchoi@samsung.com>
service/basis/common/primitiveResource/include/ResponseStatement.h
service/basis/common/primitiveResource/src/ResponseStatement.cpp [new file with mode: 0644]

index 75485d7..34421c5 100755 (executable)
 #ifndef __RESPONSESTATEMENT_H
 #define __RESPONSESTATEMENT_H
 
+#include <string>
+#include <vector>
+
 #include <ResourceAttributes.h>
 
+namespace OC
+{
+    class OCRepresentation;
+}
+
 namespace OIC
 {
     namespace Service
     {
+        class ResourceAttributes;
 
-        /**
-         * TODO : design for future flexibility
-         */
         class ResponseStatement
         {
         public:
-            static ResponseStatement create(ResourceAttributes&& attrs)
-            {
-                return ResponseStatement(attrs);
-            }
-
-            explicit ResponseStatement(const ResourceAttributes& attrs) :
-                    m_attrs{ attrs }
-            {
-            }
-            explicit ResponseStatement(ResourceAttributes&& attrs) :
-                    m_attrs{ std::move(attrs) }
-            {
-            }
+            static ResponseStatement create(const OC::OCRepresentation&);
+            static ResponseStatement create(ResourceAttributes&&);
+
+            explicit ResponseStatement(const ResourceAttributes&);
+            explicit ResponseStatement(ResourceAttributes&&);
+
+            ResponseStatement(ResourceAttributes&&, std::string&& uri,
+                    std::vector< std::string >&& resourceTypes,
+                    std::vector< std::string >&& resourceInterfaces);
 
             ResponseStatement(ResponseStatement&&) = default;
 
             ResponseStatement& operator=(ResponseStatement&&) = default;
 
-        //     std::string getUri() const;
-        //     std::vector<std::string> getResourceTypes() const;
-        //     std::vector<std::string> getResourceInterfaces() const;
+            std::string getUri() const;
+            std::vector< std::string > getResourceTypes() const;
+            std::vector< std::string > getResourceInterfaces() const;
 
-            const ResourceAttributes& getAttributes() const
-            {
-                return m_attrs;
-            }
+            const ResourceAttributes& getAttributes() const;
 
         private:
             ResourceAttributes m_attrs;
+
+            std::string m_uri;
+            std::vector< std::string > m_resourceTypes;
+            std::vector< std::string > m_resourceInterfaces;
         };
 
     }
diff --git a/service/basis/common/primitiveResource/src/ResponseStatement.cpp b/service/basis/common/primitiveResource/src/ResponseStatement.cpp
new file mode 100644 (file)
index 0000000..2a3b25b
--- /dev/null
@@ -0,0 +1,81 @@
+//******************************************************************
+//
+// Copyright 2015 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#include <ResponseStatement.h>
+
+#include <internal/ResourceAtrributesConverter.h>
+
+namespace OIC
+{
+    namespace Service
+    {
+        ResponseStatement ResponseStatement::create(const OC::OCRepresentation& ocRepresentation)
+        {
+            return ResponseStatement::create(
+                    ResourceAttributesConverter::fromOCRepresentation(ocRepresentation));
+        }
+
+        ResponseStatement ResponseStatement::create(ResourceAttributes&& attrs)
+        {
+            return ResponseStatement(std::move(attrs));
+        }
+
+        ResponseStatement::ResponseStatement(const ResourceAttributes& attrs) :
+                m_attrs{ attrs }
+        {
+        }
+
+        ResponseStatement::ResponseStatement(ResourceAttributes&& attrs) :
+                ResponseStatement{ std::move(attrs), "", { }, { } }
+        {
+        }
+
+        ResponseStatement::ResponseStatement(ResourceAttributes&& attrs, std::string&& uri,
+                std::vector< std::string >&& resourceTypes,
+                std::vector< std::string >&& resourceInterfaces) :
+                m_attrs{ std::move(attrs) }, m_uri{ std::move(uri) },
+                m_resourceTypes { std::move(resourceTypes) },
+                m_resourceInterfaces{ std::move(resourceInterfaces) }
+        {
+        }
+
+        std::string ResponseStatement::getUri() const
+        {
+            return m_uri;
+        }
+
+        std::vector< std::string > ResponseStatement::getResourceTypes() const
+        {
+            return m_resourceTypes;
+        }
+
+        std::vector< std::string > ResponseStatement::getResourceInterfaces() const
+        {
+            return m_resourceInterfaces;
+        }
+
+        const ResourceAttributes& ResponseStatement::getAttributes() const
+        {
+            return m_attrs;
+        }
+
+    }
+}
+