[Doxygen] Events.
--- a/src/core/model/event-id.cc Sun Dec 07 18:30:55 2014 -0800
+++ b/src/core/model/event-id.cc Sun Dec 07 20:53:37 2014 -0800
@@ -22,6 +22,12 @@
#include "event-impl.h"
#include "log.h"
+/**
+ * \file
+ * \ingroup events
+ * ns3::EventId definitions.
+ */
+
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("EventId");
--- a/src/core/model/event-id.h Sun Dec 07 18:30:55 2014 -0800
+++ b/src/core/model/event-id.h Sun Dec 07 20:53:37 2014 -0800
@@ -24,62 +24,99 @@
#include "ptr.h"
#include "event-impl.h"
+/**
+ * \file
+ * \ingroup events
+ * ns3::EventId declarations.
+ */
+
namespace ns3 {
class EventImpl;
/**
* \ingroup events
- * \brief an identifier for simulation events.
+ * \brief An identifier for simulation events.
*
* Each EventId identifies a unique event scheduled with one
- * of the many Simulator::Schedule methods. This EventId can
- * be used to Cancel or Remove events after they are scheduled
- * with Simulator::Cancel or Simulator::Remove.
+ * of the many Simulator::Schedule() methods. This EventId can
+ * be used to cancel or remove events after they are scheduled
+ * with Simulator::Cancel() or Simulator::Remove().
*
* The important thing to remember about this class is that
* every variable of this type is _always_ in a valid state,
- * even when it has not been assigned an EventId coming from a Schedule
- * method: calling Cancel, IsRunning, IsExpired or passing around
- * instances of this object will not result in crashes or memory leaks.
+ * even when it has not been assigned an EventId coming from a
+ * Simulator::Schedule() method: calling Simulator::Cancel(), IsRunning(),
+ * IsExpired() or passing around instances of this object
+ * will not result in crashes or memory leaks.
*/
class EventId {
public:
+ /** Default constructor. This EventId does nothing. */
EventId ();
- // internal.
+ /**
+ * Construct a real event.
+ *
+ * \param [in] impl The implementation of this event.
+ * \param [in] ts The virtual time stamp this event should occur.
+ * \param [in] context The execution context for this event.
+ * \param [in] uid The unique id for this EventId.
+ */
EventId (const Ptr<EventImpl> &impl, uint64_t ts, uint32_t context, uint32_t uid);
/**
- * This method is syntactic sugar for the ns3::Simulator::cancel
+ * This method is syntactic sugar for the ns3::Simulator::Cancel
* method.
*/
void Cancel (void);
/**
- * This method is syntactic sugar for the ns3::Simulator::isExpired
+ * This method is syntactic sugar for the ns3::Simulator::IsExpired
* method.
- * \returns true if the event has expired, false otherwise.
+ * \returns \c true if the event has expired, \c false otherwise.
*/
bool IsExpired (void) const;
/**
- * This method is syntactic sugar for the ns3::Simulator::isExpired
- * method.
- * \returns true if the event has not expired, false otherwise.
+ * This method is syntactic sugar for !IsExpired().
+ *
+ * \returns \c true if the event has not expired, \c false otherwise.
*/
bool IsRunning (void) const;
public:
- /* The following methods are semi-private
- * they are supposed to be invoked only by
+ /**
+ * \name Scheduler Helpers.
+ * \brief These methods are normally invoked only by
* subclasses of the Scheduler base class.
*/
+ /**@{*/
+ /** \return The underlying EventImpl pointer. */
EventImpl *PeekEventImpl (void) const;
+ /** \return The virtual time stamp. */
uint64_t GetTs (void) const;
+ /** \return The event context. */
uint32_t GetContext (void) const;
+ /** \return The unique id. */
uint32_t GetUid (void) const;
+ /**@}*/
+
private:
+ /**
+ * Test if two EventId's are equal.
+ * \param a The first EventId.
+ * \param b The second EventId.
+ * \return \c true if the \p a and \p b represent the same event.
+ */
friend bool operator == (const EventId &a, const EventId &b);
- Ptr<EventImpl> m_eventImpl;
- uint64_t m_ts;
- uint32_t m_context;
- uint32_t m_uid;
+ /**
+ * Test if two EventId's are not equal.
+ * \param a The first EventId.
+ * \param b The second EventId.
+ * \return \c true if the \p a and \p b are not the same event.
+ */
+ friend bool operator != (const EventId &a, const EventId &b);
+
+ Ptr<EventImpl> m_eventImpl; /**< The underlying event implementation. */
+ uint64_t m_ts; /**< The virtual time stamp. */
+ uint32_t m_context; /**< The context. */
+ uint32_t m_uid; /**< The unique id. */
};
bool operator == (const EventId &a, const EventId &b);
--- a/src/core/model/event-impl.cc Sun Dec 07 18:30:55 2014 -0800
+++ b/src/core/model/event-impl.cc Sun Dec 07 20:53:37 2014 -0800
@@ -21,6 +21,12 @@
#include "event-impl.h"
#include "log.h"
+/**
+ * \file
+ * \ingroup events
+ * ns3::EventImpl definitions.
+ */
+
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("EventImpl");
--- a/src/core/model/event-impl.h Sun Dec 07 18:30:55 2014 -0800
+++ b/src/core/model/event-impl.h Sun Dec 07 20:53:37 2014 -0800
@@ -23,46 +23,60 @@
#include <stdint.h>
#include "simple-ref-count.h"
+/**
+ * \file
+ * \ingroup events
+ * ns3::EventImpl declarations.
+ */
+
namespace ns3 {
/**
* \ingroup events
- * \brief a simulation event
+ * \brief A simulation event.
*
* Each subclass of this base class represents a simulation event. The
- * EventImpl::Invoke method will be invoked by the simulation engine
- * when the time associated to this event expires. This class is
- * obviously (there are Ref and Unref methods) reference-counted and
- * most subclasses are usually created by one of the many Simulator::Schedule
+ * Invoke() method will be called by the simulation engine
+ * when it reaches the time associated to this event. Most subclasses
+ * are usually created by one of the many Simulator::Schedule
* methods.
*/
class EventImpl : public SimpleRefCount<EventImpl>
{
public:
+ /** Default constructor. */
EventImpl ();
+ /** Destructor. */
virtual ~EventImpl () = 0;
/**
- * Called by the simulation engine to notify the event that it has expired.
+ * Called by the simulation engine to notify the event that it is time
+ * to execute.
*/
void Invoke (void);
/**
- * Marks the event as 'canceled'. The event will not be removed from
+ * Marks the event as 'canceled'. The event is not removed from
* the event list but the simulation engine will check its canceled status
- * before calling Invoke.
+ * before calling Invoke().
*/
void Cancel (void);
/**
* \returns true if the event has been canceled.
*
- * Invoked by the simulation engine before calling Invoke.
+ * Checked by the simulation engine before calling Invoke().
*/
bool IsCancelled (void);
protected:
+ /**
+ * Implementation for Invoke().
+ *
+ * This typically calls a method or function pointer with the
+ * arguments bound by a call to one of the MakeEvent() functions.
+ */
virtual void Notify (void) = 0;
private:
- bool m_cancel;
+ bool m_cancel; /**< Has this event been cancelled. */
};
} // namespace ns3
--- a/src/core/model/make-event.cc Sun Dec 07 18:30:55 2014 -0800
+++ b/src/core/model/make-event.cc Sun Dec 07 20:53:37 2014 -0800
@@ -20,10 +20,17 @@
#include "make-event.h"
#include "log.h"
+/**
+ * \file
+ * \ingroup events
+ * ns3::MakeEvent(void(*f)(void)) definition.
+ */
+
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("MakeEvent");
+// This is the only non-templated version of MakeEvent.
EventImpl * MakeEvent (void (*f)(void))
{
NS_LOG_FUNCTION (f);
--- a/src/core/model/make-event.h Sun Dec 07 18:30:55 2014 -0800
+++ b/src/core/model/make-event.h Sun Dec 07 20:53:37 2014 -0800
@@ -20,54 +20,242 @@
#ifndef MAKE_EVENT_H
#define MAKE_EVENT_H
+/**
+ * \file
+ * \ingroup events
+ * ns3::MakeEvent function declarations and template definitions.
+ */
+
namespace ns3 {
class EventImpl;
+/**
+ * \ingroup events
+ * \defgroup makeeventmemptr MakeEvent from member function pointer.
+ *
+ * Create EventImpl instances from class member functions which take
+ * varying numbers of arguments.
+ */
+/**
+ * \ingroup makeeventmemptr
+ * @{
+ */
+/**
+ * Make an EventImpl from class method members which take
+ * varying numbers of arguments.
+ *
+ * \tparam MEM The class method function signature.
+ * \tparam OBJ The class type holding the method.
+ * \param mem_ptr Class method member function pointer
+ * \param obj Class instance.
+ * \returns The constructed EventImpl.
+ */
template <typename MEM, typename OBJ>
EventImpl * MakeEvent (MEM mem_ptr, OBJ obj);
+/**
+ * \copybrief MakeEvent(MEM,OBJ)
+ * \tparam MEM The class method function signature.
+ * \tparam OBJ The class type holding the method.
+ * \tparam T1 Type of the argument to the underlying function.
+ * \param mem_ptr Class method member function pointer
+ * \param obj Class instance.
+ * \param a1 Argument value to be bound to the underlying function.
+ * \returns The constructed EventImpl.
+ */
template <typename MEM, typename OBJ,
typename T1>
EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, T1 a1);
+/**
+ * \copybrief MakeEvent(MEM,OBJ)
+ * \tparam MEM The class method function signature.
+ * \tparam OBJ The class type holding the method.
+ * \tparam T1 Type of the first argument to the underlying function.
+ * \tparam T2 Type of the second argument to the underlying function.
+ * \param mem_ptr Class method member function pointer
+ * \param obj Class instance.
+ * \param a1 First argument value to be bound to the underlying function.
+ * \param a2 Second argument value to be bound to the underlying function.
+ * \returns The constructed EventImpl.
+ */
template <typename MEM, typename OBJ,
typename T1, typename T2>
EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
+/**
+ * \copybrief MakeEvent(MEM,OBJ)
+ * \tparam MEM The class method function signature.
+ * \tparam OBJ The class type holding the method.
+ * \tparam T1 Type of the first argument to the underlying function.
+ * \tparam T2 Type of the second argument to the underlying function.
+ * \tparam T3 Type of the third argument to the underlying function.
+ * \param mem_ptr Class method member function pointer
+ * \param obj Class instance.
+ * \param a1 First argument value to be bound to the underlying function.
+ * \param a2 Second argument value to be bound to the underlying function.
+ * \param a3 Third argument value to be bound to the underlying function.
+ * \returns The constructed EventImpl.
+ */
template <typename MEM, typename OBJ,
typename T1, typename T2, typename T3>
EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
+/**
+ * \copybrief MakeEvent(MEM,OBJ)
+ * \tparam MEM The class method function signature.
+ * \tparam OBJ The class type holding the method.
+ * \tparam T1 Type of the first argument to the underlying function.
+ * \tparam T2 Type of the second argument to the underlying function.
+ * \tparam T3 Type of the third argument to the underlying function.
+ * \tparam T4 Type of the fourth argument to the underlying function.
+ * \param mem_ptr Class method member function pointer
+ * \param obj Class instance.
+ * \param a1 First argument value to be bound to the underlying function.
+ * \param a2 Second argument value to be bound to the underlying function.
+ * \param a3 Third argument value to be bound to the underlying function.
+ * \param a4 Fourth argument value to be bound to the underlying function.
+ * \returns The constructed EventImpl.
+ */
template <typename MEM, typename OBJ,
typename T1, typename T2, typename T3, typename T4>
EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4);
+/**
+ * \copybrief MakeEvent(MEM,OBJ)
+ * \tparam MEM The class method function signature.
+ * \tparam OBJ The class type holding the method.
+ * \tparam T1 Type of the first argument to the underlying function.
+ * \tparam T2 Type of the second argument to the underlying function.
+ * \tparam T3 Type of the third argument to the underlying function.
+ * \tparam T4 Type of the fourth argument to the underlying function.
+ * \tparam T5 Type of the fifth argument to the underlying function.
+ * \param mem_ptr Class method member function pointer
+ * \param obj Class instance.
+ * \param a1 First argument value to be bound to the underlying function.
+ * \param a2 Second argument value to be bound to the underlying function.
+ * \param a3 Third argument value to be bound to the underlying function.
+ * \param a4 Fourth argument value to be bound to the underlying function.
+ * \param a5 Fifh argument value to be bound to the underlying function.
+ * \returns The constructed EventImpl.
+ */
template <typename MEM, typename OBJ,
typename T1, typename T2, typename T3, typename T4, typename T5>
EventImpl * MakeEvent (MEM mem_ptr, OBJ obj,
T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
+/**@}*/
+
+/**
+ * \ingroup events
+ * \defgroup makeeventfnptr MakeEvent from function pointers.
+ *
+ * Create EventImpl instances from function pointers which take
+ * varying numbers of arguments.
+ */
+/**
+ * \ingroup makeeventfnptr
+ * @{
+ */
+/**
+ * Make an EventImpl from a function pointer taking varying numbers
+ * of arguments.
+ *
+ * \param f The function pointer.
+ * \returns The constructed EventImpl.
+ */
+EventImpl * MakeEvent (void (*f)(void));
-EventImpl * MakeEvent (void (*f)(void));
+/**
+ * \copybrief MakeEvent(void(*f)(void))
+ * \tparam U1 Formal type of the argument to the function.
+ * \tparam T1 Actual type of the argument to the function.
+ * \param f The function pointer.
+ * \param a1 Argument to be bound to the function.
+ * \returns The constructed EventImpl.
+ */
template <typename U1,
typename T1>
EventImpl * MakeEvent (void (*f)(U1), T1 a1);
+/**
+ * \copybrief MakeEvent(void(*f)(void))
+ * \tparam U1 Formal type of the first argument to the function.
+ * \tparam U2 Formal type of the second argument to the function.
+ * \tparam T1 Actual type of the first argument to the function.
+ * \tparam T2 Actual type of the second argument to the function.
+ * \param f The function pointer.
+ * \param a1 First argument to be bound to the function.
+ * \param a2 Second argument to be bound to the function.
+ * \returns The constructed EventImpl.
+ */
template <typename U1, typename U2,
typename T1, typename T2>
EventImpl * MakeEvent (void (*f)(U1,U2), T1 a1, T2 a2);
+/**
+ * \copybrief MakeEvent(void(*f)(void))
+ * \tparam U1 Formal type of the first argument to the function.
+ * \tparam U2 Formal type of the second argument to the function.
+ * \tparam U3 Formal type of the third argument to the function.
+ * \tparam T1 Actual type of the first argument to the function.
+ * \tparam T2 Actual type of the second argument to the function.
+ * \tparam T3 Actual type of the third argument to the function.
+ * \param f The function pointer.
+ * \param a1 First argument to be bound to the function.
+ * \param a2 Second argument to be bound to the function.
+ * \param a3 Third argument to be bound to the function.
+ * \returns The constructed EventImpl.
+ */
template <typename U1, typename U2, typename U3,
typename T1, typename T2, typename T3>
EventImpl * MakeEvent (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
+/**
+ * \copybrief MakeEvent(void(*f)(void))
+ * \tparam U1 Formal type of the first argument to the function.
+ * \tparam U2 Formal type of the second argument to the function.
+ * \tparam U3 Formal type of the third argument to the function.
+ * \tparam U4 Formal type of the fourth argument to the function.
+ * \tparam T1 Actual type of the first argument to the function.
+ * \tparam T2 Actual type of the second argument to the function.
+ * \tparam T3 Actual type of the third argument to the function.
+ * \tparam T4 Actual type of the fourth argument to the function.
+ * \param f The function pointer.
+ * \param a1 First argument to be bound to the function.
+ * \param a2 Second argument to be bound to the function.
+ * \param a3 Third argument to be bound to the function.
+ * \param a4 Fourth argument to be bound to the function.
+ * \returns The constructed EventImpl.
+ */
template <typename U1, typename U2, typename U3, typename U4,
typename T1, typename T2, typename T3, typename T4>
EventImpl * MakeEvent (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
+/**
+ * \copybrief MakeEvent(void(*f)(void))
+ * \tparam U1 Formal type of the first argument to the function.
+ * \tparam U2 Formal type of the second argument to the function.
+ * \tparam U3 Formal type of the third argument to the function.
+ * \tparam U4 Formal type of the fourth argument to the function.
+ * \tparam U5 Formal type of the fifth argument to the function.
+ * \tparam T1 Actual type of the first argument to the function.
+ * \tparam T2 Actual type of the second argument to the function.
+ * \tparam T3 Actual type of the third argument to the function.
+ * \tparam T4 Actual type of the fourth argument to the function.
+ * \tparam T5 Actual type of the fifth argument to the function.
+ * \param f The function pointer.
+ * \param a1 First argument to be bound to the function.
+ * \param a2 Second argument to be bound to the function.
+ * \param a3 Third argument to be bound to the function.
+ * \param a4 Fourth argument to be bound to the function.
+ * \param a5 Fifth argument to be bound to the function.
+ * \returns The constructed EventImpl.
+ */
template <typename U1, typename U2, typename U3, typename U4, typename U5,
typename T1, typename T2, typename T3, typename T4, typename T5>
EventImpl * MakeEvent (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
+/**@}*/
} // namespace ns3
@@ -80,12 +268,32 @@
namespace ns3 {
+/**
+ * \ingroup makeeventmemptr
+ * Helper for the MakeEvent functions which take a class method.
+ *
+ * This is the generic template declaration (with empty body).
+ *
+ * \tparam T The class type.
+ */
template <typename T>
struct EventMemberImplObjTraits;
+/**
+ * \ingroup makeeventmemptr
+ * Helper for the MakeEvent functions which take a class method.
+ *
+ * This is the specialization for pointer types.
+ *
+ * \tparam T The class type.
+ */
template <typename T>
struct EventMemberImplObjTraits<T *>
{
+ /**
+ * \param p Object pointer.
+ * \return A reference to the object pointed to by p.
+ */
static T &GetReference (T *p)
{
return *p;
--- a/src/core/model/scheduler.h Sun Dec 07 18:30:55 2014 -0800
+++ b/src/core/model/scheduler.h Sun Dec 07 20:53:37 2014 -0800
@@ -24,6 +24,14 @@
#include <stdint.h>
#include "object.h"
+/**
+ * \file
+ * \ingroup scheduler
+ * \ingroup events
+ * ns3::Scheduler abstract base class, ns3::Scheduler::Event and
+ * ns3::Scheduler::EventKey declarations.
+ */
+
namespace ns3 {
class EventImpl;
@@ -60,18 +68,27 @@
public:
static TypeId GetTypeId (void);
- /** \ingroup events */
+ /**
+ * \ingroup events
+ * Structure for sorting and comparing Events.
+ */
struct EventKey
{
- uint64_t m_ts;
- uint32_t m_uid;
- uint32_t m_context;
+ uint64_t m_ts; /**< Event time stamp. */
+ uint32_t m_uid; /**< Event unique id. */
+ uint32_t m_context; /**< Event context. */
};
- /** \ingroup events */
+ /**
+ * \ingroup events
+ * Scheduler event.
+ *
+ * An Event consists of an EventKey, used for maintaining the schedule,
+ * and an EventImpl which is the actual implementation.
+ */
struct Event
{
- EventImpl *impl;
- EventKey key;
+ EventImpl *impl; /**< Pointer to the event implementation. */
+ EventKey key; /**< Key for sorting and ordering Events. */
};
virtual ~Scheduler () = 0;