diff options
| author | Patrick Benavoli <patrickx.benavoli@intel.com> | 2011-11-20 15:46:41 +0100 |
|---|---|---|
| committer | David Wagner <david.wagner@intel.com> | 2014-02-10 17:15:00 +0100 |
| commit | 065264a93ce9c63b6a5c95e985188ee33ba587d3 (patch) | |
| tree | 01897cd4ed658e6a41f21061146098d0385734fd /parameter/ParameterHandle.h | |
| parent | 6ccab9d382c08323fb1f000d859a696f05719c92 (diff) | |
| download | external_parameter-framework-065264a93ce9c63b6a5c95e985188ee33ba587d3.zip external_parameter-framework-065264a93ce9c63b6a5c95e985188ee33ba587d3.tar.gz external_parameter-framework-065264a93ce9c63b6a5c95e985188ee33ba587d3.tar.bz2 | |
PFW: Type safe dynamic parameter access
BZ: 15065
Replaced high level string based parameter access interface with typed ones.
Now hosting platforms that want to control parameters must instantiate a
CParameterHandle object out of the desired parameter path.
CParameterHandle object may be used to access any kind of parameters, whatever
its internal type, whether it's an array or not.
Note that non rogue parameters offer a read access only. Any attempt to write
them will fail.
CParameterHandle objects offer the following kind of parameter accessing
interfaces:
- Boolean
- Integer (signed or unsigned)
- Double
- String
Note that those interfaces are available for scalar as well as for array
parameters.
Not all parameter types support all access kinds. Naturally, array parameters
are only accessed via array interfaces while scalar parameters are managed
through scalar interfaces.
Here's a list of parameter types that may be controlled through each kind of
access interface:
- Boolean access: boolean, bit (bit size must be one);
- Integer access: integer (sign must match), boolean (unsigned access only,
value <= 1), enumerations;
- Double access: for now only fixed points (soon integers will support them
also through platform adaptation objects)
- String access: all parameter types
In addition, cleaned up parameter access related code so as to make it more
generic and reusable.
Changed version to 2.0.0
Change-Id: Ib80868cdb773e90962e48f1f38d2ff0029189815
Signed-off-by: Patrick Benavoli <patrickx.benavoli@intel.com>
Reviewed-on: http://android.intel.com:8080/25406
Reviewed-by: Barthes, FabienX <fabienx.barthes@intel.com>
Tested-by: Barthes, FabienX <fabienx.barthes@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
Diffstat (limited to 'parameter/ParameterHandle.h')
| -rw-r--r-- | parameter/ParameterHandle.h | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/parameter/ParameterHandle.h b/parameter/ParameterHandle.h new file mode 100644 index 0000000..0e6660f --- /dev/null +++ b/parameter/ParameterHandle.h @@ -0,0 +1,86 @@ +/* ParameterHandle.h + ** + ** Copyright © 2011 Intel + ** + ** Licensed under the Apache License, Version 2.0 (the "License"); + ** you may not use this file except in compliance with the License. + ** You may obtain a copy of the License at + ** + ** http://www.apache.org/licenses/LICENSE-2.0 + ** + ** Unless required by applicable law or agreed to in writing, software + ** distributed under the License is distributed on an "AS IS" BASIS, + ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ** See the License for the specific language governing permissions and + ** limitations under the License. + ** + ** AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) + ** CREATED: 2011-06-01 + ** UPDATED: 2011-07-27 + ** + */ +#pragma once + +#include <stdint.h> +#include <string> +#include <vector> + +class CBaseParameter; +class CParameterMgr; + +class CParameterHandle +{ +public: + CParameterHandle(const CBaseParameter* pParameter, CParameterMgr* pParameterMgr); + + // Parameter features + bool isRogue() const; + bool isArray() const; + // Array Length + uint32_t getArrayLength() const; // Returns 0 for scalar + // Parameter path + std::string getPath() const; + // Parameter kind + std::string getKind() const; + + // Boolean access + bool setAsBoolean(bool bValue, std::string& strError); + bool getAsBoolean(bool bValue, std::string& strError) const; + bool setAsBooleanArray(const std::vector<bool>& abValues, std::string& strError); + bool getAsBooleanArray(std::vector<bool>& abValues, std::string& strError) const; + + // Integer Access + bool setAsInteger(uint32_t uiValue, std::string& strError); + bool getAsInteger(uint32_t& uiValue, std::string& strError) const; + bool setAsIntegerArray(const std::vector<uint32_t>& auiValues, std::string& strError); + bool getAsIntegerArray(std::vector<uint32_t>& auiValues, std::string& strError) const; + + // Signed Integer Access + bool setAsSignedInteger(int32_t iValue, std::string& strError); + bool getAsSignedInteger(int32_t& iValue, std::string& strError) const; + bool setAsSignedIntegerArray(const std::vector<int32_t>& aiValues, std::string& strError); + bool getAsSignedIntegerArray(std::vector<int32_t>& aiValues, std::string& strError) const; + + // Double Access + bool setAsDouble(double dValue, std::string& strError); + bool getAsDouble(double& dValue, std::string& strError) const; + bool setAsDoubleArray(const std::vector<double>& adValues, std::string& strError); + bool getAsDoubleArray(std::vector<double>& adValues, std::string& strError) const; + + // String Access + bool setAsString(const std::string& strValue, std::string& strError); + bool getAsString(std::string& strValue, std::string& strError) const; + bool setAsStringArray(const std::vector<std::string>& astrValues, std::string& strError); + bool getAsStringArray(std::vector<std::string>& astrValues, std::string& strError) const; + +private: + // Access validity + bool checkAccessValidity(bool bSet, uint32_t uiArrayLength, std::string& strError) const; + + // Accessed parameter instance + const CBaseParameter* _pBaseParameter; + // Parameter Mgr + CParameterMgr* _pParameterMgr; + // Subsystem endianness + bool _bBigEndianSubsystem; +}; |
