| David Wagner | b76c9d6 | 2014-02-05 18:30:24 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011-2014, Intel Corporation |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without modification, |
| 6 | * are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, this |
| 9 | * list of conditions and the following disclaimer. |
| 10 | * |
| 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 12 | * this list of conditions and the following disclaimer in the documentation and/or |
| 13 | * other materials provided with the distribution. |
| 14 | * |
| 15 | * 3. Neither the name of the copyright holder nor the names of its contributors |
| 16 | * may be used to endorse or promote products derived from this software without |
| 17 | * specific prior written permission. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
| 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 29 | */ |
| 30 | #pragma once |
| 31 | |
| 32 | #include <stdint.h> |
| 33 | #include <string> |
| 34 | #include <vector> |
| 35 | |
| 36 | class CBaseParameter; |
| 37 | class CParameterMgr; |
| 38 | |
| 39 | class CParameterHandle |
| 40 | { |
| 41 | public: |
| 42 | CParameterHandle(const CBaseParameter* pParameter, CParameterMgr* pParameterMgr); |
| 43 | |
| 44 | // Parameter features |
| 45 | bool isRogue() const; |
| 46 | bool isArray() const; |
| 47 | // Array Length |
| 48 | uint32_t getArrayLength() const; // Returns 0 for scalar |
| 49 | // Parameter path |
| 50 | std::string getPath() const; |
| 51 | // Parameter kind |
| 52 | std::string getKind() const; |
| 53 | |
| 54 | // Boolean access |
| 55 | bool setAsBoolean(bool bValue, std::string& strError); |
| Frédéric Boisnard | dfbd7a6 | 2013-07-31 17:37:20 +0200 | [diff] [blame] | 56 | |
| 57 | /** |
| 58 | * Fetch the parameter value as a boolean. |
| 59 | * |
| 60 | * @param bValue Reference to a boolean variable where the value will be stored |
| 61 | * @param strError Error message if a problem occured |
| 62 | * |
| 63 | * @return true on success, false otherwise |
| 64 | */ |
| 65 | bool getAsBoolean(bool& bValue, std::string& strError) const; |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 66 | bool setAsBooleanArray(const std::vector<bool>& abValues, std::string& strError); |
| 67 | bool getAsBooleanArray(std::vector<bool>& abValues, std::string& strError) const; |
| 68 | |
| 69 | // Integer Access |
| 70 | bool setAsInteger(uint32_t uiValue, std::string& strError); |
| 71 | bool getAsInteger(uint32_t& uiValue, std::string& strError) const; |
| 72 | bool setAsIntegerArray(const std::vector<uint32_t>& auiValues, std::string& strError); |
| 73 | bool getAsIntegerArray(std::vector<uint32_t>& auiValues, std::string& strError) const; |
| 74 | |
| 75 | // Signed Integer Access |
| 76 | bool setAsSignedInteger(int32_t iValue, std::string& strError); |
| 77 | bool getAsSignedInteger(int32_t& iValue, std::string& strError) const; |
| 78 | bool setAsSignedIntegerArray(const std::vector<int32_t>& aiValues, std::string& strError); |
| 79 | bool getAsSignedIntegerArray(std::vector<int32_t>& aiValues, std::string& strError) const; |
| 80 | |
| 81 | // Double Access |
| 82 | bool setAsDouble(double dValue, std::string& strError); |
| 83 | bool getAsDouble(double& dValue, std::string& strError) const; |
| 84 | bool setAsDoubleArray(const std::vector<double>& adValues, std::string& strError); |
| 85 | bool getAsDoubleArray(std::vector<double>& adValues, std::string& strError) const; |
| 86 | |
| 87 | // String Access |
| 88 | bool setAsString(const std::string& strValue, std::string& strError); |
| 89 | bool getAsString(std::string& strValue, std::string& strError) const; |
| 90 | bool setAsStringArray(const std::vector<std::string>& astrValues, std::string& strError); |
| 91 | bool getAsStringArray(std::vector<std::string>& astrValues, std::string& strError) const; |
| 92 | |
| 93 | private: |
| 94 | // Access validity |
| 95 | bool checkAccessValidity(bool bSet, uint32_t uiArrayLength, std::string& strError) const; |
| 96 | |
| 97 | // Accessed parameter instance |
| 98 | const CBaseParameter* _pBaseParameter; |
| 99 | // Parameter Mgr |
| 100 | CParameterMgr* _pParameterMgr; |
| 101 | // Subsystem endianness |
| 102 | bool _bBigEndianSubsystem; |
| 103 | }; |