summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorRichard Linden <none@none>2013-06-04 10:54:12 -0700
committerRichard Linden <none@none>2013-06-04 10:54:12 -0700
commit715385eed7b2276963015861d7e6b8196e6ae5cd (patch)
tree87d53b1431b1748bbb15582b7cafcccd3279dd53 /indra/llcommon
parent5b48107dbf969529267874bff9a0a4b892b348cf (diff)
BUILDFIX: don't multiple define class statics...use inline static method instead
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/lltrace.h10
-rw-r--r--indra/llcommon/llunit.h34
2 files changed, 32 insertions, 12 deletions
diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h
index c485552061..2953e993d4 100644
--- a/indra/llcommon/lltrace.h
+++ b/indra/llcommon/lltrace.h
@@ -265,6 +265,8 @@ public:
size_t getIndex() const { return mAccumulatorIndex; }
+ virtual const char* getUnitLabel() { return ""; }
+
const std::string& getName() const { return mName; }
protected:
@@ -662,6 +664,9 @@ public:
EventStatHandle(const char* name, const char* description = NULL)
: trace_t(name, description)
{}
+
+ /*virtual*/ const char* getUnitLabel() { return LLGetUnitLabel<T>::getUnitLabel(); }
+
};
template<typename T, typename VALUE_T>
@@ -682,6 +687,8 @@ public:
SampleStatHandle(const char* name, const char* description = NULL)
: trace_t(name, description)
{}
+
+ /*virtual*/ const char* getUnitLabel() { return LLGetUnitLabel<T>::getUnitLabel(); }
};
template<typename T, typename VALUE_T>
@@ -703,6 +710,7 @@ public:
: trace_t(name)
{}
+ /*virtual*/ const char* getUnitLabel() { return LLGetUnitLabel<T>::getUnitLabel(); }
};
template<typename T, typename VALUE_T>
@@ -755,6 +763,8 @@ public:
MemStatHandle(const char* name)
: trace_t(name)
{}
+
+ /*virtual*/ const char* getUnitLabel() { return "B"; }
};
// measures effective memory footprint of specified type
diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h
index c617d2a87f..77c19b5152 100644
--- a/indra/llcommon/llunit.h
+++ b/indra/llcommon/llunit.h
@@ -406,6 +406,22 @@ COMPARISON_OPERATORS(>=)
COMPARISON_OPERATORS(==)
COMPARISON_OPERATORS(!=)
+
+template<typename T>
+struct LLGetUnitLabel
+{
+ static const char* getUnitLabel() { return ""; }
+};
+
+template<typename T, typename STORAGE_T>
+struct LLGetUnitLabel<LLUnit<T, STORAGE_T> >
+{
+ static const char* getUnitLabel() { return T::getUnitLabel(); }
+};
+
+//
+// Unit declarations
+//
namespace LLUnits
{
template<typename T>
@@ -427,9 +443,8 @@ struct HighestPrecisionType<LLUnit<UNIT_TYPE, STORAGE_TYPE> >
struct unit_name \
{ \
typedef base_unit_name base_unit_t; \
- static const char* sUnitLabel; \
+ static const char* getUnitLabel() { return unit_label; } \
}; \
-const char* unit_name::sUnitLabel = unit_label; \
template<typename STORAGE_TYPE> \
struct ConversionFactor<unit_name, base_unit_name, STORAGE_TYPE> \
{ \
@@ -448,8 +463,7 @@ struct ConversionFactor<base_unit_name, unit_name, STORAGE_TYPE> \
} \
}
-struct Bytes { typedef Bytes base_unit_t; static const char* sUnitLabel;};
-const char* Bytes::sUnitLabel = "B";
+struct Bytes { typedef Bytes base_unit_t; static const char* getUnitLabel() { return "B"; }};
LL_DECLARE_DERIVED_UNIT(1024, Bytes, Kilobytes, "KiB");
LL_DECLARE_DERIVED_UNIT(1024 * 1024, Bytes, Megabytes, "MiB");
LL_DECLARE_DERIVED_UNIT(1024 * 1024 * 1024, Bytes, Gigabytes, "GiB");
@@ -458,28 +472,24 @@ LL_DECLARE_DERIVED_UNIT(1024 / 8, Bytes, Kilobits, "Kib");
LL_DECLARE_DERIVED_UNIT(1024 / 8, Bytes, Megabits, "Mib");
LL_DECLARE_DERIVED_UNIT(1024 * 1024 * 1024 / 8, Bytes, Gigabits, "Gib");
-struct Seconds { typedef Seconds base_unit_t; static const char* sUnitLabel; };
-const char* Seconds::sUnitLabel = "s";
+struct Seconds { typedef Seconds base_unit_t; static const char* getUnitLabel() { return "s"; } };
LL_DECLARE_DERIVED_UNIT(60, Seconds, Minutes, "min");
LL_DECLARE_DERIVED_UNIT(60 * 60, Seconds, Hours, "h");
LL_DECLARE_DERIVED_UNIT(1.0 / 1000.0, Seconds, Milliseconds, "ms");
LL_DECLARE_DERIVED_UNIT(1.0 / 1000000.0, Seconds, Microseconds, "\x09\x3cs");
LL_DECLARE_DERIVED_UNIT(1.0 / 1000000000.0, Seconds, Nanoseconds, "ns");
-struct Meters { typedef Meters base_unit_t; static const char* sUnitLabel; };
-const char* Meters::sUnitLabel = "m";
+struct Meters { typedef Meters base_unit_t; static const char* getUnitLabel() { return "m"; } };
LL_DECLARE_DERIVED_UNIT(1000, Meters, Kilometers, "km");
LL_DECLARE_DERIVED_UNIT(1.0 / 100.0, Meters, Centimeters, "cm");
LL_DECLARE_DERIVED_UNIT(1.0 / 1000.0, Meters, Millimeters, "mm");
-struct Hertz { typedef Hertz base_unit_t; static const char* sUnitLabel; };
-const char* Hertz::sUnitLabel = "Hz";
+struct Hertz { typedef Hertz base_unit_t; static const char* getUnitLabel() { return "Hz"; } };
LL_DECLARE_DERIVED_UNIT(1000, Hertz, Kilohertz, "KHz");
LL_DECLARE_DERIVED_UNIT(1000 * 1000, Hertz, Megahertz, "MHz");
LL_DECLARE_DERIVED_UNIT(1000 * 1000 * 1000, Hertz, Gigahertz, "GHz");
-struct Radians { typedef Radians base_unit_t; static const char* sUnitLabel;};
-const char* Radians::sUnitLabel = "rad";
+struct Radians { typedef Radians base_unit_t; static const char* getUnitLabel() { return "rad"; } };
LL_DECLARE_DERIVED_UNIT(DEG_TO_RAD, Radians, Degrees, "deg");
} // namespace LLUnits