| 1 |
/* |
| 2 |
* Copyright (c) 2021, Intel Corporation |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 5 |
* copy of this software and associated documentation files (the "Software"), |
| 6 |
* to deal in the Software without restriction, including without limitation |
| 7 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 9 |
* Software is furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included |
| 12 |
* in all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 |
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 |
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 21 |
*/ |
| 22 |
//! |
| 23 |
//! \file media_user_setting_value.h |
| 24 |
//! \brief Implementation for user setting value |
| 25 |
//! |
| 26 |
|
| 27 |
#ifndef __MEDIA_USER_SETTING_VALUE_H__ |
| 28 |
#define __MEDIA_USER_SETTING_VALUE_H__ |
| 29 |
|
| 30 |
#include "mos_utilities_common.h" |
| 31 |
#include <string> |
| 32 |
#include <sstream> |
| 33 |
|
| 34 |
namespace MediaUserSetting { |
| 35 |
|
| 36 |
class Value |
| 37 |
{ |
| 38 |
public: |
| 39 |
Value(); |
| 40 |
virtual ~Value(); |
| 41 |
Value(const Value &value); |
| 42 |
Value(const int32_t &value); |
| 43 |
Value(const int64_t &value); |
| 44 |
Value(const uint32_t &value); |
| 45 |
Value(const uint64_t &value); |
| 46 |
Value(const bool &value); |
| 47 |
Value(const float &value); |
| 48 |
Value(const std::string &value); |
| 49 |
Value(const char* value); |
| 50 |
Value(char* value); |
| 51 |
|
| 52 |
Value& operator=(const Value &value); |
| 53 |
Value& operator=(const int32_t &value); |
| 54 |
Value& operator=(const int64_t &value); |
| 55 |
Value& operator=(const uint32_t &value); |
| 56 |
Value& operator=(const uint64_t &value); |
| 57 |
Value& operator=(const bool &value); |
| 58 |
Value& operator=(const float &value); |
| 59 |
Value& operator=(const std::string &value); |
| 60 |
Value& operator=(const char* value); |
| 61 |
Value& operator=(char* value); |
| 62 |
|
| 63 |
template <class T> |
| 64 |
T Get() const |
| 65 |
{ |
| 66 |
return m_sValue; |
| 67 |
} |
| 68 |
|
| 69 |
const std::string &ConstString() const { return m_sValue; } |
| 70 |
|
| 71 |
const std::size_t &Size() const { return m_size; } |
| 72 |
const MOS_USER_FEATURE_VALUE_TYPE &ValueType() const { return m_type; } |
| 73 |
|
| 74 |
private: |
| 75 |
std::size_t m_size = 0; |
| 76 |
std::string m_sValue{}; |
| 77 |
union NUMERIC_VALUE |
| 78 |
{ |
| 79 |
NUMERIC_VALUE(); |
| 80 |
NUMERIC_VALUE(const bool value); |
| 81 |
NUMERIC_VALUE(const uint32_t value); |
| 82 |
NUMERIC_VALUE(const uint64_t value); |
| 83 |
NUMERIC_VALUE(const int32_t value); |
| 84 |
NUMERIC_VALUE(const int64_t value); |
| 85 |
NUMERIC_VALUE(const float value); |
| 86 |
NUMERIC_VALUE &operator=(const int32_t &value); |
| 87 |
NUMERIC_VALUE &operator=(const int64_t &value); |
| 88 |
NUMERIC_VALUE &operator=(const uint32_t &value); |
| 89 |
NUMERIC_VALUE &operator=(const uint64_t &value); |
| 90 |
NUMERIC_VALUE &operator=(const bool &value); |
| 91 |
NUMERIC_VALUE &operator=(const float &value); |
| 92 |
|
| 93 |
bool m_bData; |
| 94 |
uint32_t m_u32Data; |
| 95 |
uint64_t m_u64Data; |
| 96 |
int32_t m_i32Data; |
| 97 |
int64_t m_i64Data; |
| 98 |
float m_fData; |
| 99 |
}; |
| 100 |
NUMERIC_VALUE m_numericValue = {}; |
| 101 |
MOS_USER_FEATURE_VALUE_TYPE m_type = MOS_USER_FEATURE_VALUE_TYPE_INVALID; |
| 102 |
}; |
| 103 |
|
| 104 |
template <> bool Value::Get() const; |
| 105 |
template <> uint8_t Value::Get() const; |
| 106 |
template <> uint32_t Value::Get() const; |
| 107 |
template <> int32_t Value::Get() const; |
| 108 |
template <> unsigned long Value::Get() const; |
| 109 |
template <> int64_t Value::Get() const; |
| 110 |
template <> float Value::Get() const; |
| 111 |
template <> unsigned long long Value::Get() const; |
| 112 |
} |
| 113 |
|
| 114 |
#endif |