00001 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2005 INRIA 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> 00019 */ 00020 #include "event-id.h" 00021 #include "simulator.h" 00022 #include "event-impl.h" 00023 00024 namespace ns3 { 00025 00026 EventId::EventId () 00027 : m_eventImpl (0), 00028 m_ts (0), 00029 m_uid (0) 00030 {} 00031 00032 EventId::EventId (const Ptr<EventImpl> &impl, uint64_t ts, uint32_t uid) 00033 : m_eventImpl (impl), 00034 m_ts (ts), 00035 m_uid (uid) 00036 {} 00037 void 00038 EventId::Cancel (void) 00039 { 00040 Simulator::Cancel (*this); 00041 } 00042 bool 00043 EventId::IsExpired (void) const 00044 { 00045 return Simulator::IsExpired (*this); 00046 } 00047 bool 00048 EventId::IsRunning (void) const 00049 { 00050 return !IsExpired (); 00051 } 00052 EventImpl * 00053 EventId::PeekEventImpl (void) const 00054 { 00055 return PeekPointer (m_eventImpl); 00056 } 00057 uint64_t 00058 EventId::GetTs (void) const 00059 { 00060 return m_ts; 00061 } 00062 uint32_t 00063 EventId::GetUid (void) const 00064 { 00065 return m_uid; 00066 } 00067 00068 bool operator == (const EventId &a, const EventId &b) 00069 { 00070 return 00071 a.m_uid == b.m_uid && 00072 a.m_ts == b.m_ts && 00073 a.m_eventImpl == b.m_eventImpl; 00074 } 00075 bool operator != (const EventId &a, const EventId &b) 00076 { 00077 return !(a == b); 00078 } 00079 00080 00081 00082 }; // namespace ns3