blob: 1d7e74db6e479d9743235232125fb30d79f087e7 [file] [log] [blame]
Alexander Afanasyeve4795ae2013-07-11 20:01:31 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013, Regents of the University of California
4 * Alexander Afanasyev
5 * Zhenkai Zhu
6 *
7 * GNU v3.0 license, See the LICENSE file for more information
8 *
9 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
10 */
11
12#ifndef NDN_CALLBACK_BASED_APP_H
13#define NDN_CALLBACK_BASED_APP_H
14
15#include "ns3/application.h"
16#include "ns3/ptr.h"
17#include "ns3/callback.h"
18
19namespace ns3 {
20
21/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070022 * @ingroup ndn-apps
Alexander Afanasyeve4795ae2013-07-11 20:01:31 -070023 * @brief A meta application that can be used to create custom apps within Python bindings
24 */
25class CallbackBasedApp: public Application
26{
27public:
28 static TypeId GetTypeId ();
29
30 /**
31 * @brief Default constructor
32 */
33 CallbackBasedApp ();
34
35 /**
36 * @brief Virtual destructor
37 */
38 virtual
39 ~CallbackBasedApp ();
40
41 /**
42 * @brief Define callback that will be fired when application need to start its work
43 */
44 void
45 SetOnStartCallback (Callback< void, Ptr<Application> > onStart);
46
47 /**
48 * @brief Define callback that will be fired when application need to stop its work
49 */
50 void
51 SetOnStopCallback (Callback< void, Ptr<Application> > onStart);
52
53protected:
54 // inherited from Application base class. Originally they were private
55 virtual void
56 StartApplication (); ///< @brief Called at time specified by Start
57
58 virtual void
59 StopApplication (); ///< @brief Called at time specified by Stop
60
61private:
62 Callback< void, Ptr<Application> > m_onStart;
63 Callback< void, Ptr<Application> > m_onStop;
64};
65
66} // ns3
67
68#endif // NDN_CALLBACK_BASED_APP_H