LEFT | RIGHT |
(no file at all) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2012,2014 University of Zagreb |
| 4 * |
| 5 * This program is free software; you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 2 as |
| 7 * published by the Free Software Foundation; |
| 8 * |
| 9 * This program is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with this program; if not, write to the Free Software |
| 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 * |
| 18 * Author: Vedran Miletić <rivanvx@gmail.com> |
| 19 */ |
| 20 |
| 21 #include "sleep-wake-functionality.h" |
| 22 #include "log.h" |
| 23 |
| 24 NS_LOG_COMPONENT_DEFINE ("SleepWakeFunctionality"); |
| 25 |
| 26 namespace ns3 { |
| 27 |
| 28 SleepWakeFunctionality::SleepWakeFunctionality () |
| 29 : |
| 30 m_awake (true) |
| 31 { |
| 32 NS_LOG_FUNCTION (this); |
| 33 } |
| 34 |
| 35 SleepWakeFunctionality::~SleepWakeFunctionality () |
| 36 { |
| 37 NS_LOG_FUNCTION (this); |
| 38 } |
| 39 |
| 40 void |
| 41 SleepWakeFunctionality::Wake (void) |
| 42 { |
| 43 NS_LOG_FUNCTION (this); |
| 44 if (!m_awake) |
| 45 { |
| 46 NS_LOG_LOGIC ("Object " << this << " was sleeping, tracing wake event and
changing state"); |
| 47 m_wakeTrace (); |
| 48 m_awake = true; |
| 49 } |
| 50 } |
| 51 |
| 52 void |
| 53 SleepWakeFunctionality::Sleep (void) |
| 54 { |
| 55 NS_LOG_FUNCTION (this); |
| 56 if (m_awake) |
| 57 { |
| 58 NS_LOG_LOGIC ("Object " << this << " was awake, tracing sleep event and ch
anging state"); |
| 59 m_sleepTrace (); |
| 60 m_awake = false; |
| 61 } |
| 62 } |
| 63 |
| 64 bool |
| 65 SleepWakeFunctionality::IsAwake (void) const |
| 66 { |
| 67 NS_LOG_FUNCTION (this); |
| 68 return m_awake; |
| 69 } |
| 70 |
| 71 } // namespace ns3 |
LEFT | RIGHT |