Ilya Moiseenko | a121411 | 2011-08-29 13:03:55 -0700 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2011 University of California, Los Angeles |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Author: Ilya Moiseenko <iliamo@cs.ucla.edu> |
| 19 | */ |
| 20 | |
| 21 | #include "ccnx-consumer-helper.h" |
| 22 | #include "ns3/inet-socket-address.h" |
| 23 | #include "ns3/packet-socket-address.h" |
| 24 | #include "ns3/string.h" |
| 25 | #include "ns3/names.h" |
| 26 | |
| 27 | namespace ns3 |
| 28 | { |
| 29 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 30 | CcnxConsumerHelper::CcnxConsumerHelper (const std::string &prefix) |
Ilya Moiseenko | a121411 | 2011-08-29 13:03:55 -0700 | [diff] [blame] | 31 | { |
| 32 | m_factory.SetTypeId ("ns3::CcnxConsumer"); |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 33 | |
| 34 | CcnxNameComponentsValue prefixValue; |
| 35 | prefixValue.DeserializeFromString (prefix, MakeCcnxNameComponentsChecker ()); |
| 36 | m_factory.Set ("InterestName", prefixValue); |
Ilya Moiseenko | a121411 | 2011-08-29 13:03:55 -0700 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | void |
| 40 | CcnxConsumerHelper::SetAttribute (std::string name, const AttributeValue &value) |
| 41 | { |
| 42 | m_factory.Set (name, value); |
| 43 | } |
| 44 | |
| 45 | ApplicationContainer |
| 46 | CcnxConsumerHelper::Install (Ptr<Node> node) |
| 47 | { |
| 48 | return ApplicationContainer (InstallPriv (node)); |
| 49 | } |
| 50 | |
| 51 | ApplicationContainer |
| 52 | CcnxConsumerHelper::Install (std::string nodeName) |
| 53 | { |
| 54 | Ptr<Node> node = Names::Find<Node> (nodeName); |
| 55 | return ApplicationContainer (InstallPriv (node)); |
| 56 | } |
| 57 | |
| 58 | ApplicationContainer |
| 59 | CcnxConsumerHelper::Install (NodeContainer c) |
| 60 | { |
| 61 | ApplicationContainer apps; |
| 62 | for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) |
| 63 | { |
| 64 | apps.Add (InstallPriv (*i)); |
| 65 | } |
| 66 | |
| 67 | return apps; |
| 68 | } |
| 69 | |
| 70 | Ptr<Application> |
| 71 | CcnxConsumerHelper::InstallPriv (Ptr<Node> node) |
| 72 | { |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 73 | Ptr<CcnxConsumer> app = m_factory.Create<CcnxConsumer> (); |
Ilya Moiseenko | a121411 | 2011-08-29 13:03:55 -0700 | [diff] [blame] | 74 | node->AddApplication (app); |
| 75 | |
| 76 | return app; |
| 77 | } |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 78 | |
Alexander Afanasyev | 152cf11 | 2011-08-29 17:58:32 -0700 | [diff] [blame] | 79 | } |