summaryrefslogtreecommitdiff
path: root/indra/llcommon/llunit.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/llunit.h')
-rw-r--r--indra/llcommon/llunit.h66
1 files changed, 36 insertions, 30 deletions
diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h
index 4663070c42..2664bd77e9 100644
--- a/indra/llcommon/llunit.h
+++ b/indra/llcommon/llunit.h
@@ -49,11 +49,17 @@ struct LLUnitType : public BASE_UNIT
return static_cast<unit_t&>(*this);
}
- value_t get() const
+ value_t value() const
{
return convertToDerived(mValue);
}
+ template<typename CONVERTED_TYPE>
+ value_t value() const
+ {
+ return CONVERTED_TYPE(*this).value();
+ }
+
static value_t convertToBase(value_t derived_value)
{
return (value_t)((F32)derived_value * unit_t::conversionToBaseFactor());
@@ -112,7 +118,7 @@ struct LLUnitType<STORAGE_TYPE, T, T>
return static_cast<unit_t&>(*this);
}
- value_t get() { return mValue; }
+ value_t value() { return mValue; }
static value_t convertToBase(value_t derived_value)
{
@@ -173,26 +179,26 @@ protected:
value_t mValue;
};
-#define LL_DECLARE_BASE_UNIT(unit_name) \
- template<typename STORAGE_TYPE> \
+#define LL_DECLARE_BASE_UNIT(unit_name) \
+ template<typename STORAGE_TYPE> \
struct unit_name : public LLUnitType<STORAGE_TYPE, unit_name<STORAGE_TYPE> > \
- { \
+ { \
typedef unit_name<STORAGE_TYPE> base_unit_t; \
typedef STORAGE_TYPE storage_t; \
\
- unit_name(STORAGE_TYPE value) \
+ unit_name(STORAGE_TYPE value) \
: LLUnitType(value) \
- {} \
- \
- unit_name() \
- {} \
- \
+ {} \
+ \
+ unit_name() \
+ {} \
+ \
template <typename SOURCE_STORAGE_TYPE, typename SOURCE_TYPE> \
unit_name(const LLUnitType<SOURCE_STORAGE_TYPE, unit_name, SOURCE_TYPE>& source) \
- { \
- setBaseValue(source.unit_t::get()); \
- } \
- \
+ { \
+ setBaseValue(source.unit_t::value()); \
+ } \
+ \
using LLUnitType::operator +; \
using LLUnitType::operator +=; \
using LLUnitType::operator -; \
@@ -203,28 +209,28 @@ protected:
using LLUnitType::operator /=; \
};
-#define LL_DECLARE_DERIVED_UNIT(base_unit, derived_unit, conversion_factor) \
- template<typename STORAGE_TYPE> \
+#define LL_DECLARE_DERIVED_UNIT(base_unit, derived_unit, conversion_factor) \
+ template<typename STORAGE_TYPE> \
struct derived_unit : public LLUnitType<STORAGE_TYPE, base_unit<STORAGE_TYPE>, derived_unit<STORAGE_TYPE> > \
- { \
+ { \
typedef base_unit<STORAGE_TYPE> base_unit_t; \
typedef STORAGE_TYPE storage_t; \
\
- derived_unit(value_t value) \
+ derived_unit(value_t value) \
: LLUnitType(value) \
- {} \
- \
- derived_unit() \
- {} \
- \
+ {} \
+ \
+ derived_unit() \
+ {} \
+ \
template <typename SOURCE_STORAGE_TYPE, typename SOURCE_TYPE> \
derived_unit(const LLUnitType<SOURCE_STORAGE_TYPE, base_unit<STORAGE_TYPE>, SOURCE_TYPE>& source) \
- { \
- setBaseValue(source.base_unit_t::get()); \
- } \
- \
- static F32 conversionToBaseFactor() { return (F32)(conversion_factor); } \
- \
+ { \
+ setBaseValue(source.base_unit_t::value()); \
+ } \
+ \
+ static F32 conversionToBaseFactor() { return (F32)(conversion_factor); } \
+ \
using LLUnitType::operator +; \
using LLUnitType::operator +=; \
using LLUnitType::operator -; \