Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2011-2015 Regents of the University of California. |
Spyridon Mastorakis | 86edf6f | 2014-11-14 19:27:18 -0800 | [diff] [blame] | 4 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and |
| 6 | * contributors. |
Spyridon Mastorakis | 86edf6f | 2014-11-14 19:27:18 -0800 | [diff] [blame] | 7 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms |
| 9 | * of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
Spyridon Mastorakis | 86edf6f | 2014-11-14 19:27:18 -0800 | [diff] [blame] | 11 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * PURPOSE. See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | **/ |
Spyridon Mastorakis | 86edf6f | 2014-11-14 19:27:18 -0800 | [diff] [blame] | 19 | |
| 20 | #include "ndn-time.hpp" |
| 21 | |
| 22 | #include "ns3/simulator.h" |
| 23 | |
| 24 | namespace ns3 { |
| 25 | namespace ndn { |
| 26 | namespace time { |
| 27 | |
| 28 | system_clock::time_point |
| 29 | CustomSystemClock::getNow() const |
| 30 | { |
| 31 | boost::chrono::nanoseconds ns(Simulator::Now().GetNanoSeconds()); |
| 32 | return system_clock::time_point(ns); |
| 33 | } |
| 34 | |
| 35 | std::string |
| 36 | CustomSystemClock::getSince() const |
| 37 | { |
| 38 | return " since start of simulation"; |
| 39 | } |
| 40 | |
Spyridon Mastorakis | cb9be5c | 2018-02-20 11:22:27 -0800 | [diff] [blame] | 41 | system_clock::duration |
| 42 | CustomSystemClock::toWaitDuration(system_clock::duration d) const |
Spyridon Mastorakis | 86edf6f | 2014-11-14 19:27:18 -0800 | [diff] [blame] | 43 | { |
| 44 | BOOST_ASSERT_MSG(false, "Must not be called"); |
Spyridon Mastorakis | cb9be5c | 2018-02-20 11:22:27 -0800 | [diff] [blame] | 45 | return time::microseconds(1); |
Spyridon Mastorakis | 86edf6f | 2014-11-14 19:27:18 -0800 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | //////////////////////////////////// |
| 49 | |
| 50 | steady_clock::time_point |
| 51 | CustomSteadyClock::getNow() const |
| 52 | { |
| 53 | boost::chrono::nanoseconds ns(Simulator::Now().GetNanoSeconds()); |
| 54 | return steady_clock::time_point(ns); |
| 55 | } |
| 56 | |
| 57 | std::string |
| 58 | CustomSteadyClock::getSince() const |
| 59 | { |
| 60 | return " since start of simulation"; |
| 61 | } |
| 62 | |
Spyridon Mastorakis | cb9be5c | 2018-02-20 11:22:27 -0800 | [diff] [blame] | 63 | steady_clock::duration |
| 64 | CustomSteadyClock::toWaitDuration(steady_clock::duration d) const |
Spyridon Mastorakis | 86edf6f | 2014-11-14 19:27:18 -0800 | [diff] [blame] | 65 | { |
| 66 | BOOST_ASSERT_MSG(false, "Must not be called"); |
Spyridon Mastorakis | cb9be5c | 2018-02-20 11:22:27 -0800 | [diff] [blame] | 67 | return time::microseconds(1); |
Spyridon Mastorakis | 86edf6f | 2014-11-14 19:27:18 -0800 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | } // namespace time |
| 71 | } // namespace ndn |
| 72 | } // namespace ns3 |