24 #include "global-value.h"
37 Time::Time (
const std::string& s)
40 std::string::size_type n = s.find_first_not_of (
"+-0123456789.");
41 if (n != std::string::npos)
43 std::istringstream iss;
44 iss.str (s.substr (0, n));
47 std::string trailer = s.substr (n, std::string::npos);
48 if (trailer == std::string (
"s"))
53 if (trailer == std::string (
"ms"))
58 if (trailer == std::string (
"us"))
63 if (trailer == std::string (
"ns"))
68 if (trailer == std::string (
"ps"))
73 if (trailer == std::string (
"fs"))
82 std::istringstream iss;
90 Time::GetNsResolution (void)
93 struct Resolution resolution;
107 int8_t power [LAST] = { 15, 12, 9, 6, 3, 0};
108 for (
int i = 0; i < Time::LAST; i++)
110 int shift = power[i] - power[(int)unit];
111 uint64_t factor = (uint64_t) std::pow (10, std::fabs (shift));
112 struct Information *info = &resolution->info[i];
113 info->factor = factor;
116 info->timeFrom = int64x64_t (1);
117 info->timeTo = int64x64_t (1);
119 info->fromMul =
true;
123 info->timeFrom = int64x64_t (factor);
124 info->timeTo = int64x64_t::Invert (factor);
126 info->fromMul =
true;
131 info->timeFrom = int64x64_t::Invert (factor);
132 info->timeTo = int64x64_t (factor);
134 info->fromMul =
false;
137 resolution->unit = unit;
143 return PeekResolution ()->unit;
173 unit =
"unreachable";
180 std::istream&
operator>> (std::istream& is, Time & time)
std::istream & operator>>(std::istream &is, Angles &a)
#define NS_LOG_FUNCTION(parameters)
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
#define NS_LOG_FUNCTION_NOARGS()
static Time FromDouble(double value, enum Unit timeUnit)
#define ATTRIBUTE_VALUE_IMPLEMENT(type)
static enum Unit GetResolution(void)
std::ostream & operator<<(std::ostream &os, const Angles &a)
#define NS_ABORT_MSG(msg)
Abnormal program termination.
static void SetResolution(enum Unit resolution)
#define ATTRIBUTE_CHECKER_IMPLEMENT(type)