X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Finclude%2FOCRepresentation.h;h=f37ea45a6b83754257bf4c392c62cf05f0006365;hb=refs%2Ftags%2Ftizen_4.0.m2_release;hp=5f2071a5b85daec9096fd6cd4fceead00759e97c;hpb=04d50bb11e47b497f4e348cbb1abf134162e6c10;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/include/OCRepresentation.h b/resource/include/OCRepresentation.h index 5f2071a..f37ea45 100644 --- a/resource/include/OCRepresentation.h +++ b/resource/include/OCRepresentation.h @@ -28,7 +28,6 @@ #ifndef OC_REPRESENTATION_H_ #define OC_REPRESENTATION_H_ - #include #include #include @@ -62,10 +61,6 @@ namespace OC public: void setPayload(const OCPayload* rep); - void setPayload(const OCDevicePayload* rep); - - void setPayload(const OCPlatformPayload* rep); - void setPayload(const OCRepPayload* rep); OCRepPayload* getPayload() const; @@ -99,17 +94,32 @@ namespace OC // this fix will work in the meantime. OCRepresentation(): m_interfaceType(InterfaceType::None){} +#if defined(_MSC_VER) && (_MSC_VER < 1900) + OCRepresentation(OCRepresentation&& o) + { + std::memmove(this, &o, sizeof(o)); + } +#else OCRepresentation(OCRepresentation&&) = default; +#endif OCRepresentation(const OCRepresentation&) = default; OCRepresentation& operator=(const OCRepresentation&) = default; +#if defined(_MSC_VER) && (_MSC_VER < 1900) + OCRepresentation& operator=(OCRepresentation&& o) + { + std::memmove(this, &o, sizeof(o)); + return *this; + } +#else OCRepresentation& operator=(OCRepresentation&&) = default; +#endif virtual ~OCRepresentation(){} - void setDevAddr(const OCDevAddr addr); + void setDevAddr(const OCDevAddr&); const std::string getHost() const; @@ -131,6 +141,8 @@ namespace OC const std::vector& getResourceTypes() const; + const std::vector& getDataModelVersions() const; + void setResourceTypes(const std::vector& resourceTypes); void addResourceType(const std::string& str); @@ -141,6 +153,8 @@ namespace OC void addResourceInterface(const std::string& str); + void addDataModelVersion(const std::string& str); + bool emptyData() const; int numberOfAttributes() const; @@ -160,6 +174,10 @@ namespace OC m_values[str] = std::forward(val); } + const std::map& getValues() const { + return m_values; + } + /** * Retrieve the attribute value associated with the supplied name * @@ -177,8 +195,16 @@ namespace OC { try { - val = boost::get(x->second); - return true; + if (x->second.type() == typeid(T)) + { + val = boost::get(x->second); + return true; + } + else + { + val = T(); + return false; + } } catch (boost::bad_get& e) { @@ -210,7 +236,14 @@ namespace OC { try { - val = boost::get(x->second); + if (x->second.type() == typeid(T)) + { + val = boost::get(x->second); + } + else + { + return val; + } } catch (boost::bad_get& e) { @@ -272,15 +305,23 @@ namespace OC template T getValue() const { + T val = T(); try { - return boost::get(m_values[m_attrName]); + if (m_values[m_attrName].type() == typeid(T)) + { + val = boost::get(m_values[m_attrName]); + } + else + { + return val; + } } catch (boost::bad_get& e) { - T val = T(); return val; } + return val; } std::string getValueToString() const; @@ -302,12 +343,42 @@ namespace OC // Enable-if required to prevent conversions to alternate types. This prevents // ambigious conversions in the case where conversions can include a number of // types, such as the string constructor. +#if (defined(_MSC_VER) ) || (defined(__GNUC__) && (__GNUC__ <= 5)) + template::value || + std::is_same::value || + std::is_same::value || + std::is_same::value || + std::is_same::value || + std::is_same::value || + std::is_same>::value || + std::is_same>>::value || + std::is_same>>>::value || + std::is_same>::value || + std::is_same>>::value || + std::is_same>>>::value || + std::is_same>::value || + std::is_same>>::value || + std::is_same>>>::value || + std::is_same>::value || + std::is_same>>::value || + std::is_same>>>::value || + std::is_same>::value || + std::is_same>>::value || + std::is_same>>>::value || + std::is_same>::value || + std::is_same>>::value || + std::is_same>>>::value + , int>::type = 0// enable_if + > +#else template::type >::value , int>::type = 0 > +#endif operator T() const { return this->getValue(); @@ -452,6 +523,7 @@ namespace OC mutable std::map m_values; std::vector m_resourceTypes; std::vector m_interfaces; + std::vector m_dataModelVersions; InterfaceType m_interfaceType; }; @@ -461,4 +533,3 @@ namespace OC #endif // OC_REPRESENTATION_H_ -