52 return g_markingMutex;
60 static bool firstTime =
true;
94 std::string::size_type n = s.find_first_not_of (
"+-0123456789.");
95 if (n != std::string::npos)
97 std::istringstream iss;
98 iss.str (s.substr (0, n));
101 std::string trailer = s.substr (n, std::string::npos);
102 if (trailer == std::string (
"s"))
106 else if (trailer == std::string (
"ms"))
110 else if (trailer == std::string (
"us"))
114 else if (trailer == std::string (
"ns"))
118 else if (trailer == std::string (
"ps"))
122 else if (trailer == std::string (
"fs"))
134 std::istringstream iss;
149 Time::SetDefaultNsResolution (void)
179 int8_t power [
LAST] = { 15, 12, 9, 6, 3, 0};
182 int shift = power[i] - power[(int)unit];
183 int64_t factor = (int64_t) std::pow (10, std::fabs (shift));
189 info->
timeTo = int64x64_t (1);
195 info->
timeFrom = int64x64_t (factor);
196 info->
timeTo = int64x64_t::Invert (factor);
203 info->
timeFrom = int64x64_t::Invert (factor);
204 info->
timeTo = int64x64_t (factor);
209 resolution->
unit = unit;
257 std::pair< MarkedTimes::iterator, bool> ret;
262 if (ret.second ==
false)
282 "Time object " << time <<
284 " times (should be 1)." );
289 NS_LOG_WARN (
"unexpected result erasing " << time <<
"!");
309 "No MarkedTimes registry. "
310 "Time::SetResolution () called more than once?");
316 Time *
const tp = *it;
317 if ( ! ( (tp->
m_data == std::numeric_limits<int64_t>::min ())
318 || (tp->
m_data == std::numeric_limits<int64_t>::max ())
373 unit =
"unreachable";
378 std::ios_base::fmtflags ff = os.flags ();
389 os << v <<
".0" << unit;
403 Ptr<const AttributeChecker>
410 Checker (
const Time minValue,
const Time maxValue)
411 : m_minValue (minValue),
412 m_maxValue (maxValue) {}
420 return v->
Get () >= m_minValue && v->
Get () <= m_maxValue;
422 virtual std::string GetValueTypeName (
void)
const {
424 return "ns3::TimeValue";
426 virtual bool HasUnderlyingTypeInformation (
void)
const {
430 virtual std::string GetUnderlyingTypeInformation (
void)
const {
432 std::ostringstream oss;
433 oss <<
"Time" <<
" " << m_minValue <<
":" << m_maxValue;
438 return ns3::Create<TimeValue> ();
444 if (src == 0 || dst == 0)
453 } *checker =
new Checker (min, max);
static struct Resolution * PeekResolution(void)
std::istream & operator>>(std::istream &is, Angles &a)
Represent the type of an attribute.
keep track of time values and allow control of global simulation resolution
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
Hold a value for an Attribute.
int64_t ToInteger(enum Unit timeUnit) const
#define NS_ASSERT(condition)
#define NS_LOG_FUNCTION_NOARGS()
static Time FromDouble(double value, enum Unit timeUnit)
struct Information info[LAST]
Conversion info from current unit.
NS_LOG_COMPONENT_DEFINE("Time")
static enum Unit GetResolution(void)
hold objects of type ns3::Time
A class which provides a simple way to implement a Critical Section.
static void ConvertTimes(const enum Unit unit)
#define NS_LOG_LOGIC(msg)
std::ostream & operator<<(std::ostream &os, const Angles &a)
SystemMutex & GetMarkingMutex()
A class which provides a relatively platform-independent Mutual Exclusion thread synchronization prim...
#define NS_ASSERT_MSG(condition, message)
ATTRIBUTE_VALUE_IMPLEMENT(RandomVariable)
static void Mark(Time *const time)
#define NS_ABORT_MSG(msg)
Abnormal program termination.
enum Time::Unit unit
Current time unit.
static void SetResolution(enum Unit resolution)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range. Both limits are inclusive.
static void Clear(Time *const time)
#define NS_LOG_ERROR(msg)
std::set< Time * > MarkedTimes
static MarkedTimes * g_markingTimes
static void ClearMarkedTimes()
Ptr< T > Copy(Ptr< T > object)
int64_t m_data
Virtual time value, in the current unit.