replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / include / OCResource.h
index c2754a2..e1f7bc6 100644 (file)
@@ -25,8 +25,8 @@
  * Resource.
  */
 
-#ifndef __OCRESOURCE_H
-#define __OCRESOURCE_H
+#ifndef OC_RESOURCE_H_
+#define OC_RESOURCE_H_
 
 #include <memory>
 #include <random>
@@ -60,7 +60,15 @@ namespace OC
 
             OCResourceIdentifier(const OCResourceIdentifier&) = default;
 
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
+            OCResourceIdentifier(OCResourceIdentifier&& o):
+                m_resourceUri(std::move(o.m_resourceUri)),
+                m_representation(o.m_representation)
+            {
+            }
+#else
             OCResourceIdentifier(OCResourceIdentifier&&) = default;
+#endif
 
             OCResourceIdentifier& operator=(const OCResourceIdentifier&) = delete;
 
@@ -103,8 +111,33 @@ namespace OC
     public:
         typedef std::shared_ptr<OCResource> Ptr;
 
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
+        OCResource(OCResource&& o):
+            m_clientWrapper(std::move(o.m_clientWrapper)),
+            m_uri(std::move(o.m_uri)),
+            m_resourceId(std::move(o.m_resourceId)),
+            m_devAddr(std::move(o.m_devAddr)),
+            m_deviceName(std::move(o.m_deviceName)),
+            m_useHostString(o.m_useHostString),
+            m_property(o.m_property),
+            m_isCollection(o.m_isCollection),
+            m_resourceTypes(std::move(o.m_resourceTypes)),
+            m_interfaces(std::move(o.m_interfaces)),
+            m_children(std::move(m_children)),
+            m_observeHandle(std::move(m_observeHandle)),
+            m_headerOptions(std::move(m_headerOptions))
+        {
+        }
+#else
         OCResource(OCResource&&) = default;
-        OCResource& operator=(OCResource&&) = default;
+#endif
+        // Explicitly delete the copy ctor since VS2013 would try to generate one, and
+        // the standard says that defaulting the move ctor should delete the copy ctor.
+        OCResource(const OCResource&) = delete;
+
+        // We cannot support copy/move assigns since OCResourceIdentifier doesn't.
+        OCResource& operator=(OCResource&&) = delete;
+        OCResource& operator=(const OCResource&) = delete;
 
         /**
         * Virtual destructor
@@ -453,6 +486,29 @@ namespace OC
         std::string host() const;
 
         /**
+        * Function to set host address information.
+        *
+        * @param host std::string host address
+        *             optionally one of
+        *                   CoAP over UDP prefix    "coap://"
+        *                   CoAP over TCP prefix    "coap+tcp://"
+        *                   CoAP over DTLS prefix   "coaps://"
+        *                   CoAP over TLS prefix    "coaps+tcp://"
+        *                   CoAP over RFCOMM prefix "coap+rfcomm://"
+        *                   CoAP over GATT prefix   "coap+gatt://"
+        *             optionally one of
+        *                   IPv6 address            "[1234::5678]"
+        *                   IPv4 address            "192.168.1.1"
+        *             optional port               ":5683"
+        *
+        * @note This should be in the format coap://address:port.
+        *       If host has different connectivity type with a given OCResource object
+        *       which was discovered after calling findResource API, raise an exception on failure.
+        *
+        */
+        void setHost(const std::string& host);
+
+        /**
         * Function to get the URI for this resource
         * @return std::string resource URI
         */
@@ -470,6 +526,17 @@ namespace OC
         *         not observable.
         */
         bool isObservable() const;
+        
+        OCDevAddr getDevAddr() const;
+
+#ifdef WITH_MQ
+        /**
+        * Function to provide ability to check if this resource is publisher or not
+        * @return bool true indicates resource is publisher; false indicates resource is
+        *         not publisher.
+        */
+        bool isPublish() const;
+#endif
 
         /**
         * Function to get the list of resource types
@@ -502,6 +569,111 @@ namespace OC
         */
         std::string sid() const;
 
