A Discrete-Event Network Simulator
API
sensornode-helper.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 
3 
4 /*
5 * Copyright (c) 2020 DLTLT
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation;
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * Corresponding author: Niki Hrovatin <niki.hrovatin@famnit.upr.si>
21 */
22 
23 
24 #include "sensornode-helper.h"
25 
26 namespace ns3 {
27 
28 //Zagotovi, da se registrira TypeId
29 NS_OBJECT_ENSURE_REGISTERED (SensorNodeHelper);
30 
31 TypeId
33 {
34  static TypeId tid =
35  TypeId ("ns3::SensorNodeHelper").SetParent<Object> ().AddConstructor<SensorNodeHelper> ();
36  return tid;
37 }
38 
40 {
41  m_factory.SetTypeId ("ns3::SensorNode");
42 }
43 
44 SensorNodeHelper::SensorNodeHelper (Ipv4Address address, Ptr<OutputManager> outputManager,
45  Ptr<OnionValidator> onionValidator)
46  : m_outputManager (outputManager), m_onionValidator (onionValidator)
47 {
48  m_factory.SetTypeId ("ns3::SensorNode");
49  m_factory.Set ("SinkNodeAddress", Ipv4AddressValue (address));
50  m_factory.Set ("OutputManager", PointerValue (m_outputManager));
51  m_factory.Set ("OnionValidator", PointerValue (m_onionValidator));
52 }
53 
55 {
56 }
57 
58 void
59 SensorNodeHelper::SetAttribute (std::string name, const AttributeValue &value)
60 {
61  m_factory.Set (name, value);
62 }
63 
64 ApplicationContainer
65 SensorNodeHelper::Install (NodeContainer c) const
66 {
67  ApplicationContainer apps;
68  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
69  {
70  apps.Add (InstallPriv (*i));
71  }
72 
73  return apps;
74 }
75 
76 Ptr<Application>
77 SensorNodeHelper::InstallPriv (Ptr<Node> node) const
78 {
79  Ptr<Application> app = m_factory.Create<Application> ();
80 
81  node->AddApplication (app);
82 
83  return app;
84 }
85 
86 } // namespace ns3
sensornode-helper.h
ns3::SensorNodeHelper::SensorNodeHelper
SensorNodeHelper()
Default constructor.
Definition: sensornode-helper.cc:39
ns3
Definition: sensornode-helper.cc:26
ns3::SensorNodeHelper
Helper class for the creation of SensorNode applications.
Definition: sensornode-helper.h:56
ns3::SensorNodeHelper::m_onionValidator
Ptr< OnionValidator > m_onionValidator
Manage onions and when to abort them.
Definition: sensornode-helper.h:113
ns3::SensorNodeHelper::Install
ApplicationContainer Install(NodeContainer c) const
Definition: sensornode-helper.cc:65
ns3::SensorNodeHelper::m_outputManager
Ptr< OutputManager > m_outputManager
Manage the output of the simulation.
Definition: sensornode-helper.h:112
ns3::SensorNodeHelper::~SensorNodeHelper
~SensorNodeHelper()
Default constructor.
Definition: sensornode-helper.cc:54
ns3::SensorNodeHelper::InstallPriv
Ptr< Application > InstallPriv(Ptr< Node > node) const
Definition: sensornode-helper.cc:77
ns3::SensorNodeHelper::GetTypeId
static TypeId GetTypeId(void)
Register this type.
Definition: sensornode-helper.cc:32
ns3::SensorNodeHelper::m_factory
ObjectFactory m_factory
factory object
Definition: sensornode-helper.h:116
ns3::SensorNodeHelper::SetAttribute
void SetAttribute(std::string name, const AttributeValue &value)
Setter of individual attributes.
Definition: sensornode-helper.cc:59