try to get rid of tabs which sneaked in

This commit is contained in:
Mathieu Lacage
2006-10-02 14:37:46 +02:00
parent 9f93b7fb53
commit bbcf953d34
19 changed files with 707 additions and 707 deletions

View File

@@ -35,7 +35,7 @@ MyHeader::printTo (std::ostream &os) const
uint32_t
MyHeader::getSerializedSize (void) const
{
return 2;
return 2;
}
void
MyHeader::serializeTo (Buffer::Iterator start) const

View File

@@ -9,24 +9,24 @@ using namespace ns3;
// declare subclass of base class Test
class MyTest : public Test {
public:
MyTest (bool ok);
virtual ~MyTest ();
virtual bool runTests (void);
MyTest (bool ok);
virtual ~MyTest ();
virtual bool runTests (void);
private:
bool m_ok;
bool m_ok;
};
// implement MyTest
MyTest::MyTest (bool ok)
: Test ("My"),
m_ok (ok)
: Test ("My"),
m_ok (ok)
{}
MyTest::~MyTest ()
{}
bool
MyTest::runTests (void)
{
return m_ok;
return m_ok;
}
// instantiate MyTest once
@@ -36,8 +36,8 @@ static MyTest g_my_test = MyTest (true);
int main (int argc, char *argv[])
{
// run tests
TestManager::enableVerbose ();
TestManager::runTests ();
return 0;
// run tests
TestManager::enableVerbose ();
TestManager::runTests ();
return 0;
}

View File

@@ -35,7 +35,7 @@ Header::print (std::ostream &os) const
uint32_t
Header::getSize (void) const
{
return getSerializedSize ();
return getSerializedSize ();
}
void
Header::serialize (Buffer::Iterator start) const
@@ -51,7 +51,7 @@ Header::deserialize (Buffer::Iterator start)
bool
Header::isDeserialized (void) const
{
return m_isDeserialized;
return m_isDeserialized;
}

View File

