Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Ilya Moiseenko | 9b273ce | 2011-08-05 20:24:12 -0700 | [diff] [blame] | 2 | // |
| 3 | // ndn_stupidinterestgenerator_helper.cpp |
| 4 | // Abstraction |
| 5 | // |
| 6 | // Created by Ilya Moiseenko on 05.08.11. |
| 7 | // Copyright 2011 UCLA. All rights reserved. |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame^] | 8 | //w |
Ilya Moiseenko | 9b273ce | 2011-08-05 20:24:12 -0700 | [diff] [blame] | 9 | |
| 10 | #include "ndn_stupidinterestgenerator_helper.h" |
| 11 | #include "ns3/inet-socket-address.h" |
| 12 | #include "ns3/packet-socket-address.h" |
| 13 | #include "ns3/string.h" |
| 14 | #include "ns3/names.h" |
| 15 | |
| 16 | |
| 17 | namespace ns3 { |
| 18 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 19 | StupidInterestGeneratorHelper::StupidInterestGeneratorHelper (std::string protocol, Address address) |
| 20 | { |
| 21 | m_factory.SetTypeId ("ns3::StupidInterestGenerator"); |
| 22 | m_factory.Set ("Protocol", StringValue (protocol)); |
| 23 | m_factory.Set ("Remote", AddressValue (address)); |
| 24 | } |
Ilya Moiseenko | 9b273ce | 2011-08-05 20:24:12 -0700 | [diff] [blame] | 25 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 26 | void |
| 27 | StupidInterestGeneratorHelper::SetAttribute (std::string name, const AttributeValue &value) |
| 28 | { |
| 29 | m_factory.Set (name, value); |
| 30 | } |
Ilya Moiseenko | 9b273ce | 2011-08-05 20:24:12 -0700 | [diff] [blame] | 31 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 32 | ApplicationContainer |
| 33 | StupidInterestGeneratorHelper::Install (Ptr<Node> node) const |
| 34 | { |
| 35 | return ApplicationContainer (InstallPriv (node)); |
| 36 | } |
Ilya Moiseenko | 9b273ce | 2011-08-05 20:24:12 -0700 | [diff] [blame] | 37 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 38 | ApplicationContainer |
| 39 | StupidInterestGeneratorHelper::Install (std::string nodeName) const |
| 40 | { |
| 41 | Ptr<Node> node = Names::Find<Node> (nodeName); |
| 42 | return ApplicationContainer (InstallPriv (node)); |
| 43 | } |
Ilya Moiseenko | 9b273ce | 2011-08-05 20:24:12 -0700 | [diff] [blame] | 44 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 45 | ApplicationContainer |
| 46 | StupidInterestGeneratorHelper::Install (NodeContainer c) const |
| 47 | { |
| 48 | ApplicationContainer apps; |
| 49 | for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) |
| 50 | { |
| 51 | apps.Add (InstallPriv (*i)); |
| 52 | } |
Ilya Moiseenko | 9b273ce | 2011-08-05 20:24:12 -0700 | [diff] [blame] | 53 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 54 | return apps; |
| 55 | } |
Ilya Moiseenko | 9b273ce | 2011-08-05 20:24:12 -0700 | [diff] [blame] | 56 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 57 | Ptr<Application> |
| 58 | StupidInterestGeneratorHelper::InstallPriv (Ptr<Node> node) const |
| 59 | { |
| 60 | Ptr<Application> app = m_factory.Create<Application> (); |
| 61 | node->AddApplication (app); |
Ilya Moiseenko | 9b273ce | 2011-08-05 20:24:12 -0700 | [diff] [blame] | 62 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 63 | return app; |
| 64 | } |
Ilya Moiseenko | 9b273ce | 2011-08-05 20:24:12 -0700 | [diff] [blame] | 65 | |
| 66 | } // namespace ns3 |