+        /**
+        * Function to get a string representation of the human friendly name defined by the vendor.
+        * @note The format of the return value is subject to change and will
+        * likely change both in size and contents in the future.
+        */
+        std::string deviceName() const;
+
+#ifdef WITH_MQ
+        /**
+        * Function to discovery Topics from MQ Broker.
+        *
+        * @param queryParametersMap map which can have the query parameter name and value
+        * @param attributeHandler handles callback
+        * @param qos the quality of communication
+        *
+        * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
+        * @note OCStackResult is defined in ocstack.h.
+        *
+        */
+        OCStackResult discoveryMQTopics(const QueryParamsMap& queryParametersMap,
+                                        MQTopicCallback attributeHandler,
+                                        QualityOfService qos);
+        /**
+        * Function to create Topic into MQ Broker.
+        * SubTopic is also created through this method.
+        *
+        * @param rep representation of the topic
+        * @param topicUri new uri of the topic which want to create
+        * @param queryParametersMap map which can have the query parameter name and value
+        * @param attributeHandler handles callback
+        * @param qos the quality of communication
+        *
+        * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
+        * @note OCStackResult is defined in ocstack.h.
+        *
+        */
+        OCStackResult createMQTopic(const OCRepresentation& rep,
+                                    const std::string& topicUri,
+                                    const QueryParamsMap& queryParametersMap,
+                                    MQTopicCallback attributeHandler,
+                                    QualityOfService qos);
+#endif
+#ifdef MQ_SUBSCRIBER
+        /**
+        * Function to subscribe Topic to MQ Broker.
+        *
+        * @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
+        * @param qos the quality of communication
+        *
+        * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
+        * @note OCStackResult is defined in ocstack.h.
+        *
+        */
+        OCStackResult subscribeMQTopic(ObserveType observeType,
+                                       const QueryParamsMap& queryParametersMap,
+                                       ObserveCallback observeHandler,
+                                       QualityOfService qos);
+
+        /**
+        * Function to unsubscribe Topic to MQ Broker.
+        *
+        * @param qos the quality of communication
+        *
+        * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
+        * @note OCStackResult is defined in ocstack.h.
+        *
+        */
+        OCStackResult unsubscribeMQTopic(QualityOfService qos);
+
+        /**
+        * Function to request publish to MQ publisher.
+        * Publisher can confirm the request message as key:"req_pub" and value:"true".
+        *
+        * @param queryParametersMap map which can have the query parameter name and value
+        * @param attributeHandler handles callback
+        * @param qos the quality of communication
+        *
+        * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
+        * @note OCStackResult is defined in ocstack.h.
+        *
+        */
+        OCStackResult requestMQPublish(const QueryParamsMap& queryParametersMap,
+                                       PostCallback attributeHandler,
+                                       QualityOfService qos);
+#endif
+#ifdef MQ_PUBLISHER
+        /**
+        * Function to publish Topic information into MQ Broker.
+        *
+        * @param rep representation of the topic
+        * @param queryParametersMap map which can have the query parameter name and value
+        * @param attributeHandler handles callback
+        * @param qos the quality of communication
+        *
+        * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
+        * @note OCStackResult is defined in ocstack.h.
+        *
+        */
+        OCStackResult publishMQTopic(const OCRepresentation& rep,
+                                     const QueryParamsMap& queryParametersMap,
+                                     PostCallback attributeHandler,
+                                     QualityOfService qos);
+#endif
         // overloaded operators allow for putting into a 'set'
         // the uniqueidentifier allows for putting into a hash
         bool operator==(const OCResource &other) const;
@@ -517,36 +689,38 @@ namespace OC
         bool operator>=(const OCResource &other) const;
 
     private:
-        void setHost(const std::string& host);
         std::weak_ptr<IClientWrapper> m_clientWrapper;
         std::string m_uri;
         OCResourceIdentifier m_resourceId;
         OCDevAddr m_devAddr;
         bool m_useHostString;
-        bool m_isObservable;
         bool m_isCollection;
+        uint8_t m_property;
         std::vector<std::string> m_resourceTypes;
         std::vector<std::string> m_interfaces;
         std::vector<std::string> m_children;
         OCDoHandle m_observeHandle;
+        std::string m_deviceName;
         HeaderOptions m_headerOptions;
 
     private:
         OCResource(std::weak_ptr<IClientWrapper> clientWrapper,
                     const OCDevAddr& devAddr, const std::string& uri,
-                    const std::string& serverId, bool observable,
+                    const std::string& serverId, uint8_t property,
                     const std::vector<std::string>& resourceTypes,
-                    const std::vector<std::string>& interfaces);
+                    const std::vector<std::string>& interfaces,
+                    const std::string& deviceName);
 
         OCResource(std::weak_ptr<IClientWrapper> clientWrapper,
                     const std::string& host, const std::string& uri,
                     const std::string& serverId,
-                    OCConnectivityType connectivityType, bool observable,
+                    OCConnectivityType connectivityType, uint8_t property,
                     const std::vector<std::string>& resourceTypes,
-                    const std::vector<std::string>& interfaces);
+                    const std::vector<std::string>& interfaces,
+                    const std::string& deviceName);
     };
 
 } // namespace OC
 
-#endif //__OCRESOURCE_H
+#endif // OC_RESOURCE_H