@@ -48,10 +48,10 @@ public:
virtual ~Header () = 0;
void print (std::ostream &os) const;
uint32_t getSize (void) const;
uint32_t getSize (void) const;
void serialize (Buffer::Iterator start) const;
void deserialize (Buffer::Iterator start);
bool isDeserialized (void) const;
bool isDeserialized (void) const;
private:
bool m_isDeserialized;
/**
@@ -60,10 +60,10 @@ private:
*/
virtual void printTo (std::ostream &os) const = 0;
/**
* \returns the size of the serialized Header.
*/
virtual uint32_t getSerializedSize (void) const = 0;
/**
* \returns the size of the serialized Header.
*/
virtual uint32_t getSerializedSize (void) const = 0;
/**
* \param start the buffer iterator in which the protocol header

View File

@@ -27,21 +27,21 @@ uint32_t Packet::m_global_uid = 0;
Packet::Packet ()
: m_buffer (),
m_uid (m_global_uid)
m_uid (m_global_uid)
{
m_global_uid++;
m_global_uid++;
}
Packet::Packet (uint32_t size)
: m_buffer (size),
m_uid (m_global_uid)
m_uid (m_global_uid)
{
m_global_uid++;
m_global_uid++;
}
Packet::Packet (Buffer buffer, Tags tags, uint32_t uid)
: m_buffer (buffer),
m_tags (tags),
m_uid (uid)
m_uid (uid)
{}
Packet
@@ -60,40 +60,40 @@ Packet::getSize (void) const
void
Packet::add (Header const &header)
{
m_buffer.addAtStart (header.getSize ());
header.serialize (m_buffer.begin ());
m_buffer.addAtStart (header.getSize ());
header.serialize (m_buffer.begin ());
}
void
Packet::peek (Header &header)
{
header.deserialize (m_buffer.begin ());
header.deserialize (m_buffer.begin ());
}
void
Packet::remove (Header const &header)
{
assert (header.isDeserialized ());
m_buffer.removeAtStart (header.getSize ());
assert (header.isDeserialized ());
m_buffer.removeAtStart (header.getSize ());
}
void
Packet::add (Trailer const &trailer)
{
m_buffer.addAtEnd (trailer.getSize ());
Buffer::Iterator start = m_buffer.end ();
start.prev (trailer.getSize ());
trailer.serialize (start);
m_buffer.addAtEnd (trailer.getSize ());
Buffer::Iterator start = m_buffer.end ();
start.prev (trailer.getSize ());
trailer.serialize (start);
}
void
Packet::peek (Trailer &trailer)
{
Buffer::Iterator start = m_buffer.end ();
start.prev (trailer.getSize ());
trailer.deserialize (start);
Buffer::Iterator start = m_buffer.end ();
start.prev (trailer.getSize ());
trailer.deserialize (start);
}
void
Packet::remove (Trailer const &trailer)
{
assert (trailer.isDeserialized ());
m_buffer.removeAtEnd (trailer.getSize ());
assert (trailer.isDeserialized ());
m_buffer.removeAtEnd (trailer.getSize ());
}
@@ -148,13 +148,13 @@ Packet::removeAllTags (void)
uint8_t const *
Packet::peekData (void) const
{
return m_buffer.peekData ();
return m_buffer.peekData ();
}
uint32_t
Packet::getUid (void) const
{
return m_uid;
return m_uid;
}
}; // namespace ns3

View File

@@ -87,184 +87,184 @@ namespace ns3 {
*/
class Packet {
public:
/**
* Create an empty packet with a new uid (as returned
* by getUid).
*/
/**
* Create an empty packet with a new uid (as returned
* by getUid).
*/
Packet ();
/**
* Create a packet with a zero-filled payload.
* The memory necessary for the payload is not allocated:
* it will be allocated at any later point if you attempt
* to fragment this packet or to access the zero-filled
* bytes. The packet is allocated with a new uid (as
* returned by getUid).
*
* \param size the size of the zero-filled payload
*/
/**
* Create a packet with a zero-filled payload.
* The memory necessary for the payload is not allocated:
* it will be allocated at any later point if you attempt
* to fragment this packet or to access the zero-filled
* bytes. The packet is allocated with a new uid (as
* returned by getUid).
*
* \param size the size of the zero-filled payload
*/
Packet (uint32_t size);
/**
* Create a new packet which contains a fragment of the original
* packet. The returned packet shares the same uid as this packet.
*
* \param start offset from start of packet to start of fragment to create
* \param length length of fragment to create
* \returns a fragment of the original packet
*/
/**
* Create a new packet which contains a fragment of the original
* packet. The returned packet shares the same uid as this packet.
*
* \param start offset from start of packet to start of fragment to create
* \param length length of fragment to create
* \returns a fragment of the original packet
*/
Packet createFragment (uint32_t start, uint32_t length) const;
/**
* \returns the size in bytes of the packet (including the zero-filled
* initial payload)
*/
/**
* \returns the size in bytes of the packet (including the zero-filled
* initial payload)
*/
uint32_t getSize (void) const;
/**
* Add header to this packet. This method invokes the
* ns3::Header::serializeTo method to request the header to serialize
* itself in the packet buffer.
*
* \param header a reference to the header to add to this packet.
*/
void add (Header const &header);
/**
* Deserialize header from this packet. This method invokes the
* ns3::Header::deserializeFrom method to request the header to deserialize
* itself from the packet buffer. This method does not remove
* the data from the buffer. It merely reads it.
*
* \param header a reference to the header to deserialize from the buffer
*/
void peek (Header &header);
/**
* Remove a deserialized header from the internal buffer.
* This method removes the bytes read by Packet::peek from
* the packet buffer.
*
* \param header a reference to the header to remove from the internal buffer.
*/
void remove (Header const &header);
/**
* Add trailer to this packet. This method invokes the
* ns3::Trailer::serializeTo method to request the trailer to serialize
* itself in the packet buffer.
*
* \param trailer a reference to the trailer to add to this packet.
*/
void add (Trailer const &trailer);
/**
* Deserialize trailer from this packet. This method invokes the
* ns3::Trailer::deserializeFrom method to request the trailer to deserialize
* itself from the packet buffer. This method does not remove
* the data from the buffer. It merely reads it.
*
* \param trailer a reference to the trailer to deserialize from the buffer
*/
void peek (Trailer &trailer);
/**
* Remove a deserialized trailer from the internal buffer.
* This method removes the bytes read by Packet::peek from
* the packet buffer.
*
* \param trailer a reference to the trailer to remove from the internal buffer.
*/
void remove (Trailer const &trailer);
/**
* Attach a tag to this packet. The tag is fully copied
* in a packet-specific internal buffer. This operation
* is expected to be really fast.
*
* \param tag a pointer to the tag to attach to this packet.
*/
/**
* Add header to this packet. This method invokes the
* ns3::Header::serializeTo method to request the header to serialize
* itself in the packet buffer.
*
* \param header a reference to the header to add to this packet.
*/
void add (Header const &header);
/**
* Deserialize header from this packet. This method invokes the
* ns3::Header::deserializeFrom method to request the header to deserialize
* itself from the packet buffer. This method does not remove
* the data from the buffer. It merely reads it.
*
* \param header a reference to the header to deserialize from the buffer
*/
void peek (Header &header);
/**
* Remove a deserialized header from the internal buffer.
* This method removes the bytes read by Packet::peek from
* the packet buffer.
*
* \param header a reference to the header to remove from the internal buffer.
*/
void remove (Header const &header);
/**
* Add trailer to this packet. This method invokes the
* ns3::Trailer::serializeTo method to request the trailer to serialize
* itself in the packet buffer.
*
* \param trailer a reference to the trailer to add to this packet.
*/
void add (Trailer const &trailer);
/**
* Deserialize trailer from this packet. This method invokes the
* ns3::Trailer::deserializeFrom method to request the trailer to deserialize
* itself from the packet buffer. This method does not remove
* the data from the buffer. It merely reads it.
*
* \param trailer a reference to the trailer to deserialize from the buffer
*/
void peek (Trailer &trailer);
/**
* Remove a deserialized trailer from the internal buffer.
* This method removes the bytes read by Packet::peek from
* the packet buffer.
*
* \param trailer a reference to the trailer to remove from the internal buffer.
*/
void remove (Trailer const &trailer);
/**
* Attach a tag to this packet. The tag is fully copied
* in a packet-specific internal buffer. This operation
* is expected to be really fast.
*
* \param tag a pointer to the tag to attach to this packet.
*/
template <typename T>
void addTag (T const &tag);
/**
* Remove a tag from this packet. The data stored internally
* for this tag is copied in the input tag if an instance
* of this tag type is present in the internal buffer. If this
* tag type is not present, the input tag is not modified.
*
* This operation can be potentially slow and might trigger
* unexpectedly large memory allocations. It is thus
* usually a better idea to create a copy of this packet,
* and invoke removeAllTags on the copy to remove all
* tags rather than remove the tags one by one from a packet.
*
* \param tag a pointer to the tag to remove from this packet
* \returns true if an instance of this tag type is stored
* in this packet, false otherwise.
*/
/**
* Remove a tag from this packet. The data stored internally
* for this tag is copied in the input tag if an instance
* of this tag type is present in the internal buffer. If this
* tag type is not present, the input tag is not modified.
*
* This operation can be potentially slow and might trigger
* unexpectedly large memory allocations. It is thus
* usually a better idea to create a copy of this packet,
* and invoke removeAllTags on the copy to remove all
* tags rather than remove the tags one by one from a packet.
*
* \param tag a pointer to the tag to remove from this packet
* \returns true if an instance of this tag type is stored
* in this packet, false otherwise.
*/
template <typename T>
bool removeTag (T &tag);
/**
* Copy a tag stored internally to the input tag. If no instance
* of this tag is present internally, the input tag is not modified.
*
* \param tag a pointer to the tag to read from this packet
* \returns true if an instance of this tag type is stored
* in this packet, false otherwise.
*/
/**
* Copy a tag stored internally to the input tag. If no instance
* of this tag is present internally, the input tag is not modified.
*
* \param tag a pointer to the tag to read from this packet
* \returns true if an instance of this tag type is stored
* in this packet, false otherwise.
*/
template <typename T>
bool peekTag (T &tag) const;
/**
* Remove all the tags stored in this packet. This operation is
* much much faster than invoking removeTag n times.
*/
/**
* Remove all the tags stored in this packet. This operation is
* much much faster than invoking removeTag n times.
*/
void removeAllTags (void);
/**
* Concatenate the input packet at the end of the current
* packet. This does not alter the uid of either packet.
*
* \param packet packet to concatenate
*/
/**
* Concatenate the input packet at the end of the current
* packet. This does not alter the uid of either packet.
*
* \param packet packet to concatenate
*/
void addAtEnd (Packet packet);
/**
* Concatenate the fragment of the input packet identified
* by the offset and size parameters at the end of the current
* packet. This does not alter the uid of either packet.
*
* \param packet to concatenate
* \param offset offset of fragment to copy from the start of the input packet
* \param size size of fragment of input packet to copy.
*/
/**
* Concatenate the fragment of the input packet identified
* by the offset and size parameters at the end of the current
* packet. This does not alter the uid of either packet.
*
* \param packet to concatenate
* \param offset offset of fragment to copy from the start of the input packet
* \param size size of fragment of input packet to copy.
*/
void addAtEnd (Packet packet, uint32_t offset, uint32_t size);
/**
* Remove size bytes from the end of the current packet
* It is safe to remove more bytes that what is present in
* the packet.
*
* \param size number of bytes from remove
*/
/**
* Remove size bytes from the end of the current packet
* It is safe to remove more bytes that what is present in
* the packet.
*
* \param size number of bytes from remove
*/
void removeAtEnd (uint32_t size);
/**
* Remove size bytes from the start of the current packet.
* It is safe to remove more bytes that what is present in
* the packet.
*
* \param size number of bytes from remove
*/
/**
* Remove size bytes from the start of the current packet.
* It is safe to remove more bytes that what is present in
* the packet.
*
* \param size number of bytes from remove
*/
void removeAtStart (uint32_t size);
/**
* If you try to change the content of the buffer
* returned by this method, you will die.
*
* \returns a pointer to the internal buffer of the packet.
*/
uint8_t const *peekData (void) const;
/**
* If you try to change the content of the buffer
* returned by this method, you will die.
*
* \returns a pointer to the internal buffer of the packet.
*/
uint8_t const *peekData (void) const;
/**
* A packet is allocated a new uid when it is created
* empty or with zero-filled payload.
*
* \returns an integer identifier which uniquely
* identifies this packet.
*/
uint32_t getUid (void) const;
/**
* A packet is allocated a new uid when it is created
* empty or with zero-filled payload.
*
* \returns an integer identifier which uniquely
* identifies this packet.
*/
uint32_t getUid (void) const;
private:
Packet (Buffer buffer, Tags tags, uint32_t uid);
Buffer m_buffer;
Tags m_tags;
uint32_t m_uid;
static uint32_t m_global_uid;
uint32_t m_uid;
static uint32_t m_global_uid;
};
}; // namespace ns3

