A Discrete-Event Network Simulator
API
make-event.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  */
19 
20 #include "make-event.h"
21 #include "log.h"
22 
29 namespace ns3 {
30 
31 NS_LOG_COMPONENT_DEFINE ("MakeEvent");
32 
33 // This is the only non-templated version of MakeEvent.
34 EventImpl * MakeEvent (void (*f)(void))
35 {
37  // zero arg version
38  class EventFunctionImpl0 : public EventImpl
39  {
40 public:
41  typedef void (*F)(void);
42 
43  EventFunctionImpl0 (F function)
44  : m_function (function)
45  {
46  }
47  virtual ~EventFunctionImpl0 ()
48  {
49  }
50 protected:
51  virtual void Notify (void)
52  {
53  (*m_function)();
54  }
55 private:
56  F m_function;
57  } *ev = new EventFunctionImpl0 (f);
58  return ev;
59 }
60 
61 } // namespace ns3
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
ns3::MakeEvent function declarations and template implementation.
double f(double x, void *params)
Definition: 80211b.c:70
Every class exported by the ns3 library is enclosed in the ns3 namespace.
A simulation event.
Definition: event-impl.h:44
Debug message logging.
EventImpl * MakeEvent(void(*f)(void))
Make an EventImpl from a function pointer taking varying numbers of arguments.
Definition: make-event.cc:34