2167ba61b0dea11f81ef9759dbbc3b8dcbb33c4a
[platform/upstream/iotivity.git] / resource / include / OCResource.h
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 /**
22  * @file
23  *
24  * This file contains the declaration of classes and its members related to
25  * Resource.
26  */
27
28 #ifndef OC_RESOURCE_H_
29 #define OC_RESOURCE_H_
30
31 #include <memory>
32 #include <random>
33 #include <algorithm>
34
35 #include <OCApi.h>
36 #include <ResourceInitException.h>
37 #include <IClientWrapper.h>
38 #include <InProcClientWrapper.h>
39 #include <OCRepresentation.h>
40
41 namespace OC
42 {
43     class OCResource;
44     class OCResourceIdentifier;
45     std::ostream& operator <<(std::ostream& os, const OCResourceIdentifier& ri);
46     /**
47     *  @brief  OCResourceIdentifier represents the identity information for a server. This
48     *          object combined with the OCResource's URI property uniquely identify an
49     *          OCResource on or across networks.
50     *          Equality operators are implemented.  However, internal representation is subject
51     *          to change and thus should not be accessed or depended on.
52     */
53     class OCResourceIdentifier
54     {
55         friend class OCResource;
56         friend std::ostream& operator <<(std::ostream& os, const OCResourceIdentifier& ri);
57
58         public:
59             OCResourceIdentifier() = delete;
60
61             OCResourceIdentifier(const OCResourceIdentifier&) = default;
62
63 #if defined(_MSC_VER) && (_MSC_VER < 1900)
64             OCResourceIdentifier(OCResourceIdentifier&& o):
65                 m_resourceUri(std::move(o.m_resourceUri)),
66                 m_representation(o.m_representation)
67             {
68             }
69 #else
70             OCResourceIdentifier(OCResourceIdentifier&&) = default;
71 #endif
72
73             OCResourceIdentifier& operator=(const OCResourceIdentifier&) = delete;
74
75             OCResourceIdentifier& operator=(OCResourceIdentifier&&) = delete;
76
77             bool operator==(const OCResourceIdentifier &other) const;
78
79             bool operator!=(const OCResourceIdentifier &other) const;
80
81             bool operator<(const OCResourceIdentifier &other) const;
82
83             bool operator>(const OCResourceIdentifier &other) const;
84
85             bool operator<=(const OCResourceIdentifier &other) const;
86
87             bool operator>=(const OCResourceIdentifier &other) const;
88
89         private:
90
91             OCResourceIdentifier(const std::string& wireServerIdentifier,
92                     const std::string& resourceUri );
93
94         private:
95             std::string m_representation;
96             const std::string& m_resourceUri;
97     };
98
99     /**
100     *   @brief  OCResource represents an OC resource. A resource could be a light controller,
101     *           temperature sensor, smoke detector, etc. A resource comes with a well-defined
102     *           contract or interface onto which you can perform different operations, such as
103     *           turning on the light, getting the current temperature or subscribing for event
104     *           notifications from the smoke detector. A resource can be composed of one or
105     *           more resources.
106     */
107     class OCResource
108     {
109     friend class OCPlatform_impl;
110     friend class ListenOCContainer;
111     public:
112         typedef std::shared_ptr<OCResource> Ptr;
113
114 #if defined(_MSC_VER) && (_MSC_VER < 1900)
115         OCResource(OCResource&& o):
116             m_clientWrapper(std::move(o.m_clientWrapper)),
117             m_uri(std::move(o.m_uri)),
118             m_resourceId(std::move(o.m_resourceId)),
119             m_devAddr(std::move(o.m_devAddr)),
120             m_useHostString(o.m_useHostString),
121             m_property(o.m_property),
122             m_isCollection(o.m_isCollection),
123             m_resourceTypes(std::move(o.m_resourceTypes)),
124             m_interfaces(std::move(o.m_interfaces)),
125             m_children(std::move(m_children)),
126             m_observeHandle(std::move(m_observeHandle)),
127             m_headerOptions(std::move(m_headerOptions))
128         {
129         }
130 #else
131         OCResource(OCResource&&) = default;
132 #endif
133         // Explicitly delete the copy ctor since VS2013 would try to generate one, and
134         // the standard says that defaulting the move ctor should delete the copy ctor.
135         OCResource(const OCResource&) = delete;
136
137         // We cannot support copy/move assigns since OCResourceIdentifier doesn't.
138         OCResource& operator=(OCResource&&) = delete;
139         OCResource& operator=(const OCResource&) = delete;
140
141         /**
142         * Virtual destructor
143         */
144         virtual ~OCResource(void);
145
146         /**
147         * Function to get the attributes of a resource.
148         * @param queryParametersMap map which can have the query parameter name and value
149         * @param attributeHandler handles callback
150         *        The callback function will be invoked with a map of attribute name and values.
151         *        The callback function will also have the result from this Get operation
152         *        This will have error codes
153         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
154         * @note OCStackResult is defined in ocstack.h.
155         */
156         OCStackResult get(const QueryParamsMap& queryParametersMap, GetCallback attributeHandler);
157         /**
158         * Function to get the attributes of a resource.
159         * @param queryParametersMap map which can have the query parameter name and value
160         * @param attributeHandler handles callback
161         *        The callback function will be invoked with a map of attribute name and values.
162         *        The callback function will also have the result from this Get operation
163         *        This will have error codes
164         * @param QoS the quality of communication
165         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
166         * @note OCStackResult is defined in ocstack.h.
167         */
168         OCStackResult get(const QueryParamsMap& queryParametersMap, GetCallback attributeHandler,
169                           QualityOfService QoS);
170
171         /**
172         * Function to get the attributes of a resource.
173         *
174         * @param resourceType resourceType of the resource operate on
175         * @param resourceInterface interface type of the resource to operate on
176         * @param queryParametersMap map which can have the query parameter name and value
177         * @param attributeHandler handles callback
178         *        The callback function will be invoked with a map of attribute name and values.
179         *        The callback function will be invoked with a list of URIs if 'get' is invoked on a
180         *        resource container (list will be empty if not a container)
181         *        The callback function will also have the result from this Get operation. This will
182         *        have error codes
183         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
184         * @note OCStackResult is defined in ocstack.h.
185         * @par Example:
186         * Consider resource "a/home" (with link interface and resource type as home) contains links
187         *  to "a/kitchen" and "a/room".
188         * -# get("home", Link_Interface, &onGet)
189         * @par
190         * Callback onGet will receive a) Empty attribute map because there are no attributes for
191         * a/home b) list with
192         * full URI of "a/kitchen" and "a/room" resources and their properties c) error code for GET
193         * operation
194         * @note A resource may contain single or multiple resource types. Also, a resource may
195         * contain single or multiple interfaces.
196         * Currently, single GET request is allowed to do operate on single resource type or resource
197         * interface. In future, a single GET
198         * can operate on multiple resource types and interfaces.
199         * @note A client can traverse a tree or graph by doing successive GETs on the returned
200         * resources at a node.
201         *
202         */
203         OCStackResult get(const std::string& resourceType, const std::string& resourceInterface,
204                         const QueryParamsMap& queryParametersMap, GetCallback attributeHandler);
205         /**
206         * Function to get the attributes of a resource.
207         *
208         * @param resourceType resourceType of the resource operate on
209         * @param resourceInterface interface type of the resource to operate on
210         * @param queryParametersMap map which can have the query parameter name and value
211         * @param attributeHandler handles callback
212         *        The callback function will be invoked with a map of attribute name and values.
213         *        The callback function will be invoked with a list of URIs if 'get' is invoked on a
214         *        resource container (list will be empty if not a container)
215         *        The callback function will also have the result from this Get operation. This will
216         *        have error codes
217         * @param QoS the quality of communication
218         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
219         * note OCStackResult is defined in ocstack.h.
220         * @par Example:
221         * Consider resource "a/home" (with link interface and resource type as home) contains links
222         *  to "a/kitchen" and "a/room".
223         * -# get("home", Link_Interface, &onGet)
224         * @par
225         * Callback onGet will receive a) Empty attribute map because there are no attributes for
226         * a/home b) list with
227         * full URI of "a/kitchen" and "a/room" resources and their properties c) error code for GET
228         * operation
229         * @note A resource may contain single or multiple resource types. Also, a resource may
230         * contain single or multiple interfaces.
231         * Currently, single GET request is allowed to do operate on single resource type or resource
232         * interface. In future, a single GET
233         * can operate on multiple resource types and interfaces.
234         * @note A client can traverse a tree or graph by doing successive GETs on the returned
235         * resources at a node.
236         *
237         */
238         OCStackResult get(const std::string& resourceType, const std::string& resourceInterface,
239                         const QueryParamsMap& queryParametersMap, GetCallback attributeHandler,
240                         QualityOfService QoS);
241
242         /**
243         * Function to set the representation of a resource (via PUT)
244         *
245         * @param representation which can either have all the attribute names and values
246                  (which will represent entire state of the resource) or a
247         *        set of attribute names and values which needs to be modified
248         *        The callback function will be invoked with a map of attribute name and values.
249         *        The callback function will also have the result from this Put operation
250         *        This will have error codes
251         * @param queryParametersMap map which can have the query parameter name and value
252         * @param attributeHandler attribute handler
253         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
254         * @note OCStackResult is defined in ocstack.h.
255         *
256         */
257         OCStackResult put(const OCRepresentation& representation,
258                         const QueryParamsMap& queryParametersMap, PutCallback attributeHandler);
259         /**
260         * Function to set the representation of a resource (via PUT)
261         *
262         * @param representation which can either have all the attribute names and values
263                  (which will represent entire state of the resource) or a
264         *        set of attribute names and values which needs to be modified
265         *        The callback function will be invoked with a map of attribute name and values.
266         *        The callback function will also have the result from this Put operation
267         *        This will have error codes
268         * @param queryParametersMap map which can have the query parameter name and value
269         * @param attributeHandler attribute handler
270         * @param QoS the quality of communication
271         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
272         * @note OCStackResult is defined in ocstack.h.
273         *
274         */
275         OCStackResult put(const OCRepresentation& representation,
276                         const QueryParamsMap& queryParametersMap, PutCallback attributeHandler,
277                         QualityOfService QoS);
278
279         /**
280         * Function to set the attributes of a resource (via PUT)
281         *
282         * @param resourceType resource type of the resource to operate on
283         * @param resourceInterface interface type of the resource to operate on
284         * @param representation representation of the resource
285         * @param queryParametersMap Map which can have the query parameter name and value
286         * @param attributeHandler attribute handler
287         *        The callback function will be invoked with a map of attribute name and values.
288         *        The callback function will also have the result from this Put operation
289         *        This will have error codes.
290         *        The Representation parameter maps which can either have all the attribute names
291         *        and values
292         *        (which will represent entire state of the resource) or a
293         *        set of attribute names and values which needs to be modified
294         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
295         * @note OCStackResult is defined in ocstack.h.
296         *
297         */
298         OCStackResult put(const std::string& resourceType, const std::string& resourceInterface,
299                         const OCRepresentation& representation, const QueryParamsMap& queryParametersMap,
300                         PutCallback attributeHandler);
301         /**
302         * Function to set the attributes of a resource (via PUT)
303         * @param resourceType resource type of the resource to operate on
304         * @param resourceInterface interface type of the resource to operate on
305         * @param representation representation of the resource
306         * @param queryParametersMap Map which can have the query parameter name and value
307         * @param attributeHandler attribute handler
308         *        The callback function will be invoked with a map of attribute name and values.
309         *        The callback function will also have the result from this Put operation
310         *        This will have error codes.
311         *        The Representation parameter maps which can either have all the attribute names
312         *        and values
313         *        (which will represent entire state of the resource) or a
314         *        set of attribute names and values which needs to be modified
315         * @param QoS the quality of communication
316         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
317         * @note OCStackResult is defined in ocstack.h.
318         *
319         */
320         OCStackResult put(const std::string& resourceType, const std::string& resourceInterface,
321                         const OCRepresentation& representation, const QueryParamsMap& queryParametersMap,
322                         PutCallback attributeHandler, QualityOfService QoS);
323
324         /**
325         * Function to post on a resource
326         *
327         * @param representation which can either have all the attribute names and values
328         *        (which will represent entire state of the resource) or a
329         *        set of attribute names and values which needs to be modified
330         *        The callback function will be invoked with a map of attribute name and values.
331         *        The callback function will also have the result from this Put operation
332         *        This will have error codes
333         * @param queryParametersMap map which can have the query parameter name and value
334         * @param attributeHandler attribute handler
335         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
336         * @note OCStackResult is defined in ocstack.h.
337         */
338         OCStackResult post(const OCRepresentation& representation,
339                         const QueryParamsMap& queryParametersMap, PostCallback attributeHandler);
340         /**
341         * Function to post on a resource
342         *
343         * @param representation which can either have all the attribute names and values
344         *        (which will represent entire state of the resource) or a
345         *        set of attribute names and values which needs to be modified
346         *        The callback function will be invoked with a map of attribute name and values.
347         *        The callback function will also have the result from this Put operation
348         *        This will have error codes
349         * @param queryParametersMap map which can have the query parameter name and value
350         * @param attributeHandler attribute handler
351         * @param QoS the quality of communication
352         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
353         * @note OCStackResult is defined in ocstack.h.
354         */
355         OCStackResult post(const OCRepresentation& representation,
356                         const QueryParamsMap& queryParametersMap, PostCallback attributeHandler,
357                         QualityOfService QoS);
358
359         /**
360         * Function to post on a resource
361         *
362         * @param resourceType resource type of the resource to operate on
363         * @param resourceInterface interface type of the resource to operate on
364         * @param representation representation of the resource
365         * @param queryParametersMap Map which can have the query parameter name and value
366         * @param attributeHandler attribute handler
367         *        The callback function will be invoked with a map of attribute name and values.
368         *        The callback function will also have the result from this Put operation
369         *        This will have error codes.
370         *        The Representation parameter maps which can either have all the attribute names
371         *        and values
372         *        (which will represent entire state of the resource) or a
373         *        set of attribute names and values which needs to be modified
374         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
375         * @note OCStackResult is defined in ocstack.h.
376         *
377         */
378         OCStackResult post(const std::string& resourceType, const std::string& resourceInterface,
379                         const OCRepresentation& representation, const QueryParamsMap& queryParametersMap,
380                         PostCallback attributeHandler);
381         /**
382         * Function to post on a resource
383         *
384         * @param resourceType resource type of the resource to operate on
385         * @param resourceInterface interface type of the resource to operate on
386         * @param representation representation of the resource
387         * @param queryParametersMap Map which can have the query parameter name and value
388         * @param attributeHandler attribute handler
389         *        The callback function will be invoked with a map of attribute name and values.
390         *        The callback function will also have the result from this Put operation
391         *        This will have error codes.
392         *        The Representation parameter maps which can either have all the attribute names
393         *        and values
394         *        (which will represent entire state of the resource) or a
395         *        set of attribute names and values which needs to be modified
396         * @param QoS the quality of communication
397         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
398         * @note OCStackResult is defined in ocstack.h.
399         *
400         */
401         OCStackResult post(const std::string& resourceType, const std::string& resourceInterface,
402                         const OCRepresentation& representation, const QueryParamsMap& queryParametersMap,
403                         PostCallback attributeHandler, QualityOfService QoS);
404
405         /**
406         * Function to perform DELETE operation
407         *
408         * @param deleteHandler handles callback
409         *        The callback function will have headerOptions and result from this Delete
410         *        operation. This will have error codes
411         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
412         * @note OCStackResult is defined in ocstack.h.
413         *
414         */
415         OCStackResult deleteResource(DeleteCallback deleteHandler);
416         OCStackResult deleteResource(DeleteCallback deleteHandler, QualityOfService QoS);
417
418         /**
419         * Function to set observation on the resource
420         *
421         * @param observeType allows the client to specify how it wants to observe.
422         * @param queryParametersMap map which can have the query parameter name and value
423         * @param observeHandler handles callback
424         *        The callback function will be invoked with a map of attribute name and values.
425         *        The callback function will also have the result from this observe operation
426         *        This will have error codes
427         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
428         * @note OCStackResult is defined in ocstack.h.
429         *
430         */
431         OCStackResult observe(ObserveType observeType, const QueryParamsMap& queryParametersMap,
432                         ObserveCallback observeHandler);
433         /**
434         * Function to set observation on the resource
435         *
436         * @param observeType allows the client to specify how it wants to observe.
437         * @param queryParametersMap map which can have the query parameter name and value
438         * @param observeHandler handles callback
439         *        The callback function will be invoked with a map of attribute name and values.
440         *        The callback function will also have the result from this observe operation
441         *        This will have error codes
442         * @param qos the quality of communication
443         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
444         * @note OCStackResult is defined in ocstack.h.
445         *
446         */
447         OCStackResult observe(ObserveType observeType, const QueryParamsMap& queryParametersMap,
448                         ObserveCallback observeHandler, QualityOfService qos);
449
450         /**
451         * Function to cancel the observation on the resource
452         *
453         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
454         * @note OCStackResult is defined in ocstack.h.
455         *
456         */
457         OCStackResult cancelObserve();
458         OCStackResult cancelObserve(QualityOfService qos);
459
460         /**
461         * Function to set header information.
462         * @param headerOptions std::vector where header information(header optionID and optionData
463         * is passed
464         *
465         * @note Once the headers information is set, it will be applicable to GET, PUT and observe
466         * request.
467         * setHeaderOptions can be used multiple times if headers need to be modifed by the client.
468         * Latest headers will be used to send in the request. <br>
469         * @note Initial support is only for two headers. If headerMap consists of more than two
470         * header options, they will be ignored. <br>
471         * Use unsetHeaderOptions API to clear the header information.
472         */
473         void setHeaderOptions(const HeaderOptions& headerOptions);
474
475         /**
476         * Function to unset header options.
477         */
478         void unsetHeaderOptions();
479
480         /**
481         * Function to get the host address of this resource
482         * @return std::string host address
483         * @note This might or might not be exposed in future due to security concerns
484         */
485         std::string host() const;
486
487         /**
488         * Function to get the URI for this resource
489         * @return std::string resource URI
490         */
491         std::string uri() const;
492
493         /**
494         * Function to get the connectivity type of this resource
495         * @return enum connectivity type (flags and adapter)
496         */
497         OCConnectivityType connectivityType() const;
498
499         /**
500         * Function to provide ability to check if this resource is observable or not
501         * @return bool true indicates resource is observable; false indicates resource is
502         *         not observable.
503         */
504         bool isObservable() const;
505
506 #ifdef WITH_MQ
507         /**
508         * Function to provide ability to check if this resource is publisher or not
509         * @return bool true indicates resource is publisher; false indicates resource is
510         *         not publisher.
511         */
512         bool isPublish() const;
513 #endif
514
515         /**
516         * Function to get the list of resource types
517         * @return vector of resource types
518         */
519         std::vector<std::string> getResourceTypes() const;
520
521         /**
522         * Function to get the list of resource interfaces
523         * @return vector of resource interface
524         */
525         std::vector<std::string> getResourceInterfaces(void) const;
526
527         // TODO-CA Revisit this since we are exposing two identifiers
528         /**
529         * Function to get a unique identifier for this
530         * resource across network interfaces.  This will
531         * be guaranteed unique for every resource-per-server
532         * independent of how this was discovered.
533         * @return OCResourceIdentifier object, which can
534         * be used for all comparison and hashing.
535         */
536         OCResourceIdentifier uniqueIdentifier() const;
537
538         /**
539         * Function to get a string representation of the resource's server ID.
540         * This is unique per- server independent on how it was discovered.
541         * @note The format of the return value is subject to change and will
542         * likely change both in size and contents in the future.
543         */
544         std::string sid() const;
545
546 #ifdef WITH_MQ
547         /**
548         * Function to discovery Topics from MQ Broker.
549         *
550         * @param queryParametersMap map which can have the query parameter name and value
551         * @param attributeHandler handles callback
552         * @param qos the quality of communication
553         *
554         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
555         * @note OCStackResult is defined in ocstack.h.
556         *
557         */
558         OCStackResult discoveryMQTopics(const QueryParamsMap& queryParametersMap,
559                                         MQTopicCallback attributeHandler,
560                                         QualityOfService qos);
561         /**
562         * Function to create Topic into MQ Broker.
563         * SubTopic is also created through this method.
564         *
565         * @param rep representation of the topic
566         * @param topicUri new uri of the topic which want to create
567         * @param queryParametersMap map which can have the query parameter name and value
568         * @param attributeHandler handles callback
569         * @param qos the quality of communication
570         *
571         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
572         * @note OCStackResult is defined in ocstack.h.
573         *
574         */
575         OCStackResult createMQTopic(const OCRepresentation& rep,
576                                     const std::string& topicUri,
577                                     const QueryParamsMap& queryParametersMap,
578                                     MQTopicCallback attributeHandler,
579                                     QualityOfService qos);
580 #endif
581 #ifdef MQ_SUBSCRIBER
582         /**
583         * Function to subscribe Topic to MQ Broker.
584         *
585         * @param observeType allows the client to specify how it wants to observe.
586         * @param queryParametersMap map which can have the query parameter name and value
587         * @param observeHandler handles callback
588         * @param qos the quality of communication
589         *
590         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
591         * @note OCStackResult is defined in ocstack.h.
592         *
593         */
594         OCStackResult subscribeMQTopic(ObserveType observeType,
595                                        const QueryParamsMap& queryParametersMap,
596                                        ObserveCallback observeHandler,
597                                        QualityOfService qos);
598
599         /**
600         * Function to unsubscribe Topic to MQ Broker.
601         *
602         * @param qos the quality of communication
603         *
604         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
605         * @note OCStackResult is defined in ocstack.h.
606         *
607         */
608         OCStackResult unsubscribeMQTopic(QualityOfService qos);
609
610         /**
611         * Function to request publish to MQ publisher.
612         * Publisher can confirm the request message as key:"req_pub" and value:"true".
613         *
614         * @param queryParametersMap map which can have the query parameter name and value
615         * @param attributeHandler handles callback
616         * @param qos the quality of communication
617         *
618         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
619         * @note OCStackResult is defined in ocstack.h.
620         *
621         */
622         OCStackResult requestMQPublish(const QueryParamsMap& queryParametersMap,
623                                        PostCallback attributeHandler,
624                                        QualityOfService qos);
625 #endif
626 #ifdef MQ_PUBLISHER
627         /**
628         * Function to publish Topic information into MQ Broker.
629         *
630         * @param rep representation of the topic
631         * @param queryParametersMap map which can have the query parameter name and value
632         * @param attributeHandler handles callback
633         * @param qos the quality of communication
634         *
635         * @return Returns  ::OC_STACK_OK on success, some other value upon failure.
636         * @note OCStackResult is defined in ocstack.h.
637         *
638         */
639         OCStackResult publishMQTopic(const OCRepresentation& rep,
640                                      const QueryParamsMap& queryParametersMap,
641                                      PostCallback attributeHandler,
642                                      QualityOfService qos);
643 #endif
644         // overloaded operators allow for putting into a 'set'
645         // the uniqueidentifier allows for putting into a hash
646         bool operator==(const OCResource &other) const;
647
648         bool operator!=(const OCResource &other) const;
649
650         bool operator<(const OCResource &other) const;
651
652         bool operator>(const OCResource &other) const;
653
654         bool operator<=(const OCResource &other) const;
655
656         bool operator>=(const OCResource &other) const;
657
658     private:
659         void setHost(const std::string& host);
660         std::weak_ptr<IClientWrapper> m_clientWrapper;
661         std::string m_uri;
662         OCResourceIdentifier m_resourceId;
663         OCDevAddr m_devAddr;
664         bool m_useHostString;
665         bool m_isCollection;
666         uint8_t m_property;
667         std::vector<std::string> m_resourceTypes;
668         std::vector<std::string> m_interfaces;
669         std::vector<std::string> m_children;
670         OCDoHandle m_observeHandle;
671         HeaderOptions m_headerOptions;
672
673     private:
674         OCResource(std::weak_ptr<IClientWrapper> clientWrapper,
675                     const OCDevAddr& devAddr, const std::string& uri,
676                     const std::string& serverId, uint8_t property,
677                     const std::vector<std::string>& resourceTypes,
678                     const std::vector<std::string>& interfaces);
679
680         OCResource(std::weak_ptr<IClientWrapper> clientWrapper,
681                     const std::string& host, const std::string& uri,
682                     const std::string& serverId,
683                     OCConnectivityType connectivityType, uint8_t property,
684                     const std::vector<std::string>& resourceTypes,
685                     const std::vector<std::string>& interfaces);
686     };
687
688 } // namespace OC
689
690 #endif // OC_RESOURCE_H
691