View File

@@ -75,7 +75,7 @@ PcapWriter::writePacket (Packet const packet)
write_32 (us & 0xffffffff);
write_32 (packet.getSize ());
write_32 (packet.getSize ());
m_writer->write (packet.peekData (), packet.getSize ());
m_writer->write (packet.peekData (), packet.getSize ());
}
}

View File

@@ -52,8 +52,8 @@ public:
* Write a pcap header in the output file which specifies
* that the content of the file will Packets with
* Ethernet/LLC/SNAP encapsulation. This method should
* be invoked before ns3::PcapWriter::writePacket and after
* ns3::PcapWriter::open.
* be invoked before ns3::PcapWriter::writePacket and after
* ns3::PcapWriter::open.
*/
void writeHeaderEthernet (void);

View File

@@ -30,38 +30,38 @@ TagRegistry::TagsData TagRegistry::m_registry;
void
TagRegistry::record (std::string uuid, PrettyPrinter prettyPrinter)
{
assert (!m_sorted);
m_registry.push_back (make_pair (uuid, prettyPrinter));
assert (!m_sorted);
m_registry.push_back (make_pair (uuid, prettyPrinter));
}
uint32_t
TagRegistry::lookupUid (std::string uuid)
{
if (!m_sorted) {
std::sort (m_registry.begin (), m_registry.end ());
m_sorted = true;
}
assert (m_sorted);
uint32_t uid = 0;
for (TagsDataCI i = m_registry.begin (); i != m_registry.end (); i++) {
if (i->first == uuid) {
return uid;
}
uid++;
}
// someone asked for a uid for an unregistered uuid.
assert ("You tried to use unregistered tag: make sure you create an "
"instance of type TagRegistration<YouTagType>.");
// quiet compiler
return 0;
if (!m_sorted) {
std::sort (m_registry.begin (), m_registry.end ());
m_sorted = true;
}
assert (m_sorted);
uint32_t uid = 0;
for (TagsDataCI i = m_registry.begin (); i != m_registry.end (); i++) {
if (i->first == uuid) {
return uid;
}
uid++;
}
// someone asked for a uid for an unregistered uuid.
assert ("You tried to use unregistered tag: make sure you create an "
"instance of type TagRegistration<YouTagType>.");
// quiet compiler
return 0;
}
void
TagRegistry::prettyPrint (uint32_t uid, uint8_t buf[Tags::SIZE], std::ostream &os)
{
assert (m_registry.size () > uid);
PrettyPrinter prettyPrinter = m_registry[uid].second;
if (prettyPrinter != 0) {
prettyPrinter (buf, os);
}
assert (m_registry.size () > uid);
PrettyPrinter prettyPrinter = m_registry[uid].second;
if (prettyPrinter != 0) {
prettyPrinter (buf, os);
}
}

View File

