From a2e22732f195dc075a733c79f15156752f522a43 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 30 Jul 2013 19:13:45 -0700 Subject: Summer cleaning - removed a lot of llcommon dependencies to speed up build times consolidated most indra-specific constants in llcommon under indra_constants.h fixed issues with operations on mixed unit types (implicit and explicit) made LL_INFOS() style macros variadic in order to subsume other logging methods such as ll_infos added optional tag output to error recorders --- indra/llcommon/llunit.h | 88 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 67 insertions(+), 21 deletions(-) (limited to 'indra/llcommon/llunit.h') diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index d6d8d9da6a..781a4ab731 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -29,7 +29,7 @@ #include "stdtypes.h" #include "llpreprocessor.h" -#include "llerrorlegacy.h" +#include "llerror.h" template struct LLUnit @@ -266,13 +266,29 @@ LLUnit operator + (SCALAR_TYPE first, LLUnit -LLUnitImplicit operator + (LLUnitImplicit first, LLUnit second) +LLUnitImplicit operator + (LLUnitImplicit first, LLUnitImplicit second) +{ + LLUnitImplicit result(first); + result += second; + return result; +} + +template +LLUnitImplicit operator + (LLUnit first, LLUnitImplicit second) { LLUnitImplicit result(first); result += second; return result; } +template +LLUnitImplicit operator + (LLUnitImplicit first, LLUnit second) +{ + LLUnitImplicit result(first); + result += LLUnitImplicit(second); + return result; +} + template LLUnitImplicit operator + (LLUnitImplicit first, SCALAR_TYPE second) { @@ -281,10 +297,10 @@ LLUnitImplicit operator + (LLUnitImplicit -LLUnitImplicit operator + (LLUnitImplicit first, LLUnitImplicit second) +template +LLUnitImplicit operator + (SCALAR_TYPE first, LLUnitImplicit second) { - LLUnitImplicit result(first); + LLUnitImplicit result(first); result += second; return result; } @@ -324,6 +340,22 @@ LLUnitImplicit operator - (LLUnitImplicit +LLUnitImplicit operator - (LLUnit first, LLUnitImplicit second) +{ + LLUnitImplicit result(first); + result -= second; + return result; +} + +template +LLUnitImplicit operator - (LLUnitImplicit first, LLUnit second) +{ + LLUnitImplicit result(first); + result -= LLUnitImplicit(second); + return result; +} + template LLUnitImplicit operator - (LLUnitImplicit first, SCALAR_TYPE second) { @@ -343,18 +375,6 @@ LLUnitImplicit operator - (SCALAR_TYPE first, LLUnitImp // // operator * // -template -LLUnit operator * (SCALAR_TYPE first, LLUnit second) -{ - return LLUnit((STORAGE_TYPE)(first * second.value())); -} - -template -LLUnit operator * (LLUnit first, SCALAR_TYPE second) -{ - return LLUnit((STORAGE_TYPE)(first.value() * second)); -} - template LLUnit operator * (LLUnit, LLUnit) { @@ -364,15 +384,15 @@ LLUnit operator * (LLUnit, } template -LLUnitImplicit operator * (SCALAR_TYPE first, LLUnitImplicit second) +LLUnit operator * (LLUnit first, SCALAR_TYPE second) { - return LLUnitImplicit(first * second.value()); + return LLUnit((STORAGE_TYPE)(first.value() * second)); } template -LLUnitImplicit operator * (LLUnitImplicit first, SCALAR_TYPE second) +LLUnit operator * (SCALAR_TYPE first, LLUnit second) { - return LLUnitImplicit(first.value() * second); + return LLUnit((STORAGE_TYPE)(first * second.value())); } template @@ -383,6 +403,19 @@ LLUnitImplicit operator * (LLUnitImplicit(); } +template +LLUnitImplicit operator * (LLUnitImplicit first, SCALAR_TYPE second) +{ + return LLUnitImplicit(first.value() * second); +} + +template +LLUnitImplicit operator * (SCALAR_TYPE first, LLUnitImplicit second) +{ + return LLUnitImplicit(first * second.value()); +} + + // // operator / // @@ -416,6 +449,18 @@ STORAGE_TYPE1 operator / (LLUnitImplicit first, LLUni return STORAGE_TYPE1(first.value() / first.convert(second)); } +template +STORAGE_TYPE1 operator / (LLUnit first, LLUnitImplicit second) +{ + return STORAGE_TYPE1(first.value() / first.convert(second)); +} + +template +STORAGE_TYPE1 operator / (LLUnitImplicit first, LLUnit second) +{ + return STORAGE_TYPE1(first.value() / first.convert(second)); +} + #define COMPARISON_OPERATORS(op) \ template \ bool operator op (SCALAR_TYPE first, LLUnit second) \ @@ -591,6 +636,7 @@ LL_DECLARE_DERIVED_UNIT(Mibibits, * 1024, Gibibits, "Gib"); LL_DECLARE_BASE_UNIT(Seconds, "s"); LL_DECLARE_DERIVED_UNIT(Seconds, * 60, Minutes, "min"); LL_DECLARE_DERIVED_UNIT(Minutes, * 60, Hours, "h"); +LL_DECLARE_DERIVED_UNIT(Hours, * 24, Days, "d"); LL_DECLARE_DERIVED_UNIT(Seconds, / 1000, Milliseconds, "ms"); LL_DECLARE_DERIVED_UNIT(Milliseconds, / 1000, Microseconds, "\x09\x3cs"); LL_DECLARE_DERIVED_UNIT(Microseconds, / 1000, Nanoseconds, "ns"); -- cgit v1.2.3