X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fsrc%2FOCResource.cpp;h=2ad836ad687614dc5170e938e37f78e3b05ca2c1;hb=935fdb9b67b6c10d007e652e9e2e028fd6ccfe09;hp=df5ff60be36d8cf559fab4d78116d17c99939931;hpb=00b3660e45c56cb3db35dc2596a054f801b5591a;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/src/OCResource.cpp b/resource/src/OCResource.cpp index df5ff60..2ad836a 100644 --- a/resource/src/OCResource.cpp +++ b/resource/src/OCResource.cpp @@ -21,6 +21,8 @@ #include "OCResource.h" #include "OCUtilities.h" +#include + namespace OC { using OC::nil_guard; @@ -28,9 +30,14 @@ using OC::result_guard; using OC::checked_guard; OCResource::OCResource(std::weak_ptr clientWrapper, const std::string& host, - const std::string& uri, bool observable, const std::vector& resourceTypes, + const std::string& uri, const std::string& serverId, + OCConnectivityType connectivityType, bool observable, + const std::vector& resourceTypes, const std::vector& interfaces) - : m_clientWrapper(clientWrapper), m_uri(uri), m_host(host), m_isObservable(observable), + : m_clientWrapper(clientWrapper), m_uri(uri), m_resourceId(serverId, m_uri), + m_host(host), + m_connectivityType(connectivityType), + m_isObservable(observable), m_isCollection(false), m_resourceTypes(resourceTypes), m_interfaces(interfaces), m_observeHandle(nullptr) { @@ -55,7 +62,8 @@ OCStackResult OCResource::get(const QueryParamsMap& queryParametersMap, GetCallback attributeHandler, QualityOfService QoS) { return checked_guard(m_clientWrapper.lock(), &IClientWrapper::GetResourceRepresentation, - m_host, m_uri, queryParametersMap, m_headerOptions, attributeHandler, QoS); + m_host, m_uri, m_connectivityType, queryParametersMap, m_headerOptions, + attributeHandler, QoS); } OCStackResult OCResource::get(const QueryParamsMap& queryParametersMap, @@ -99,7 +107,8 @@ OCStackResult OCResource::put(const OCRepresentation& rep, QualityOfService QoS) { return checked_guard(m_clientWrapper.lock(), &IClientWrapper::PutResourceRepresentation, - m_host, m_uri, rep, queryParametersMap, m_headerOptions, attributeHandler, QoS); + m_host, m_uri, m_connectivityType, rep, queryParametersMap, + m_headerOptions, attributeHandler, QoS); } OCStackResult OCResource::put(const OCRepresentation& rep, @@ -148,7 +157,8 @@ OCStackResult OCResource::post(const OCRepresentation& rep, QualityOfService QoS) { return checked_guard(m_clientWrapper.lock(), &IClientWrapper::PostResourceRepresentation, - m_host, m_uri, rep, queryParametersMap, m_headerOptions, attributeHandler, QoS); + m_host, m_uri, m_connectivityType, rep, queryParametersMap, + m_headerOptions, attributeHandler, QoS); } OCStackResult OCResource::post(const OCRepresentation& rep, @@ -195,7 +205,7 @@ OCStackResult OCResource::post(const std::string& resourceType, OCStackResult OCResource::deleteResource(DeleteCallback deleteHandler, QualityOfService QoS) { return checked_guard(m_clientWrapper.lock(), &IClientWrapper::DeleteResource, - m_host, m_uri, m_headerOptions, deleteHandler, QoS); + m_host, m_uri, m_connectivityType, m_headerOptions, deleteHandler, QoS); } OCStackResult OCResource::deleteResource(DeleteCallback deleteHandler) @@ -217,7 +227,8 @@ OCStackResult OCResource::observe(ObserveType observeType, return checked_guard(m_clientWrapper.lock(), &IClientWrapper::ObserveResource, observeType, &m_observeHandle, m_host, - m_uri, queryParametersMap, m_headerOptions, observeHandler, QoS); + m_uri, m_connectivityType, queryParametersMap, m_headerOptions, + observeHandler, QoS); } OCStackResult OCResource::observe(ObserveType observeType, @@ -265,9 +276,103 @@ std::string OCResource::uri() const return m_uri; } +OCConnectivityType OCResource::connectivityType() const +{ + return m_connectivityType; +} + bool OCResource::isObservable() const { return m_isObservable; } + +OCResourceIdentifier OCResource::uniqueIdentifier() const +{ + return m_resourceId; +} + +std::string OCResource::sid() const +{ + return this->uniqueIdentifier().m_representation; +} + +bool OCResource::operator==(const OCResource &other) const +{ + return m_resourceId == other.m_resourceId; +} + +bool OCResource::operator!=(const OCResource &other) const +{ + return m_resourceId != other.m_resourceId; +} + +bool OCResource::operator<(const OCResource &other) const +{ + return m_resourceId < other.m_resourceId; +} + +bool OCResource::operator>(const OCResource &other) const +{ + return m_resourceId > other.m_resourceId; +} + +bool OCResource::operator<=(const OCResource &other) const +{ + return m_resourceId <= other.m_resourceId; +} + +bool OCResource::operator>=(const OCResource &other) const +{ + return m_resourceId >= other.m_resourceId; +} + +OCResourceIdentifier::OCResourceIdentifier(const std::string& wireServerIdentifier, + const std::string& resourceUri) + :m_representation(wireServerIdentifier), m_resourceUri(resourceUri) +{ +} + +std::ostream& operator <<(std::ostream& os, const OCResourceIdentifier& ri) +{ + + os << ri.m_representation<(const OCResourceIdentifier &other) const +{ + return *this != other && !(*this other); +} + +bool OCResourceIdentifier::operator>=(const OCResourceIdentifier &other) const +{ + return !(*this < other); +} + } // namespace OC +