ns-3 PLC model
model/plc-simulator-impl.h
00001 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
00002 /*
00003  * Copyright (c) 2012 University of British Columbia, Vancouver
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  * Modified by: Alexander Schloegl <alexander.schloegl@gmx.de>
00020  */
00021 
00022 #ifndef PLC_SIMULATOR_IMPL_H_
00023 #define PLC_SIMULATOR_IMPL_H_
00024 
00025 #include "ns3/simulator-impl.h"
00026 #include "ns3/scheduler.h"
00027 #include "ns3/event-impl.h"
00028 
00029 #include "ns3/ptr.h"
00030 
00031 #include <list>
00032 
00033 namespace ns3 {
00034 
00035 class PLC_SimulatorImpl : public SimulatorImpl
00036 {
00037 public:
00038         static TypeId GetTypeId (void);
00039 
00040         PLC_SimulatorImpl ();
00041         ~PLC_SimulatorImpl ();
00042 
00043         // Added to support simulation time granularity other than ns3::Time::Unit
00044         void SetGranularity(Time granularity);
00045         Time GetGranularity(void) { return m_granularity; }
00046         uint64_t GetQuantizedTicks(Time time);
00047 
00048         virtual void Destroy ();
00049         virtual bool IsFinished (void) const;
00050         virtual Time Next (void) const;
00051         virtual void Stop (void);
00052         virtual void Stop (Time const &time);
00053         virtual EventId Schedule (Time const &time, EventImpl *event);
00054         virtual void ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event);
00055         virtual EventId ScheduleNow (EventImpl *event);
00056         virtual EventId ScheduleDestroy (EventImpl *event);
00057         virtual void Remove (const EventId &ev);
00058         virtual void Cancel (const EventId &ev);
00059         virtual bool IsExpired (const EventId &ev) const;
00060         virtual void Run (void);
00061         virtual void RunOneEvent (void);
00062         virtual Time Now (void) const;
00063         virtual Time GetDelayLeft (const EventId &id) const;
00064         virtual Time GetMaximumSimulationTime (void) const;
00065         virtual void SetScheduler (ObjectFactory schedulerFactory);
00066         virtual uint32_t GetSystemId (void) const;
00067         virtual uint32_t GetContext (void) const;
00068 
00069 private:
00070         virtual void DoDispose (void);
00071         void ProcessOneEvent (void);
00072         uint64_t NextTs (void) const;
00073         typedef std::list<EventId> DestroyEvents;
00074 
00075         DestroyEvents m_destroyEvents;
00076         bool m_stop;
00077         Ptr<Scheduler> m_events;
00078         uint32_t m_uid;
00079         uint32_t m_currentUid;
00080         uint64_t m_currentTs;
00081         uint32_t m_currentContext;
00082         // number of events that have been inserted but not yet scheduled,
00083         // not counting the "destroy" events; this is used for validation
00084         int m_unscheduledEvents;
00085 
00086         Time            m_granularity;
00087         int64_t         m_tick_ts;
00088 };
00089 
00090 } // namespace ns3
00091 
00092 #endif /* PLC_SIMULATOR_IMPL_H_ */
 All Classes Functions Variables Enumerations