src/simulator/time.cc
changeset 150 663120712cd9
parent 144 f07f6fb0f660
child 151 8395af452e55
equal deleted inserted replaced
149:d5b12472c5e2 150:663120712cd9
     1 /* -*- Mode:NS3; -*- */
     1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
     2 /*
     2 /*
     3  * Copyright (c) 2005,2006 INRIA
     3  * Copyright (c) 2005,2006 INRIA
     4  * All rights reserved.
     4  * All rights reserved.
     5  *
     5  *
     6  * This program is free software; you can redistribute it and/or modify
     6  * This program is free software; you can redistribute it and/or modify
    22 #include "simulator.h"
    22 #include "simulator.h"
    23 
    23 
    24 namespace ns3 {
    24 namespace ns3 {
    25 
    25 
    26 Time::Time ()
    26 Time::Time ()
    27     : m_ns (0)
    27   : m_ns (0)
    28 {}
    28 {}
    29 Time::Time (Time const &o)
    29 Time::Time (Time const &o)
    30     : m_ns (o.m_ns)
    30   : m_ns (o.m_ns)
    31 {}
    31 {}
    32 Time &
    32 Time &
    33 Time::operator = (Time const &o)
    33 Time::operator = (Time const &o)
    34 {
    34 {
    35   m_ns = o.m_ns;
    35   m_ns = o.m_ns;
    36   return *this;
    36   return *this;
    37 }
    37 }
    38 Time::Time (int64_t ns)
    38 Time::Time (int64_t ns)
    39     : m_ns (ns)
    39   : m_ns (ns)
    40 {}
    40 {}
    41 
    41 
    42 
    42 
    43 bool 
    43 bool 
    44 Time::IsNegative (void) const
    44 Time::IsNegative (void) const
   151 {
   151 {
   152   return GetNs (lhs) >= GetNs (rhs);
   152   return GetNs (lhs) >= GetNs (rhs);
   153 }
   153 }
   154 
   154 
   155 Now::Now ()
   155 Now::Now ()
   156     : Time (Simulator::Now ())
   156   : Time (Simulator::Now ())
   157 {}
   157 {}
   158 Seconds::Seconds (double s)
   158 Seconds::Seconds (double s)
   159     : Time ((int64_t)(s * 1000000000))
   159   : Time ((int64_t)(s * 1000000000))
   160 {}
   160 {}
   161 MilliSeconds::MilliSeconds (int32_t ms)
   161 MilliSeconds::MilliSeconds (int32_t ms)
   162     : Time ((int64_t)(ms * 1000000))
   162   : Time ((int64_t)(ms * 1000000))
   163 {}
   163 {}
   164 MicroSeconds::MicroSeconds (int32_t us)
   164 MicroSeconds::MicroSeconds (int32_t us)
   165     : Time ((int64_t)(us * 1000))
   165   : Time ((int64_t)(us * 1000))
   166 {}
   166 {}
   167 NanoSeconds::NanoSeconds (int64_t ns)
   167 NanoSeconds::NanoSeconds (int64_t ns)
   168     : Time (ns)
   168   : Time (ns)
   169 {}
   169 {}
   170   
   170   
   171 
   171 
   172 
   172 
   173 
   173