blob: 00119e5f99198a6d229ec9c1343411291ab3fff5 [file] [log] [blame]
Spyridon Mastorakis95be5092015-08-26 15:07:37 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
4 *
5 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
7 *
8 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
19
20#ifndef NDNSIM_EXAMPLES_NDN_CXX_SIMPLE_REAL_APP_STARTER_HPP
21#define NDNSIM_EXAMPLES_NDN_CXX_SIMPLE_REAL_APP_STARTER_HPP
22
23#include "real-app.hpp"
24
25#include "ns3/ndnSIM/helper/ndn-stack-helper.hpp"
26#include "ns3/application.h"
27
28namespace ns3 {
29
30// Class inheriting from ns3::Application
31class RealAppStarter : public Application
32{
33public:
34 static TypeId
35 GetTypeId()
36 {
37 static TypeId tid = TypeId("RealAppStarter")
38 .SetParent<Application>()
39 .AddConstructor<RealAppStarter>();
40
41 return tid;
42 }
43
44protected:
45 // inherited from Application base class.
46 virtual void
47 StartApplication()
48 {
49 // Create an instance of the app, and passing the dummy version of KeyChain (no real signing)
50 m_instance.reset(new app::RealApp(ndn::StackHelper::getKeyChain()));
51 m_instance->run(); // can be omitted
52 }
53
54 virtual void
55 StopApplication()
56 {
57 // Stop and destroy the instance of the app
58 m_instance.reset();
59 }
60
61private:
62 std::unique_ptr<app::RealApp> m_instance;
63};
64
65} // namespace ns3
66
67#endif // NDNSIM_EXAMPLES_NDN_CXX_SIMPLE_REAL_APP_STARTER_HPP