{"action":"created","comment":{"url":"https://api.github.com/repos/01org/parameter-framework/pulls/comments/35874310","id":35874310,"diff_hunk":"@@ -0,0 +1,349 @@\n+/*\n+ * Copyright (c) 2014-2015, Intel Corporation\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without modification,\n+ * are permitted provided that the following conditions are met:\n+ *\n+ * 1. Redistributions of source code must retain the above copyright notice, this\n+ * list of conditions and the following disclaimer.\n+ *\n+ * 2. Redistributions in binary form must reproduce the above copyright notice,\n+ * this list of conditions and the following disclaimer in the documentation and/or\n+ * other materials provided with the distribution.\n+ *\n+ * 3. Neither the name of the copyright holder nor the names of its contributors\n+ * may be used to endorse or promote products derived from this software without\n+ * specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\n+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n+ * LOSS OF USE, Value, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+#include \"FloatingPointParameterType.h\"\n+#include <sstream>\n+#include <iomanip>\n+#include \"ParameterAccessContext.h\"\n+#include \"ConfigurationAccessContext.h\"\n+#include <limits>\n+#include <climits>\n+#include \"convert.hpp\"\n+#include \"Utility.h\"\n+\n+using std::string;\n+\n+CFloatingPointParameterType::CFloatingPointParameterType(const string& strName)\n+    : base(strName),\n+      _fMin(-std::numeric_limits<float>::max()),\n+      _fMax(std::numeric_limits<float>::max())\n+{\n+}\n+\n+string CFloatingPointParameterType::getKind() const\n+{\n+    return \"FloatingPointParameter\";\n+}\n+\n+// Element properties\n+void CFloatingPointParameterType::showProperties(string& strResult) const\n+{\n+    base::showProperties(strResult);\n+\n+    // Notation\n+    strResult += \"Min:\";\n+    strResult += CUtility::toString(_fMin);\n+    strResult += \"\\n\";\n+    strResult += \"Max:\";\n+    strResult += CUtility::toString(_fMax);\n+    strResult += \"\\n\";\n+}\n+\n+// XML Serialization value space handling\n+// Value space handling for configuration import\n+void CFloatingPointParameterType::handleValueSpaceAttribute(\n+        CXmlElement& xmlConfigurableElementSettingsElement,\n+        CConfigurationAccessContext& configurationAccessContext) const\n+{\n+    // Direction?\n+    if (!configurationAccessContext.serializeOut()) {\n+\n+        string strValueSpace;\n+\n+        // Get Value space from XML\n+        if (xmlConfigurableElementSettingsElement.getAttribute(\"ValueSpace\", strValueSpace)) {\n+\n+            configurationAccessContext.setValueSpaceRaw(strValueSpace == \"Raw\");\n+        } else {\n+\n+            configurationAccessContext.setValueSpaceRaw(false);\n+        }\n+    } else {\n+        // Provide value space only if not the default one\n+        if (configurationAccessContext.valueSpaceIsRaw()) {\n+\n+            xmlConfigurableElementSettingsElement.setAttribute(\"ValueSpace\", \"Raw\");\n+        }\n+    }\n+}\n+\n+bool CFloatingPointParameterType::fromXml(const CXmlElement& xmlElement,\n+                                          CXmlSerializingContext& serializingContext)\n+{\n+    // Size. The XSD fixes it to 32\n+    uint32_t uiSizeInBits = 32;\n+    xmlElement.getAttribute(\"Size\", uiSizeInBits);\n+\n+    // Size support check\n+    if (uiSizeInBits != sizeof(float) * CHAR_BIT) {\n+\n+        serializingContext.setError(\"Unsupported size (\" + CUtility::toString(uiSizeInBits) +\n+            \") for \" + getKind() + \" \" + xmlElement.getPath() + \". For now, only 32 is supported.\");\n+\n+        return false;\n+    }\n+\n+    // Set the size\n+    setSize(uiSizeInBits / CHAR_BIT);\n+\n+    // Bounds\n+    xmlElement.getAttribute(\"Min\", _fMin);\n+    xmlElement.getAttribute(\"Max\", _fMax);\n+\n+    if (_fMin > _fMax) {\n+        serializingContext.setError(\"Min (\" + CUtility::toString(_fMin) +\n+                \") can't be greater than Max (\" + CUtility::toString(_fMax) + \")\");\n+        return false;\n+    }\n+\n+    return base::fromXml(xmlElement, serializingContext);\n+}\n+\n+bool CFloatingPointParameterType::toBlackboard(\n+        const string& strValue,\n+        uint32_t& uiValue,\n+        CParameterAccessContext& parameterAccessContext) const\n+{\n+    // Check Value integrity\n+    if (CUtility::isHexadecimal(strValue) && !parameterAccessContext.valueSpaceIsRaw()) {\n+\n+        parameterAccessContext.setError(\"Hexadecimal values are not supported for \"\n+                                        + getKind()\n+                                        + \" when selected value space is real: \"\n+                                        + strValue);\n+\n+        return false;\n+    }\n+\n+    if (parameterAccessContext.valueSpaceIsRaw()) {\n+\n+        uint32_t uiData;\n+\n+        // Intepret data\n+        if (!convertTo(strValue, uiData)) {\n+\n+            parameterAccessContext.setError(\"Value \" + strValue + \" is invalid\");\n+\n+            return false;\n+        }\n+\n+        // Reinterpret as float\n+        float fData = reinterpret_cast<const float&>(uiData);\n+\n+        // Check against NaN\n+        if (fData != fData) {\n+\n+            parameterAccessContext.setError(\"Value \" + strValue + \" is not a number\");\n+\n+            return false;\n+        }\n+\n+        // Check against range\n+        if (!checkValueAgainstRange(fData)) {\n+\n+            setOutOfRangeError(strValue, parameterAccessContext);\n+\n+            return false;\n+        }\n+\n+        uiValue = uiData;\n+\n+        return true;\n+    }\n+    else {\n+\n+        float fValue;\n+\n+        // Intepret data\n+        if (!convertTo(strValue, fValue)) {\n+\n+            parameterAccessContext.setError(\"Value \" + strValue + \" is invalid\");\n+\n+            return false;\n+        }\n+\n+        // Check against range","path":"parameter/FloatingPointParameterType.cpp","position":191,"original_position":191,"commit_id":"32a069a2f8932707bbb8276ae1faa2a2fd3f4c54","original_commit_id":"32a069a2f8932707bbb8276ae1faa2a2fd3f4c54","user":{"login":"dawagner","id":6430928,"avatar_url":"https://avatars.githubusercontent.com/u/6430928?v=3","gravatar_id":"","url":"https://api.github.com/users/dawagner","html_url":"https://github.com/dawagner","followers_url":"https://api.github.com/users/dawagner/followers","following_url":"https://api.github.com/users/dawagner/following{/other_user}","gists_url":"https://api.github.com/users/dawagner/gists{/gist_id}","starred_url":"https://api.github.com/users/dawagner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dawagner/subscriptions","organizations_url":"https://api.github.com/users/dawagner/orgs","repos_url":"https://api.github.com/users/dawagner/repos","events_url":"https://api.github.com/users/dawagner/events{/privacy}","received_events_url":"https://api.github.com/users/dawagner/received_events","type":"User","site_admin":false},"body":"done","created_at":"2015-07-30T14:15:52Z","updated_at":"2015-07-30T14:15:52Z","html_url":"https://github.com/01org/parameter-framework/pull/152#discussion_r35874310","pull_request_url":"https://api.github.com/repos/01org/parameter-framework/pulls/152","_links":{"self":{"href":"https://api.github.com/repos/01org/parameter-framework/pulls/comments/35874310"},"html":{"href":"https://github.com/01org/parameter-framework/pull/152#discussion_r35874310"},"pull_request":{"href":"https://api.github.com/repos/01org/parameter-framework/pulls/152"}}},"pull_request":{"url":"https://api.github.com/repos/01org/parameter-framework/pulls/152","id":40548505,"html_url":"https://github.com/01org/parameter-framework/pull/152","diff_url":"https://github.com/01org/parameter-framework/pull/152.diff","patch_url":"https://github.com/01org/parameter-framework/pull/152.patch","issue_url":"https://api.github.com/repos/01org/parameter-framework/issues/152","number":152,"state":"open","locked":false,"title":"Add Floating point parameters","user":{"login":"dawagner","id":6430928,"avatar_url":"https://avatars.githubusercontent.com/u/6430928?v=3","gravatar_id":"","url":"https://api.github.com/users/dawagner","html_url":"https://github.com/dawagner","followers_url":"https://api.github.com/users/dawagner/followers","following_url":"https://api.github.com/users/dawagner/following{/other_user}","gists_url":"https://api.github.com/users/dawagner/gists{/gist_id}","starred_url":"https://api.github.com/users/dawagner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dawagner/subscriptions","organizations_url":"https://api.github.com/users/dawagner/orgs","repos_url":"https://api.github.com/users/dawagner/repos","events_url":"https://api.github.com/users/dawagner/events{/privacy}","received_events_url":"https://api.github.com/users/dawagner/received_events","type":"User","site_admin":false},"body":"Add support for floating point parameters\r\n\r\nThe get/setAttribute inner API is reworked as preparative work.\r\n\r\nFunctional tests for this new parameter type are also added.","created_at":"2015-07-22T10:01:40Z","updated_at":"2015-07-30T14:15:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2ee3ce59523c96dd7eef1164b9cbe0cec0b8acb7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/01org/parameter-framework/pulls/152/commits","review_comments_url":"https://api.github.com/repos/01org/parameter-framework/pulls/152/comments","review_comment_url":"https://api.github.com/repos/01org/parameter-framework/pulls/comments{/number}","comments_url":"https://api.github.com/repos/01org/parameter-framework/issues/152/comments","statuses_url":"https://api.github.com/repos/01org/parameter-framework/statuses/32a069a2f8932707bbb8276ae1faa2a2fd3f4c54","head":{"label":"dawagner:floating-point","ref":"floating-point","sha":"32a069a2f8932707bbb8276ae1faa2a2fd3f4c54","user":{"login":"dawagner","id":6430928,"avatar_url":"https://avatars.githubusercontent.com/u/6430928?v=3","gravatar_id":"","url":"https://api.github.com/users/dawagner","html_url":"https://github.com/dawagner","followers_url":"https://api.github.com/users/dawagner/followers","following_url":"https://api.github.com/users/dawagner/following{/other_user}","gists_url":"https://api.github.com/users/dawagner/gists{/gist_id}","starred_url":"https://api.github.com/users/dawagner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dawagner/subscriptions","organizations_url":"https://api.github.com/users/dawagner/orgs","repos_url":"https://api.github.com/users/dawagner/repos","events_url":"https://api.github.com/users/dawagner/events{/privacy}","received_events_url":"https://api.github.com/users/dawagner/received_events","type":"User","site_admin":false},"repo":{"id":29674215,"name":"parameter-framework","full_name":"dawagner/parameter-framework","owner":{"login":"dawagner","id":6430928,"avatar_url":"https://avatars.githubusercontent.com/u/6430928?v=3","gravatar_id":"","url":"https://api.github.com/users/dawagner","html_url":"https://github.com/dawagner","followers_url":"https://api.github.com/users/dawagner/followers","following_url":"https://api.github.com/users/dawagner/following{/other_user}","gists_url":"https://api.github.com/users/dawagner/gists{/gist_id}","starred_url":"https://api.github.com/users/dawagner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dawagner/subscriptions","organizations_url":"https://api.github.com/users/dawagner/orgs","repos_url":"https://api.github.com/users/dawagner/repos","events_url":"https://api.github.com/users/dawagner/events{/privacy}","received_events_url":"https://api.github.com/users/dawagner/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dawagner/parameter-framework","description":"Plugin-based and rule-based framework for describing and controlling parameters","fork":true,"url":"https://api.github.com/repos/dawagner/parameter-framework","forks_url":"https://api.github.com/repos/dawagner/parameter-framework/forks","keys_url":"https://api.github.com/repos/dawagner/parameter-framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dawagner/parameter-framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dawagner/parameter-framework/teams","hooks_url":"https://api.github.com/repos/dawagner/parameter-framework/hooks","issue_events_url":"https://api.github.com/repos/dawagner/parameter-framework/issues/events{/number}","events_url":"https://api.github.com/repos/dawagner/parameter-framework/events","assignees_url":"https://api.github.com/repos/dawagner/parameter-framework/assignees{/user}","branches_url":"https://api.github.com/repos/dawagner/parameter-framework/branches{/branch}","tags_url":"https://api.github.com/repos/dawagner/parameter-framework/tags","blobs_url":"https://api.github.com/repos/dawagner/parameter-framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dawagner/parameter-framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dawagner/parameter-framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/dawagner/parameter-framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dawagner/parameter-framework/statuses/{sha}","languages_url":"https://api.github.com/repos/dawagner/parameter-framework/languages","stargazers_url":"https://api.github.com/repos/dawagner/parameter-framework/stargazers","contributors_url":"https://api.github.com/repos/dawagner/parameter-framework/contributors","subscribers_url":"https://api.github.com/repos/dawagner/parameter-framework/subscribers","subscription_url":"https://api.github.com/repos/dawagner/parameter-framework/subscription","commits_url":"https://api.github.com/repos/dawagner/parameter-framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/dawagner/parameter-framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/dawagner/parameter-framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/dawagner/parameter-framework/issues/comments{/number}","contents_url":"https://api.github.com/repos/dawagner/parameter-framework/contents/{+path}","compare_url":"https://api.github.com/repos/dawagner/parameter-framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dawagner/parameter-framework/merges","archive_url":"https://api.github.com/repos/dawagner/parameter-framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dawagner/parameter-framework/downloads","issues_url":"https://api.github.com/repos/dawagner/parameter-framework/issues{/number}","pulls_url":"https://api.github.com/repos/dawagner/parameter-framework/pulls{/number}","milestones_url":"https://api.github.com/repos/dawagner/parameter-framework/milestones{/number}","notifications_url":"https://api.github.com/repos/dawagner/parameter-framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dawagner/parameter-framework/labels{/name}","releases_url":"https://api.github.com/repos/dawagner/parameter-framework/releases{/id}","created_at":"2015-01-22T10:54:57Z","updated_at":"2015-04-24T08:50:14Z","pushed_at":"2015-07-29T14:33:28Z","git_url":"git://github.com/dawagner/parameter-framework.git","ssh_url":"git@github.com:dawagner/parameter-framework.git","clone_url":"https://github.com/dawagner/parameter-framework.git","svn_url":"https://github.com/dawagner/parameter-framework","homepage":"","size":36361,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"01org:master","ref":"master","sha":"b03e972701aeb7ffe1047c21a019e2d5c7c7bc5c","user":{"login":"01org","id":1635439,"avatar_url":"https://avatars.githubusercontent.com/u/1635439?v=3","gravatar_id":"","url":"https://api.github.com/users/01org","html_url":"https://github.com/01org","followers_url":"https://api.github.com/users/01org/followers","following_url":"https://api.github.com/users/01org/following{/other_user}","gists_url":"https://api.github.com/users/01org/gists{/gist_id}","starred_url":"https://api.github.com/users/01org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/01org/subscriptions","organizations_url":"https://api.github.com/users/01org/orgs","repos_url":"https://api.github.com/users/01org/repos","events_url":"https://api.github.com/users/01org/events{/privacy}","received_events_url":"https://api.github.com/users/01org/received_events","type":"Organization","site_admin":false},"repo":{"id":16009363,"name":"parameter-framework","full_name":"01org/parameter-framework","owner":{"login":"01org","id":1635439,"avatar_url":"https://avatars.githubusercontent.com/u/1635439?v=3","gravatar_id":"","url":"https://api.github.com/users/01org","html_url":"https://github.com/01org","followers_url":"https://api.github.com/users/01org/followers","following_url":"https://api.github.com/users/01org/following{/other_user}","gists_url":"https://api.github.com/users/01org/gists{/gist_id}","starred_url":"https://api.github.com/users/01org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/01org/subscriptions","organizations_url":"https://api.github.com/users/01org/orgs","repos_url":"https://api.github.com/users/01org/repos","events_url":"https://api.github.com/users/01org/events{/privacy}","received_events_url":"https://api.github.com/users/01org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/01org/parameter-framework","description":"Plugin-based and rule-based framework for describing and controlling parameters","fork":false,"url":"https://api.github.com/repos/01org/parameter-framework","forks_url":"https://api.github.com/repos/01org/parameter-framework/forks","keys_url":"https://api.github.com/repos/01org/parameter-framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/01org/parameter-framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/01org/parameter-framework/teams","hooks_url":"https://api.github.com/repos/01org/parameter-framework/hooks","issue_events_url":"https://api.github.com/repos/01org/parameter-framework/issues/events{/number}","events_url":"https://api.github.com/repos/01org/parameter-framework/events","assignees_url":"https://api.github.com/repos/01org/parameter-framework/assignees{/user}","branches_url":"https://api.github.com/repos/01org/parameter-framework/branches{/branch}","tags_url":"https://api.github.com/repos/01org/parameter-framework/tags","blobs_url":"https://api.github.com/repos/01org/parameter-framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/01org/parameter-framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/01org/parameter-framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/01org/parameter-framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/01org/parameter-framework/statuses/{sha}","languages_url":"https://api.github.com/repos/01org/parameter-framework/languages","stargazers_url":"https://api.github.com/repos/01org/parameter-framework/stargazers","contributors_url":"https://api.github.com/repos/01org/parameter-framework/contributors","subscribers_url":"https://api.github.com/repos/01org/parameter-framework/subscribers","subscription_url":"https://api.github.com/repos/01org/parameter-framework/subscription","commits_url":"https://api.github.com/repos/01org/parameter-framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/01org/parameter-framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/01org/parameter-framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/01org/parameter-framework/issues/comments{/number}","contents_url":"https://api.github.com/repos/01org/parameter-framework/contents/{+path}","compare_url":"https://api.github.com/repos/01org/parameter-framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/01org/parameter-framework/merges","archive_url":"https://api.github.com/repos/01org/parameter-framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/01org/parameter-framework/downloads","issues_url":"https://api.github.com/repos/01org/parameter-framework/issues{/number}","pulls_url":"https://api.github.com/repos/01org/parameter-framework/pulls{/number}","milestones_url":"https://api.github.com/repos/01org/parameter-framework/milestones{/number}","notifications_url":"https://api.github.com/repos/01org/parameter-framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/01org/parameter-framework/labels{/name}","releases_url":"https://api.github.com/repos/01org/parameter-framework/releases{/id}","created_at":"2014-01-17T19:24:01Z","updated_at":"2015-07-11T10:04:10Z","pushed_at":"2015-07-30T08:33:31Z","git_url":"git://github.com/01org/parameter-framework.git","ssh_url":"git@github.com:01org/parameter-framework.git","clone_url":"https://github.com/01org/parameter-framework.git","svn_url":"https://github.com/01org/parameter-framework","homepage":"","size":48780,"stargazers_count":10,"watchers_count":10,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":20,"mirror_url":null,"open_issues_count":19,"forks":20,"open_issues":19,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/01org/parameter-framework/pulls/152"},"html":{"href":"https://github.com/01org/parameter-framework/pull/152"},"issue":{"href":"https://api.github.com/repos/01org/parameter-framework/issues/152"},"comments":{"href":"https://api.github.com/repos/01org/parameter-framework/issues/152/comments"},"review_comments":{"href":"https://api.github.com/repos/01org/parameter-framework/pulls/152/comments"},"review_comment":{"href":"https://api.github.com/repos/01org/parameter-framework/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/01org/parameter-framework/pulls/152/commits"},"statuses":{"href":"https://api.github.com/repos/01org/parameter-framework/statuses/32a069a2f8932707bbb8276ae1faa2a2fd3f4c54"}}}}