--HG-- rename : src/core/abort.h => src/core/model/abort.h rename : src/core/assert.h => src/core/model/assert.h rename : src/core/attribute-accessor-helper.h => src/core/model/attribute-accessor-helper.h rename : src/core/attribute-helper.h => src/core/model/attribute-helper.h rename : src/core/attribute-list.cc => src/core/model/attribute-list.cc rename : src/core/attribute-list.h => src/core/model/attribute-list.h rename : src/core/attribute.cc => src/core/model/attribute.cc rename : src/core/attribute.h => src/core/model/attribute.h rename : src/core/boolean.cc => src/core/model/boolean.cc rename : src/core/boolean.h => src/core/model/boolean.h rename : src/core/breakpoint.cc => src/core/model/breakpoint.cc rename : src/core/breakpoint.h => src/core/model/breakpoint.h rename : src/simulator/cairo-wideint-private.h => src/core/model/cairo-wideint-private.h rename : src/simulator/cairo-wideint.c => src/core/model/cairo-wideint.c rename : src/simulator/calendar-scheduler.cc => src/core/model/calendar-scheduler.cc rename : src/simulator/calendar-scheduler.h => src/core/model/calendar-scheduler.h rename : src/core/callback.cc => src/core/model/callback.cc rename : src/core/callback.h => src/core/model/callback.h rename : src/core/command-line.cc => src/core/model/command-line.cc rename : src/core/command-line.h => src/core/model/command-line.h rename : src/core/config.cc => src/core/model/config.cc rename : src/core/config.h => src/core/model/config.h rename : src/core/default-deleter.h => src/core/model/default-deleter.h rename : src/simulator/default-simulator-impl.cc => src/core/model/default-simulator-impl.cc rename : src/simulator/default-simulator-impl.h => src/core/model/default-simulator-impl.h rename : src/core/deprecated.h => src/core/model/deprecated.h rename : src/core/double.cc => src/core/model/double.cc rename : src/core/double.h => src/core/model/double.h rename : src/core/empty.h => src/core/model/empty.h rename : src/core/enum.cc => src/core/model/enum.cc rename : src/core/enum.h => src/core/model/enum.h rename : src/simulator/event-id.cc => src/core/model/event-id.cc rename : src/simulator/event-id.h => src/core/model/event-id.h rename : src/simulator/event-impl.cc => src/core/model/event-impl.cc rename : src/simulator/event-impl.h => src/core/model/event-impl.h rename : src/core/fatal-error.h => src/core/model/fatal-error.h rename : src/core/fatal-impl.cc => src/core/model/fatal-impl.cc rename : src/core/fatal-impl.h => src/core/model/fatal-impl.h rename : src/core/global-value.cc => src/core/model/global-value.cc rename : src/core/global-value.h => src/core/model/global-value.h rename : src/simulator/heap-scheduler.cc => src/core/model/heap-scheduler.cc rename : src/simulator/heap-scheduler.h => src/core/model/heap-scheduler.h rename : src/simulator/high-precision-128.cc => src/core/model/high-precision-128.cc rename : src/simulator/high-precision-128.h => src/core/model/high-precision-128.h rename : src/simulator/high-precision-cairo.cc => src/core/model/high-precision-cairo.cc rename : src/simulator/high-precision-cairo.h => src/core/model/high-precision-cairo.h rename : src/simulator/high-precision-double.h => src/core/model/high-precision-double.h rename : src/simulator/high-precision.cc => src/core/model/high-precision.cc rename : src/simulator/high-precision.h => src/core/model/high-precision.h rename : src/core/int-to-type.h => src/core/model/int-to-type.h rename : src/core/integer.cc => src/core/model/integer.cc rename : src/core/integer.h => src/core/model/integer.h rename : src/simulator/list-scheduler.cc => src/core/model/list-scheduler.cc rename : src/simulator/list-scheduler.h => src/core/model/list-scheduler.h rename : src/core/log.cc => src/core/model/log.cc rename : src/core/log.h => src/core/model/log.h rename : src/simulator/make-event.cc => src/core/model/make-event.cc rename : src/simulator/make-event.h => src/core/model/make-event.h rename : src/simulator/map-scheduler.cc => src/core/model/map-scheduler.cc rename : src/simulator/map-scheduler.h => src/core/model/map-scheduler.h rename : src/core/names.cc => src/core/model/names.cc rename : src/core/names.h => src/core/model/names.h rename : src/simulator/ns2-calendar-scheduler.cc => src/core/model/ns2-calendar-scheduler.cc rename : src/simulator/ns2-calendar-scheduler.h => src/core/model/ns2-calendar-scheduler.h rename : src/simulator/nstime.h => src/core/model/nstime.h rename : src/core/object-base.cc => src/core/model/object-base.cc rename : src/core/object-base.h => src/core/model/object-base.h rename : src/core/object-factory.cc => src/core/model/object-factory.cc rename : src/core/object-factory.h => src/core/model/object-factory.h rename : src/core/object-vector.cc => src/core/model/object-vector.cc rename : src/core/object-vector.h => src/core/model/object-vector.h rename : src/core/object.cc => src/core/model/object.cc rename : src/core/object.h => src/core/model/object.h rename : src/core/pointer.cc => src/core/model/pointer.cc rename : src/core/pointer.h => src/core/model/pointer.h rename : src/core/ptr.h => src/core/model/ptr.h rename : src/core/random-variable.cc => src/core/model/random-variable.cc rename : src/core/random-variable.h => src/core/model/random-variable.h rename : src/simulator/realtime-simulator-impl.cc => src/core/model/realtime-simulator-impl.cc rename : src/simulator/realtime-simulator-impl.h => src/core/model/realtime-simulator-impl.h rename : src/core/ref-count-base.cc => src/core/model/ref-count-base.cc rename : src/core/ref-count-base.h => src/core/model/ref-count-base.h rename : src/core/rng-stream.cc => src/core/model/rng-stream.cc rename : src/core/rng-stream.h => src/core/model/rng-stream.h rename : src/simulator/scheduler.cc => src/core/model/scheduler.cc rename : src/simulator/scheduler.h => src/core/model/scheduler.h rename : src/core/simple-ref-count.h => src/core/model/simple-ref-count.h rename : src/simulator/simulation-singleton.h => src/core/model/simulation-singleton.h rename : src/simulator/simulator-impl.cc => src/core/model/simulator-impl.cc rename : src/simulator/simulator-impl.h => src/core/model/simulator-impl.h rename : src/simulator/simulator.cc => src/core/model/simulator.cc rename : src/simulator/simulator.h => src/core/model/simulator.h rename : src/core/singleton.h => src/core/model/singleton.h rename : src/core/string.cc => src/core/model/string.cc rename : src/core/string.h => src/core/model/string.h rename : src/simulator/synchronizer.cc => src/core/model/synchronizer.cc rename : src/simulator/synchronizer.h => src/core/model/synchronizer.h rename : src/core/system-condition.h => src/core/model/system-condition.h rename : src/core/system-mutex.h => src/core/model/system-mutex.h rename : src/core/system-thread.h => src/core/model/system-thread.h rename : src/core/system-wall-clock-ms.h => src/core/model/system-wall-clock-ms.h rename : src/core/test.cc => src/core/model/test.cc rename : src/core/test.h => src/core/model/test.h rename : src/simulator/time-base.cc => src/core/model/time-base.cc rename : src/simulator/time-base.h => src/core/model/time-base.h rename : src/simulator/time.cc => src/core/model/time.cc rename : src/simulator/timer-impl.h => src/core/model/timer-impl.h rename : src/simulator/timer.cc => src/core/model/timer.cc rename : src/simulator/timer.h => src/core/model/timer.h rename : src/core/trace-source-accessor.cc => src/core/model/trace-source-accessor.cc rename : src/core/trace-source-accessor.h => src/core/model/trace-source-accessor.h rename : src/core/traced-callback.h => src/core/model/traced-callback.h rename : src/core/traced-value.h => src/core/model/traced-value.h rename : src/core/type-id.cc => src/core/model/type-id.cc rename : src/core/type-id.h => src/core/model/type-id.h rename : src/core/type-name.cc => src/core/model/type-name.cc rename : src/core/type-name.h => src/core/model/type-name.h rename : src/core/type-traits.h => src/core/model/type-traits.h rename : src/core/uinteger.cc => src/core/model/uinteger.cc rename : src/core/uinteger.h => src/core/model/uinteger.h rename : src/simulator/unix-fd-reader.cc => src/core/model/unix-fd-reader.cc rename : src/simulator/unix-fd-reader.h => src/core/model/unix-fd-reader.h rename : src/core/unix-system-condition.cc => src/core/model/unix-system-condition.cc rename : src/core/unix-system-mutex.cc => src/core/model/unix-system-mutex.cc rename : src/core/unix-system-thread.cc => src/core/model/unix-system-thread.cc rename : src/core/unix-system-wall-clock-ms.cc => src/core/model/unix-system-wall-clock-ms.cc rename : src/core/vector.cc => src/core/model/vector.cc rename : src/core/vector.h => src/core/model/vector.h rename : src/simulator/wall-clock-synchronizer.cc => src/core/model/wall-clock-synchronizer.cc rename : src/simulator/wall-clock-synchronizer.h => src/core/model/wall-clock-synchronizer.h rename : src/simulator/watchdog.cc => src/core/model/watchdog.cc rename : src/simulator/watchdog.h => src/core/model/watchdog.h rename : src/core/win32-system-wall-clock-ms.cc => src/core/model/win32-system-wall-clock-ms.cc rename : src/core/attribute-test-suite.cc => src/core/test/attribute-test-suite.cc rename : src/core/callback-test-suite.cc => src/core/test/callback-test-suite.cc rename : src/core/names-test-suite.cc => src/core/test/names-test-suite.cc rename : src/core/ptr-test-suite.cc => src/core/test/ptr-test-suite.cc rename : src/core/rng-test-suite.cc => src/core/test/rng-test-suite.cc rename : src/core/traced-callback-test-suite.cc => src/core/test/traced-callback-test-suite.cc rename : src/core/type-traits-test-suite.cc => src/core/test/type-traits-test-suite.cc
203 lines
7.3 KiB
C++
203 lines
7.3 KiB
C++
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
|
/*
|
|
* Copyright (c) 2005,2006 INRIA
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation;
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*
|
|
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
|
*/
|
|
|
|
#ifndef SIMULATOR_IMPL_H
|
|
#define SIMULATOR_IMPL_H
|
|
|
|
#include "event-impl.h"
|
|
#include "event-id.h"
|
|
#include "nstime.h"
|
|
#include "ns3/object.h"
|
|
#include "ns3/object-factory.h"
|
|
#include "ns3/ptr.h"
|
|
|
|
namespace ns3 {
|
|
|
|
class Scheduler;
|
|
|
|
class SimulatorImpl : public Object
|
|
{
|
|
public:
|
|
static TypeId GetTypeId (void);
|
|
|
|
/**
|
|
* Every event scheduled by the Simulator::insertAtDestroy method is
|
|
* invoked. Then, we ensure that any memory allocated by the
|
|
* Simulator is freed.
|
|
* This method is typically invoked at the end of a simulation
|
|
* to avoid false-positive reports by a leak checker.
|
|
* After this method has been invoked, it is actually possible
|
|
* to restart a new simulation with a set of calls to Simulator::run
|
|
* and Simulator::insert_*.
|
|
*/
|
|
virtual void Destroy () = 0;
|
|
/**
|
|
* If there are no more events lefts to be scheduled, or if simulation
|
|
* time has already reached the "stop time" (see Simulator::Stop()),
|
|
* return true. Return false otherwise.
|
|
*/
|
|
virtual bool IsFinished (void) const = 0;
|
|
/**
|
|
* If Simulator::IsFinished returns true, the behavior of this
|
|
* method is undefined. Otherwise, it returns the microsecond-based
|
|
* time of the next event expected to be scheduled.
|
|
*/
|
|
virtual Time Next (void) const = 0;
|
|
/**
|
|
* If an event invokes this method, it will be the last
|
|
* event scheduled by the Simulator::run method before
|
|
* returning to the caller.
|
|
*/
|
|
virtual void Stop (void) = 0;
|
|
/**
|
|
* Force the Simulator::run method to return to the caller when the
|
|
* expiration time of the next event to be processed is greater than
|
|
* or equal to the stop time. The stop time is relative to the
|
|
* current simulation time.
|
|
* @param time the stop time, relative to the current time.
|
|
*/
|
|
virtual void Stop (Time const &time) = 0;
|
|
/**
|
|
* \param time delay until the event expires
|
|
* \param event the event to schedule
|
|
* \returns a unique identifier for the newly-scheduled event.
|
|
*
|
|
* This method will be typically used by language bindings
|
|
* to delegate events to their own subclass of the EventImpl base class.
|
|
*/
|
|
virtual EventId Schedule (Time const &time, EventImpl *event) = 0;
|
|
/**
|
|
* \param time delay until the event expires
|
|
* \param context event context
|
|
* \param event the event to schedule
|
|
* \returns a unique identifier for the newly-scheduled event.
|
|
*
|
|
* This method will be typically used by language bindings
|
|
* to delegate events to their own subclass of the EventImpl base class.
|
|
*/
|
|
virtual void ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event) = 0;
|
|
/**
|
|
* \param event the event to schedule
|
|
* \returns a unique identifier for the newly-scheduled event.
|
|
*
|
|
* This method will be typically used by language bindings
|
|
* to delegate events to their own subclass of the EventImpl base class.
|
|
*/
|
|
virtual EventId ScheduleNow (EventImpl *event) = 0;
|
|
/**
|
|
* \param event the event to schedule
|
|
* \returns a unique identifier for the newly-scheduled event.
|
|
*
|
|
* This method will be typically used by language bindings
|
|
* to delegate events to their own subclass of the EventImpl base class.
|
|
*/
|
|
virtual EventId ScheduleDestroy (EventImpl *event) = 0;
|
|
/**
|
|
* Remove an event from the event list.
|
|
* This method has the same visible effect as the
|
|
* ns3::EventId::Cancel method
|
|
* but its algorithmic complexity is much higher: it has often
|
|
* O(log(n)) complexity, sometimes O(n), sometimes worse.
|
|
* Note that it is not possible to remove events which were scheduled
|
|
* for the "destroy" time. Doing so will result in a program error (crash).
|
|
*
|
|
* @param ev the event to remove from the list of scheduled events.
|
|
*/
|
|
virtual void Remove (const EventId &ev) = 0;
|
|
/**
|
|
* Set the cancel bit on this event: the event's associated function
|
|
* will not be invoked when it expires.
|
|
* This method has the same visible effect as the
|
|
* ns3::Simulator::remove method but its algorithmic complexity is
|
|
* much lower: it has O(1) complexity.
|
|
* This method has the exact same semantics as ns3::EventId::cancel.
|
|
* Note that it is not possible to cancel events which were scheduled
|
|
* for the "destroy" time. Doing so will result in a program error (crash).
|
|
*
|
|
* @param ev the event to cancel
|
|
*/
|
|
virtual void Cancel (const EventId &ev) = 0;
|
|
/**
|
|
* This method has O(1) complexity.
|
|
* Note that it is not possible to test for the expiration of
|
|
* events which were scheduled for the "destroy" time. Doing so
|
|
* will result in a program error (crash).
|
|
* An event is said to "expire" when it starts being scheduled
|
|
* which means that if the code executed by the event calls
|
|
* this function, it will get true.
|
|
*
|
|
* @param ev the event to test for expiration
|
|
* @returns true if the event has expired, false otherwise.
|
|
*/
|
|
virtual bool IsExpired (const EventId &ev) const = 0;
|
|
/**
|
|
* Run the simulation until one of:
|
|
* - no events are present anymore
|
|
* - the user called Simulator::stop
|
|
* - the user called Simulator::stopAtUs and the
|
|
* expiration time of the next event to be processed
|
|
* is greater than or equal to the stop time.
|
|
*/
|
|
virtual void Run (void) = 0;
|
|
/**
|
|
* Process only the next simulation event, then return immediately.
|
|
*/
|
|
virtual void RunOneEvent (void) = 0;
|
|
/**
|
|
* Return the "current simulation time".
|
|
*/
|
|
virtual Time Now (void) const = 0;
|
|
/**
|
|
* \param id the event id to analyse
|
|
* \return the delay left until the input event id expires.
|
|
* if the event is not running, this method returns
|
|
* zero.
|
|
*/
|
|
virtual Time GetDelayLeft (const EventId &id) const = 0;
|
|
/**
|
|
* \return the maximum simulation time at which an event
|
|
* can be scheduled.
|
|
*
|
|
* The returned value will always be bigger than or equal to Simulator::Now.
|
|
*/
|
|
virtual Time GetMaximumSimulationTime (void) const = 0;
|
|
/**
|
|
* \param schedulerFactory a new event scheduler factory
|
|
*
|
|
* The event scheduler can be set at any time: the events scheduled
|
|
* in the previous scheduler will be transfered to the new scheduler
|
|
* before we start to use it.
|
|
*/
|
|
virtual void SetScheduler (ObjectFactory schedulerFactory) = 0;
|
|
/**
|
|
* \return the system id for this simulator; used for
|
|
* MPI or other distributed simulations
|
|
*/
|
|
virtual uint32_t GetSystemId () const = 0;
|
|
/**
|
|
* \return the current simulation context
|
|
*/
|
|
virtual uint32_t GetContext (void) const = 0;
|
|
};
|
|
|
|
} // namespace ns3
|
|
|
|
#endif /* SIMULATOR_IMPL_H */
|