@@ -91,12 +91,12 @@ private:
template <typename T>
class TagRegistration {
public:
/**
* \param uuid a uuid generated with uuidgen
* \param fn a function which can pretty-print an instance
* of type T in the output stream.
*/
TagRegistration<T> (std::string uuid, void(*fn) (T *, std::ostream &));
/**
* \param uuid a uuid generated with uuidgen
* \param fn a function which can pretty-print an instance
* of type T in the output stream.
*/
TagRegistration<T> (std::string uuid, void(*fn) (T *, std::ostream &));
private:
static void prettyPrinterCb (uint8_t *buf, std::ostream &os);
static void(*m_prettyPrinter) (T *, std::ostream &);
@@ -116,15 +116,15 @@ namespace ns3 {
class TagRegistry {
public:
typedef void (*PrettyPrinter) (uint8_t [Tags::SIZE], std::ostream &);
static void record (std::string uuid, PrettyPrinter prettyPrinter);
static uint32_t lookupUid (std::string uuid);
static void prettyPrint (uint32_t uid, uint8_t buf[Tags::SIZE], std::ostream &os);
typedef void (*PrettyPrinter) (uint8_t [Tags::SIZE], std::ostream &);
static void record (std::string uuid, PrettyPrinter prettyPrinter);
static uint32_t lookupUid (std::string uuid);
static void prettyPrint (uint32_t uid, uint8_t buf[Tags::SIZE], std::ostream &os);
private:
typedef std::vector<std::pair<std::string,PrettyPrinter> > TagsData;
typedef std::vector<std::pair<std::string,PrettyPrinter> >::const_iterator TagsDataCI;
static bool m_sorted;
static TagsData m_registry;
typedef std::vector<std::pair<std::string,PrettyPrinter> > TagsData;
typedef std::vector<std::pair<std::string,PrettyPrinter> >::const_iterator TagsDataCI;
static bool m_sorted;
static TagsData m_registry;
};
/**
* The TypeUid class is used to create a mapping Type --> uid
@@ -137,17 +137,17 @@ private:
template <typename T>
class TypeUid {
public:
static void record (std::string uuid);
static const uint32_t getUid (void);
static void record (std::string uuid);
static const uint32_t getUid (void);
private:
static std::string *getUuid (void);
T m_realType;
static std::string *getUuid (void);
T m_realType;
};
template <typename T>
void TypeUid<T>::record (std::string uuid)
{
*(getUuid ()) = uuid;
*(getUuid ()) = uuid;
}
template <typename T>
@@ -160,8 +160,8 @@ const uint32_t TypeUid<T>::getUid (void)
template <typename T>
std::string *TypeUid<T>::getUuid (void)
{
static std::string uuid;
return &uuid;
static std::string uuid;
return &uuid;
}
@@ -177,8 +177,8 @@ TagRegistration<T>::TagRegistration (std::string uuid, void (*prettyPrinter) (T
{
assert (sizeof (T) <= Tags::SIZE);
m_prettyPrinter = prettyPrinter;
TagRegistry::record (uuid, &TagRegistration<T>::prettyPrinterCb);
TypeUid<T>::record (uuid);
TagRegistry::record (uuid, &TagRegistration<T>::prettyPrinterCb);
TypeUid<T>::record (uuid);
}
template <typename T>
void

View File

@@ -35,7 +35,7 @@ Trailer::print (std::ostream &os) const
uint32_t
Trailer::getSize (void) const
{
return getSerializedSize ();
return getSerializedSize ();
}
void
Trailer::serialize (Buffer::Iterator start) const
@@ -51,7 +51,7 @@ Trailer::deserialize (Buffer::Iterator start)
bool
Trailer::isDeserialized (void) const
{
return m_isDeserialized;
return m_isDeserialized;
}

View File

@@ -48,10 +48,10 @@ public:
virtual ~Trailer () = 0;
void print (std::ostream &os) const;
uint32_t getSize (void) const;
uint32_t getSize (void) const;
void serialize (Buffer::Iterator start) const;
void deserialize (Buffer::Iterator start);
bool isDeserialized (void) const;
bool isDeserialized (void) const;
private:
bool m_isDeserialized;
/**
@@ -60,10 +60,10 @@ private:
*/
virtual void printTo (std::ostream &os) const = 0;
/**
* \returns the size of the serialized Trailer.
*/
virtual uint32_t getSerializedSize (void) const = 0;
/**
* \returns the size of the serialized Trailer.
*/
virtual uint32_t getSerializedSize (void) const = 0;
/**
* \param start the buffer iterator in which the protocol trailer

View File

@@ -35,38 +35,38 @@ class SystemFilePrivate;
*/
class SystemFile {
public:
/**
* This method does not create or open any
* file on disk.
*/
/**
* This method does not create or open any
* file on disk.
*/
SystemFile ();
/**
* If a file has been opened, it is closed by
* this destructor.
*/
/**
* If a file has been opened, it is closed by
* this destructor.
*/
~SystemFile ();
/**
* \param filename name of file to open
*
* Open a file for writing. If the file does not
* exist, it is created. If it exists, it is
* emptied first.
*/
/**
* \param filename name of file to open
*
* Open a file for writing. If the file does not
* exist, it is created. If it exists, it is
* emptied first.
*/
void open (char const *filename);
/**
* \param buffer data to write
* \param size size of data to write
*
* Write data in file on disk. This method cannot fail:
* it will write _all_ the data to disk. This method does not
* perform any data caching and forwards the data
* to the OS through a direct syscall. However,
* it is not possible to rely on the data being
* effectively written to disk after this method returns.
* To make sure the data is written to disk, destroy
* this object.
*/
/**
* \param buffer data to write
* \param size size of data to write
*
* Write data in file on disk. This method cannot fail:
* it will write _all_ the data to disk. This method does not
* perform any data caching and forwards the data
* to the OS through a direct syscall. However,
* it is not possible to rely on the data being
* effectively written to disk after this method returns.
* To make sure the data is written to disk, destroy
* this object.
*/
void write (uint8_t const*buffer, uint32_t size);
private:
SystemFilePrivate *m_priv;

View File

@@ -32,17 +32,17 @@ public:
SystemWallClockMs ();
~SystemWallClockMs ();
/**
* Start a measure.
*/
/**
* Start a measure.
*/
void start (void);
/**
* \returns the measured elapsed wall clock time since
* ns3::SystemWallClockMs::start was invoked.
*
* It is possible to start a new measurement with ns3::SystemWallClockMs::start
* after this method returns.
*/
/**
* \returns the measured elapsed wall clock time since
* ns3::SystemWallClockMs::start was invoked.
*
* It is possible to start a new measurement with ns3::SystemWallClockMs::start
* after this method returns.
*/
unsigned long long end (void);
private:
class SystemWallClockMsPrivate *m_priv;

View File

@@ -46,22 +46,22 @@ class TestManager;
*/
class Test {
public:
/**
* \param name the name of the test
*/
/**
* \param name the name of the test
*/
Test (char const *name);
virtual ~Test ();
/**
* \returns true if the test was successful, false otherwise.
*/
/**
* \returns true if the test was successful, false otherwise.
*/
virtual bool runTests (void) = 0;
protected:
/**
* \returns an output stream which base classes can write to
* to return extra information on test errors.
*/
/**
* \returns an output stream which base classes can write to
* to return extra information on test errors.
*/
std::ostream &failure (void);
};
@@ -70,20 +70,20 @@ protected:
*/
class TestManager {
public:
/**
* Enable verbose output. If you do not enable verbose output,
* nothing is printed on screen during the test runs.
*/
/**
* Enable verbose output. If you do not enable verbose output,
* nothing is printed on screen during the test runs.
*/
static void enableVerbose (void);
/**
* \returns true if all tests passed, false otherwise.
*
* run all registered regression tests
*/
/**
* \returns true if all tests passed, false otherwise.
*
* run all registered regression tests
*/
static bool runTests (void);
private:
friend class Test;
friend class Test;
static void add (Test *test, char const *name);
static std::ostream &failure (void);
static TestManager *get (void);

View File

@@ -34,16 +34,16 @@ class EventId {
public:
EventId ();
EventId (EventImpl *impl, uint64_t ns, uint32_t uid);
/**
* This method is syntactic sugar for the ns3::Simulator::cancel
* method.
*/
/**
* This method is syntactic sugar for the ns3::Simulator::cancel
* method.
*/
void cancel (void);
/**
* This method is syntactic sugar for the ns3::Simulator::isExpired
* method.
* \returns true if the event has expired, false otherwise.
*/
/**
* This method is syntactic sugar for the ns3::Simulator::isExpired
* method.
* \returns true if the event has expired, false otherwise.
*/
bool isExpired (void);
public:
/* The following methods are semi-private

View File

@@ -35,67 +35,67 @@ class Time {
public:
Time (Time const &o);
Time &operator = (Time const &o);
/**
* \returns the time stored in this
* instance as seconds.
*/
/**
* \returns the time stored in this
* instance as seconds.
*/
double s (void) const;
/**
* \returns the time stored in this
* instance as microseconds.
*/
/**
* \returns the time stored in this
* instance as microseconds.
*/
uint64_t us (void) const;
/**
* \returns the time stored in this
* instance as nanoseconds.
*/
/**
* \returns the time stored in this
* instance as nanoseconds.
*/
uint64_t ns (void) const;
/**
* \returns true if this instance represents
* the "destroy" time.
*/
/**
* \returns true if this instance represents
* the "destroy" time.
*/
bool isDestroy (void) const;
/**
* \param s absolute time in seconds
* \returns a constructed Time object
*/
/**
* \param s absolute time in seconds
* \returns a constructed Time object
*/
static Time absS (double s);
/**
* \param us absolute time in microseconds
* \returns a constructed Time object
*/
/**
* \param us absolute time in microseconds
* \returns a constructed Time object
*/
static Time absUs (uint64_t us);
/**
* \param ns absolute time in nanoseconds
* \returns a constructed Time object
*/
/**
* \param ns absolute time in nanoseconds
* \returns a constructed Time object
*/
static Time absNs (uint64_t ns);
/**
* \param s relative time in seconds
* \returns a constructed Time object
*/
/**
* \param s relative time in seconds
* \returns a constructed Time object
*/
static Time relS (double s);
/**
* \param us relative time in microseconds
* \returns a constructed Time object
*/
/**
* \param us relative time in microseconds
* \returns a constructed Time object
*/
static Time relUs (uint64_t us);
/**
* \param ns relative time in nanoseconds
* \returns a constructed Time object
*/
/**
* \param ns relative time in nanoseconds
* \returns a constructed Time object
*/
static Time relNs (uint64_t ns);
/**
* \returns a constructed Time object which represents
* the current simulation time
*/
/**
* \returns a constructed Time object which represents
* the current simulation time
*/
static Time now (void);
/**
* \returns a constructed Time object which represents
* the current "destroy" simulation time, that
* is, the time when Simulator::destroy is
* invoked by the user.
*/
/**
* \returns a constructed Time object which represents
* the current "destroy" simulation time, that
* is, the time when Simulator::destroy is
* invoked by the user.
*/
static Time destroy (void);
private:
Time (uint64_t ns);

View File

@@ -344,23 +344,23 @@ Simulator::schedule (Time const &time, EventImpl *ev)
EventId
Simulator::schedule (Time const &time, void (*f) (void))
{
// zero arg version
class EventFunctionImpl0 : public EventImpl {
public:
typedef void (*F)(void);
// zero arg version
class EventFunctionImpl0 : public EventImpl {
public:
typedef void (*F)(void);
EventFunctionImpl0 (F function)
: m_function (function)
{}
protected:
virtual void notify (void) {
(*m_function) ();
EventFunctionImpl0 (F function)
: m_function (function)
{}
protected:
virtual void notify (void) {
(*m_function) ();
}
private:
virtual ~EventFunctionImpl0 () {}
F m_function;
} *ev = new EventFunctionImpl0 (f);
return schedule (time, ev);
private:
virtual ~EventFunctionImpl0 () {}
F m_function;
} *ev = new EventFunctionImpl0 (f);
return schedule (time, ev);
}

View File

@@ -49,12 +49,12 @@ class SchedulerFactory;
*/
class Simulator {
public:
/**
* Enable ParallelSimulation.
* This method must be invoked before every other method exported
* by the Simulator class.
*/
static void enableParallelSimulation (void);
/**
* Enable ParallelSimulation.
* This method must be invoked before every other method exported
* by the Simulator class.
*/
static void enableParallelSimulation (void);
/**
* Force the use of an event scheduler based on a linked-list.
* This method must be invoked before any other method exported
@@ -152,12 +152,12 @@ public:
/**
* Schedule an event to expire when time is reached.
* When the event expires, the input method will be invoked
* on the input object.
* When the event expires, the input method will be invoked
* on the input object.
*
* @param time the expiration time of the event.
* @param mem_ptr member method pointer to invoke
* @param obj the object on which to invoke the member method
* @param obj the object on which to invoke the member method
* @returns an id for the scheduled event.
*/
template <typename T>
@@ -165,8 +165,8 @@ public:
/**
* @param time the expiration time of the event.
* @param mem_ptr member method pointer to invoke
* @param obj the object on which to invoke the member method
* @param a1 the first argument to pass to the invoked method
* @param obj the object on which to invoke the member method
* @param a1 the first argument to pass to the invoked method
* @returns an id for the scheduled event.
*/
template <typename T, typename T1>
@@ -174,9 +174,9 @@ public:
/**
* @param time the expiration time of the event.
* @param mem_ptr member method pointer to invoke
* @param obj the object on which to invoke the member method
* @param a1 the first argument to pass to the invoked method
* @param a2 the second argument to pass to the invoked method
* @param obj the object on which to invoke the member method
* @param a1 the first argument to pass to the invoked method
* @param a2 the second argument to pass to the invoked method
* @returns an id for the scheduled event.
*/
template <typename T, typename T1, typename T2>
@@ -184,10 +184,10 @@ public:
/**
* @param time the expiration time of the event.
* @param mem_ptr member method pointer to invoke
* @param obj the object on which to invoke the member method
* @param a1 the first argument to pass to the invoked method
* @param a2 the second argument to pass to the invoked method
* @param a3 the third argument to pass to the invoked method
* @param obj the object on which to invoke the member method
* @param a1 the first argument to pass to the invoked method
* @param a2 the second argument to pass to the invoked method
* @param a3 the third argument to pass to the invoked method
* @returns an id for the scheduled event.
*/
template <typename T, typename T1, typename T2, typename T3>
@@ -195,11 +195,11 @@ public:
/**
* @param time the expiration time of the event.
* @param mem_ptr member method pointer to invoke
* @param obj the object on which to invoke the member method
* @param a1 the first argument to pass to the invoked method
* @param a2 the second argument to pass to the invoked method
* @param a3 the third argument to pass to the invoked method
* @param a4 the fourth argument to pass to the invoked method
* @param obj the object on which to invoke the member method
* @param a1 the first argument to pass to the invoked method
* @param a2 the second argument to pass to the invoked method
* @param a3 the third argument to pass to the invoked method
* @param a4 the fourth argument to pass to the invoked method
* @returns an id for the scheduled event.
*/
template <typename T, typename T1, typename T2, typename T3, typename T4>
@@ -207,18 +207,18 @@ public:
/**
* @param time the expiration time of the event.
* @param mem_ptr member method pointer to invoke
* @param obj the object on which to invoke the member method
* @param a1 the first argument to pass to the invoked method
* @param a2 the second argument to pass to the invoked method
* @param a3 the third argument to pass to the invoked method
* @param a4 the fourth argument to pass to the invoked method
* @param a5 the fifth argument to pass to the invoked method
* @param obj the object on which to invoke the member method
* @param a1 the first argument to pass to the invoked method
* @param a2 the second argument to pass to the invoked method
* @param a3 the third argument to pass to the invoked method
* @param a4 the fourth argument to pass to the invoked method
* @param a5 the fifth argument to pass to the invoked method
* @returns an id for the scheduled event.
*/
template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5>
static EventId schedule (Time const &time, void (T::*mem_ptr) (T1,T2,T3,T4,T5), T* obj,
T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
/**
T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
/**
* @param time the expiration time of the event.
* @param f the function to invoke
* @returns an id for the scheduled event.
@@ -227,7 +227,7 @@ public:
/**
* @param time the expiration time of the event.
* @param f the function to invoke
* @param a1 the first argument to pass to the function to invoke
* @param a1 the first argument to pass to the function to invoke
* @returns an id for the scheduled event.
*/
template <typename T1>
@@ -235,8 +235,8 @@ public:
/**
* @param time the expiration time of the event.
* @param f the function to invoke
* @param a1 the first argument to pass to the function to invoke
* @param a2 the second argument to pass to the function to invoke
* @param a1 the first argument to pass to the function to invoke
* @param a2 the second argument to pass to the function to invoke
* @returns an id for the scheduled event.
*/
template <typename T1, typename T2>
@@ -244,9 +244,9 @@ public:
/**
* @param time the expiration time of the event.
* @param f the function to invoke
* @param a1 the first argument to pass to the function to invoke
* @param a2 the second argument to pass to the function to invoke
* @param a3 the third argument to pass to the function to invoke
* @param a1 the first argument to pass to the function to invoke
* @param a2 the second argument to pass to the function to invoke
* @param a3 the third argument to pass to the function to invoke
* @returns an id for the scheduled event.
*/
template <typename T1, typename T2, typename T3>
@@ -254,10 +254,10 @@ public:
/**
* @param time the expiration time of the event.
* @param f the function to invoke
* @param a1 the first argument to pass to the function to invoke
* @param a2 the second argument to pass to the function to invoke
* @param a3 the third argument to pass to the function to invoke
* @param a4 the fourth argument to pass to the function to invoke
* @param a1 the first argument to pass to the function to invoke
* @param a2 the second argument to pass to the function to invoke
* @param a3 the third argument to pass to the function to invoke
* @param a4 the fourth argument to pass to the function to invoke
* @returns an id for the scheduled event.
*/
template <typename T1, typename T2, typename T3, typename T4>
@@ -265,48 +265,48 @@ public:
/**
* @param time the expiration time of the event.
* @param f the function to invoke
* @param a1 the first argument to pass to the function to invoke
* @param a2 the second argument to pass to the function to invoke
* @param a3 the third argument to pass to the function to invoke
* @param a4 the fourth argument to pass to the function to invoke
* @param a5 the fifth argument to pass to the function to invoke
* @param a1 the first argument to pass to the function to invoke
* @param a2 the second argument to pass to the function to invoke
* @param a3 the third argument to pass to the function to invoke
* @param a4 the fourth argument to pass to the function to invoke
* @param a5 the fifth argument to pass to the function to invoke
* @returns an id for the scheduled event.
*/
template <typename T1, typename T2, typename T3, typename T4, typename T5>
static EventId schedule (Time const &time, void (*f) (T1,T2,T3,T4,T5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
/**
* Remove an event from the event list.
* This method has the same visible effect as the
* ns3::Simulator::cancel method or 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).
*
* This method has the same visible effect as the
* ns3::Simulator::cancel method or 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 id the event to remove from the list of scheduled events.
*/
static void remove (EventId id);
/**
* 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 id the event to cancel
* 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 id the event to cancel
*/
static void cancel (EventId id);
/**
* 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).
*
* @param id the event to test for expiration
* @returns true if the event has expired, false otherwise.
* 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).
*
* @param id the event to test for expiration
* @returns true if the event has expired, false otherwise.
*/
static bool isExpired (EventId id);
/**
@@ -340,315 +340,315 @@ namespace ns3 {
template <typename T>
EventId Simulator::schedule (Time const &time, void (T::*mem_ptr) (void), T *obj)
{
// zero argument version
class EventMemberImpl0 : public EventImpl {
public:
typedef void (T::*F)(void);
EventMemberImpl0 (T *obj, F function)
: m_obj (obj),
m_function (function)
{}
virtual ~EventMemberImpl0 () {}
private:
virtual void notify (void) {
(m_obj->*m_function) ();
}
T* m_obj;
F m_function;
} *ev = new EventMemberImpl0 (obj, mem_ptr);
return schedule (time, ev);
// zero argument version
class EventMemberImpl0 : public EventImpl {
public:
typedef void (T::*F)(void);
EventMemberImpl0 (T *obj, F function)
: m_obj (obj),
m_function (function)
{}
virtual ~EventMemberImpl0 () {}
private:
virtual void notify (void) {
(m_obj->*m_function) ();
}
T* m_obj;
F m_function;
} *ev = new EventMemberImpl0 (obj, mem_ptr);
return schedule (time, ev);
}
template <typename T, typename T1>
EventId Simulator::schedule (Time const &time, void (T::*mem_ptr) (T1), T* obj, T1 a1)
{
// one argument version
class EventMemberImpl1 : public EventImpl {
public:
typedef void (T::*F)(T1);
EventMemberImpl1 (T *obj, F function, T1 a1)
: m_obj (obj),
m_function (function),
m_a1 (a1)
{}
protected:
virtual ~EventMemberImpl1 () {}
private:
virtual void notify (void) {
(m_obj->*m_function) (m_a1);
}
T* m_obj;
F m_function;
T1 m_a1;
} *ev = new EventMemberImpl1 (obj, mem_ptr, a1);
return schedule (time, ev);
// one argument version
class EventMemberImpl1 : public EventImpl {
public:
typedef void (T::*F)(T1);
EventMemberImpl1 (T *obj, F function, T1 a1)
: m_obj (obj),
m_function (function),
m_a1 (a1)
{}
protected:
virtual ~EventMemberImpl1 () {}
private:
virtual void notify (void) {
(m_obj->*m_function) (m_a1);
}
T* m_obj;
F m_function;
T1 m_a1;
} *ev = new EventMemberImpl1 (obj, mem_ptr, a1);
return schedule (time, ev);
}
template <typename T, typename T1, typename T2>
EventId Simulator::schedule (Time const &time, void (T::*mem_ptr) (T1,T2), T* obj, T1 a1, T2 a2)
{
// two argument version
class EventMemberImpl2 : public EventImpl {
public:
typedef void (T::*F)(T1, T2);
// two argument version
class EventMemberImpl2 : public EventImpl {
public:
typedef void (T::*F)(T1, T2);
EventMemberImpl2 (T *obj, F function, T1 a1, T2 a2)
: m_obj (obj),
m_function (function),
m_a1 (a1),
m_a2 (a2)
{ }
protected:
virtual ~EventMemberImpl2 () {}
private:
virtual void notify (void) {
(m_obj->*m_function) (m_a1, m_a2);
}
T* m_obj;
F m_function;
T1 m_a1;
T2 m_a2;
} *ev = new EventMemberImpl2 (obj, mem_ptr, a1, a2);
EventMemberImpl2 (T *obj, F function, T1 a1, T2 a2)
: m_obj (obj),
m_function (function),
m_a1 (a1),
m_a2 (a2)
{ }
protected:
virtual ~EventMemberImpl2 () {}
private:
virtual void notify (void) {
(m_obj->*m_function) (m_a1, m_a2);
}
T* m_obj;
F m_function;
T1 m_a1;
T2 m_a2;
} *ev = new EventMemberImpl2 (obj, mem_ptr, a1, a2);
return schedule (time, ev);
return schedule (time, ev);
}
template <typename T, typename T1, typename T2, typename T3>
EventId Simulator::schedule (Time const &time, void (T::*mem_ptr) (T1,T2,T3), T* obj, T1 a1, T2 a2, T3 a3)
{
// three argument version
class EventMemberImpl3 : public EventImpl {
public:
typedef void (T::*F)(T1, T2, T3);
// three argument version
class EventMemberImpl3 : public EventImpl {
public:
typedef void (T::*F)(T1, T2, T3);
EventMemberImpl3 (T *obj, F function, T1 a1, T2 a2, T3 a3)
: m_obj (obj),
m_function (function),
m_a1 (a1),
m_a2 (a2),
m_a3 (a3)
{ }
protected:
virtual ~EventMemberImpl3 () {}
private:
virtual void notify (void) {
(m_obj->*m_function) (m_a1, m_a2, m_a3);
}
T* m_obj;
F m_function;
T1 m_a1;
T2 m_a2;
T3 m_a3;
} *ev = new EventMemberImpl3 (obj, mem_ptr, a1, a2, a3);
return schedule (time, ev);
EventMemberImpl3 (T *obj, F function, T1 a1, T2 a2, T3 a3)
: m_obj (obj),
m_function (function),
m_a1 (a1),
m_a2 (a2),
m_a3 (a3)
{ }
protected:
virtual ~EventMemberImpl3 () {}
private:
virtual void notify (void) {
(m_obj->*m_function) (m_a1, m_a2, m_a3);
}
T* m_obj;
F m_function;
T1 m_a1;
T2 m_a2;
T3 m_a3;
} *ev = new EventMemberImpl3 (obj, mem_ptr, a1, a2, a3);
return schedule (time, ev);
}
template <typename T, typename T1, typename T2, typename T3, typename T4>
EventId Simulator::schedule (Time const &time, void (T::*mem_ptr) (T1,T2,T3,T4), T* obj, T1 a1, T2 a2, T3 a3, T4 a4)
{
// four argument version
class EventMemberImpl4 : public EventImpl {
public:
typedef void (T::*F)(T1, T2, T3, T4);
// four argument version
class EventMemberImpl4 : public EventImpl {
public:
typedef void (T::*F)(T1, T2, T3, T4);
EventMemberImpl4 (T *obj, F function, T1 a1, T2 a2, T3 a3, T4 a4)
: m_obj (obj),
m_function (function),
m_a1 (a1),
m_a2 (a2),
m_a3 (a3),
m_a4 (a4)
{ }
protected:
virtual ~EventMemberImpl4 () {}
private:
virtual void notify (void) {
(m_obj->*m_function) (m_a1, m_a2, m_a3, m_a4);
}
T* m_obj;
F m_function;
T1 m_a1;
T2 m_a2;
T3 m_a3;
T4 m_a4;
} *ev = new EventMemberImpl4 (obj, mem_ptr, a1, a2, a3, a4);
return schedule (time, ev);
EventMemberImpl4 (T *obj, F function, T1 a1, T2 a2, T3 a3, T4 a4)
: m_obj (obj),
m_function (function),
m_a1 (a1),
m_a2 (a2),
m_a3 (a3),
m_a4 (a4)
{ }
protected:
virtual ~EventMemberImpl4 () {}
private:
virtual void notify (void) {
(m_obj->*m_function) (m_a1, m_a2, m_a3, m_a4);
}
T* m_obj;
F m_function;
T1 m_a1;
T2 m_a2;
T3 m_a3;
T4 m_a4;
} *ev = new EventMemberImpl4 (obj, mem_ptr, a1, a2, a3, a4);
return schedule (time, ev);
}
template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5>
EventId Simulator::schedule (Time const &time, void (T::*mem_ptr) (T1,T2,T3,T4,T5), T* obj,
T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
{
// five argument version
class EventMemberImpl5 : public EventImpl {
public:
typedef void (T::*F)(T1, T2, T3, T4, T5);
// five argument version
class EventMemberImpl5 : public EventImpl {
public:
typedef void (T::*F)(T1, T2, T3, T4, T5);
EventMemberImpl5 (T *obj, F function, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
: m_obj (obj),
m_function (function),
m_a1 (a1),
m_a2 (a2),
m_a3 (a3),
m_a4 (a4),
m_a5 (a5)
{ }
protected:
virtual ~EventMemberImpl5 () {}
private:
virtual void notify (void) {
(m_obj->*m_function) (m_a1, m_a2, m_a3, m_a4, m_a5);
}
T* m_obj;
F m_function;
T1 m_a1;
T2 m_a2;
T3 m_a3;
T4 m_a4;
T5 m_a5;
} *ev = new EventMemberImpl5 (obj, mem_ptr, a1, a2, a3, a4, a5);
return schedule (time, ev);
EventMemberImpl5 (T *obj, F function, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
: m_obj (obj),
m_function (function),
m_a1 (a1),
m_a2 (a2),
m_a3 (a3),
m_a4 (a4),
m_a5 (a5)
{ }
protected:
virtual ~EventMemberImpl5 () {}
private:
virtual void notify (void) {
(m_obj->*m_function) (m_a1, m_a2, m_a3, m_a4, m_a5);
}
T* m_obj;
F m_function;
T1 m_a1;
T2 m_a2;
T3 m_a3;
T4 m_a4;
T5 m_a5;
} *ev = new EventMemberImpl5 (obj, mem_ptr, a1, a2, a3, a4, a5);
return schedule (time, ev);
}
template <typename T1>
EventId Simulator::schedule (Time const &time, void (*f) (T1), T1 a1)
{
// one arg version
class EventFunctionImpl1 : public EventImpl {
public:
typedef void (*F)(T1);
// one arg version
class EventFunctionImpl1 : public EventImpl {
public:
typedef void (*F)(T1);
EventFunctionImpl1 (F function, T1 a1)
: m_function (function),
m_a1 (a1)
{ }
protected:
virtual ~EventFunctionImpl1 () {}
private:
virtual void notify (void) {
(*m_function) (m_a1);
}
F m_function;
T1 m_a1;
} *ev = new EventFunctionImpl1(f, a1);
return schedule (time, ev);
EventFunctionImpl1 (F function, T1 a1)
: m_function (function),
m_a1 (a1)
{ }
protected:
virtual ~EventFunctionImpl1 () {}
private:
virtual void notify (void) {
(*m_function) (m_a1);
}
F m_function;
T1 m_a1;
} *ev = new EventFunctionImpl1(f, a1);
return schedule (time, ev);
}
template <typename T1, typename T2>
EventId Simulator::schedule (Time const &time, void (*f) (T1,T2), T1 a1, T2 a2)
{
// two arg version
class EventFunctionImpl2 : public EventImpl {
public:
typedef void (*F)(T1, T2);
// two arg version
class EventFunctionImpl2 : public EventImpl {
public:
typedef void (*F)(T1, T2);
EventFunctionImpl2 (F function, T1 a1, T2 a2)
: m_function (function),
m_a1 (a1),
m_a2 (a2)
{ }
protected:
virtual ~EventFunctionImpl2 () {}
private:
virtual void notify (void) {
(*m_function) (m_a1, m_a2);
}
F m_function;
T1 m_a1;
T2 m_a2;
} *ev = new EventFunctionImpl2 (f, a1, a2);
return schedule (time, ev);
EventFunctionImpl2 (F function, T1 a1, T2 a2)
: m_function (function),
m_a1 (a1),
m_a2 (a2)
{ }
protected:
virtual ~EventFunctionImpl2 () {}
private:
virtual void notify (void) {
(*m_function) (m_a1, m_a2);
}
F m_function;
T1 m_a1;
T2 m_a2;
} *ev = new EventFunctionImpl2 (f, a1, a2);
return schedule (time, ev);
}
template <typename T1, typename T2, typename T3>
EventId Simulator::schedule (Time const &time, void (*f) (T1,T2,T3), T1 a1, T2 a2, T3 a3)
{
// three arg version
class EventFunctionImpl3 : public EventImpl {
public:
typedef void (*F)(T1, T2, T3);
// three arg version
class EventFunctionImpl3 : public EventImpl {
public:
typedef void (*F)(T1, T2, T3);
EventFunctionImpl3 (F function, T1 a1, T2 a2, T3 a3)
: m_function (function),
m_a1 (a1),
m_a2 (a2),
m_a3 (a3)
{ }
protected:
virtual ~EventFunctionImpl3 () {}
private:
virtual void notify (void) {
(*m_function) (m_a1, m_a2, m_a3);
}
F m_function;
T1 m_a1;
T2 m_a2;
T3 m_a3;
} *ev = new EventFunctionImpl3 (f, a1, a2, a3);
return schedule (time, ev);
EventFunctionImpl3 (F function, T1 a1, T2 a2, T3 a3)
: m_function (function),
m_a1 (a1),
m_a2 (a2),
m_a3 (a3)
{ }
protected:
virtual ~EventFunctionImpl3 () {}
private:
virtual void notify (void) {
(*m_function) (m_a1, m_a2, m_a3);
}
F m_function;
T1 m_a1;
T2 m_a2;
T3 m_a3;
} *ev = new EventFunctionImpl3 (f, a1, a2, a3);
return schedule (time, ev);
}
template <typename T1, typename T2, typename T3, typename T4>
EventId Simulator::schedule (Time const &time, void (*f) (T1,T2,T3,T4), T1 a1, T2 a2, T3 a3, T4 a4)
{
// four arg version
class EventFunctionImpl4 : public EventImpl {
public:
typedef void (*F)(T1, T2, T3, T4);
// four arg version
class EventFunctionImpl4 : public EventImpl {
public:
typedef void (*F)(T1, T2, T3, T4);
EventFunctionImpl4 (F function, T1 a1, T2 a2, T3 a3, T4 a4)
: m_function (function),
m_a1 (a1),
m_a2 (a2),
m_a3 (a3),
m_a4 (a4)
{ }
protected:
virtual ~EventFunctionImpl4 () {}
private:
virtual void notify (void) {
(*m_function) (m_a1, m_a2, m_a3, m_a4);
}
F m_function;
T1 m_a1;
T2 m_a2;
T3 m_a3;
T4 m_a4;
} *ev = new EventFunctionImpl4 (f, a1, a2, a3, a4);
return schedule (time, ev);
EventFunctionImpl4 (F function, T1 a1, T2 a2, T3 a3, T4 a4)
: m_function (function),
m_a1 (a1),
m_a2 (a2),
m_a3 (a3),
m_a4 (a4)
{ }
protected:
virtual ~EventFunctionImpl4 () {}
private:
virtual void notify (void) {
(*m_function) (m_a1, m_a2, m_a3, m_a4);
}
F m_function;
T1 m_a1;
T2 m_a2;
T3 m_a3;
T4 m_a4;
} *ev = new EventFunctionImpl4 (f, a1, a2, a3, a4);
return schedule (time, ev);
}
template <typename T1, typename T2, typename T3, typename T4, typename T5>
static EventId schedule (Time const &time, void (*f) (T1,T2,T3,T4,T5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
{
// five arg version
class EventFunctionImpl5 : public EventImpl {
public:
typedef void (*F)(T1, T2, T3, T4, T5);
// five arg version
class EventFunctionImpl5 : public EventImpl {
public:
typedef void (*F)(T1, T2, T3, T4, T5);
EventFunctionImpl5 (F function, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
: m_function (function),
m_a1 (a1),
m_a2 (a2),
m_a3 (a3),
m_a4 (a4),
m_a5 (a5)
{ }
protected:
virtual ~EventFunctionImpl5 () {}
private:
virtual void notify (void) {
(*m_function) (m_a1, m_a2, m_a3, m_a4, m_a5);
}
F m_function;
T1 m_a1;
T2 m_a2;
T3 m_a3;
T4 m_a4;
T5 m_a5;
} *ev = new EventFunctionImpl5 (f, a1, a2, a3, a4, a5);
return schedule (time, ev);
EventFunctionImpl5 (F function, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
: m_function (function),
m_a1 (a1),
m_a2 (a2),
m_a3 (a3),
m_a4 (a4),
m_a5 (a5)
{ }
protected:
virtual ~EventFunctionImpl5 () {}
private:
virtual void notify (void) {
(*m_function) (m_a1, m_a2, m_a3, m_a4, m_a5);
}
F m_function;
T1 m_a1;
T2 m_a2;
T3 m_a3;
T4 m_a4;
T5 m_a5;
} *ev = new EventFunctionImpl5 (f, a1, a2, a3, a4, a5);
return schedule (time, ev);
}
}; // namespace ns3