|
craigdo@3470
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
|
craigdo@3470
|
2 |
/*
|
|
craigdo@3470
|
3 |
* Copyright (c) 2005,2006 INRIA
|
|
craigdo@3470
|
4 |
*
|
|
craigdo@3470
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
craigdo@3470
|
6 |
* it under the terms of the GNU General Public License version 2 as
|
|
craigdo@3470
|
7 |
* published by the Free Software Foundation;
|
|
craigdo@3470
|
8 |
*
|
|
craigdo@3470
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
craigdo@3470
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
craigdo@3470
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
craigdo@3470
|
12 |
* GNU General Public License for more details.
|
|
craigdo@3470
|
13 |
*
|
|
craigdo@3470
|
14 |
* You should have received a copy of the GNU General Public License
|
|
craigdo@3470
|
15 |
* along with this program; if not, write to the Free Software
|
|
craigdo@3470
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
craigdo@3470
|
17 |
*
|
|
craigdo@3470
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
|
craigdo@3470
|
19 |
*/
|
|
craigdo@3470
|
20 |
|
|
craigdo@3470
|
21 |
#ifndef DEFAULT_SIMULATOR_IMPL_H
|
|
craigdo@3470
|
22 |
#define DEFAULT_SIMULATOR_IMPL_H
|
|
craigdo@3470
|
23 |
|
|
craigdo@3470
|
24 |
#include "simulator-impl.h"
|
|
craigdo@3470
|
25 |
#include "scheduler.h"
|
|
craigdo@3470
|
26 |
#include "event-impl.h"
|
|
craigdo@3470
|
27 |
|
|
craigdo@3470
|
28 |
#include "ns3/ptr.h"
|
|
craigdo@3470
|
29 |
#include "ns3/assert.h"
|
|
craigdo@3470
|
30 |
#include "ns3/log.h"
|
|
craigdo@3470
|
31 |
|
|
craigdo@3470
|
32 |
#include <list>
|
|
craigdo@3470
|
33 |
|
|
craigdo@3470
|
34 |
namespace ns3 {
|
|
craigdo@3470
|
35 |
|
|
craigdo@3470
|
36 |
class DefaultSimulatorImpl : public SimulatorImpl
|
|
craigdo@3470
|
37 |
{
|
|
craigdo@3470
|
38 |
public:
|
|
craigdo@3470
|
39 |
static TypeId GetTypeId (void);
|
|
craigdo@3470
|
40 |
|
|
craigdo@3470
|
41 |
DefaultSimulatorImpl ();
|
|
craigdo@3470
|
42 |
~DefaultSimulatorImpl ();
|
|
craigdo@3470
|
43 |
|
|
mathieu@3509
|
44 |
virtual void Destroy ();
|
|
mathieu@3509
|
45 |
virtual bool IsFinished (void) const;
|
|
mathieu@3509
|
46 |
virtual Time Next (void) const;
|
|
mathieu@3509
|
47 |
virtual void Stop (void);
|
|
mathieu@3808
|
48 |
virtual EventId Schedule (Time const &time, EventImpl *event);
|
|
mathieu@3808
|
49 |
virtual EventId ScheduleNow (EventImpl *event);
|
|
mathieu@3808
|
50 |
virtual EventId ScheduleDestroy (EventImpl *event);
|
|
mathieu@3509
|
51 |
virtual void Remove (const EventId &ev);
|
|
mathieu@3509
|
52 |
virtual void Cancel (const EventId &ev);
|
|
mathieu@3509
|
53 |
virtual bool IsExpired (const EventId &ev) const;
|
|
mathieu@3509
|
54 |
virtual void Run (void);
|
|
gjc@3515
|
55 |
virtual void RunOneEvent (void);
|
|
mathieu@3509
|
56 |
virtual Time Now (void) const;
|
|
mathieu@3509
|
57 |
virtual Time GetDelayLeft (const EventId &id) const;
|
|
mathieu@3509
|
58 |
virtual Time GetMaximumSimulationTime (void) const;
|
|
guillaume@5507
|
59 |
virtual void SetScheduler (ObjectFactory schedulerFactory);
|
|
craigdo@3470
|
60 |
|
|
craigdo@3470
|
61 |
private:
|
|
craigdo@3470
|
62 |
void ProcessOneEvent (void);
|
|
craigdo@3470
|
63 |
uint64_t NextTs (void) const;
|
|
craigdo@3470
|
64 |
|
|
craigdo@3470
|
65 |
typedef std::list<EventId> DestroyEvents;
|
|
craigdo@3470
|
66 |
DestroyEvents m_destroyEvents;
|
|
craigdo@3470
|
67 |
bool m_stop;
|
|
craigdo@3470
|
68 |
Ptr<Scheduler> m_events;
|
|
craigdo@3470
|
69 |
uint32_t m_uid;
|
|
craigdo@3470
|
70 |
uint32_t m_currentUid;
|
|
craigdo@3470
|
71 |
uint64_t m_currentTs;
|
|
craigdo@3470
|
72 |
// number of events that have been inserted but not yet scheduled,
|
|
craigdo@3470
|
73 |
// not counting the "destroy" events; this is used for validation
|
|
craigdo@3470
|
74 |
int m_unscheduledEvents;
|
|
craigdo@3470
|
75 |
};
|
|
craigdo@3470
|
76 |
|
|
craigdo@3470
|
77 |
} // namespace ns3
|
|
craigdo@3470
|
78 |
|
|
craigdo@3470
|
79 |
#endif /* DEFAULT_SIMULATOR_IMPL_H */
|