samples/main-simulator.cc
author Florian Westphal <fw@strlen.de>
Wed, 03 Sep 2008 23:24:59 +0200
changeset 3595 693faf7f4e9b
parent 163 2a7e05018eeb
child 4309 bf8c338c7820
permissions -rw-r--r--
nsc: Fix build problem if gtk config store is disabled gtk config store pulled in libdl.so for us, so things fail to link of the config store isn't enabled. This makes nsc pull in libdl itself when its enabled.

/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
#include "ns3/simulator.h"
#include "ns3/nstime.h"
#include <iostream>

using namespace ns3;

class MyModel {
public:
  void Start (void);
private:
  void DealWithEvent (double eventValue);
};

void 
MyModel::Start (void)
{
  Simulator::Schedule (Seconds (10.0), 
                       &MyModel::DealWithEvent, 
                       this, Simulator::Now ().GetSeconds ());
}
void
MyModel::DealWithEvent (double value)
{
  std::cout << "Member method received event at " << Simulator::Now ().GetSeconds () 
            << "s started at " << value << "s" << std::endl;
}

static void 
random_function (MyModel *model)
{
  std::cout << "random function received event at " << 
      Simulator::Now ().GetSeconds () << "s" << std::endl;
  model->Start ();
}


int main (int argc, char *argv[])
{
  MyModel model;

  Simulator::Schedule (Seconds (10.0), &random_function, &model);

  Simulator::Run ();

  Simulator::Destroy ();
}