Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [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-app-helper.h" |
| 22 | #include "ns3/log.h" |
| 23 | #include "ns3/string.h" |
| 24 | #include "ns3/names.h" |
| 25 | #include "ns3/ccnx-app.h" |
| 26 | |
| 27 | NS_LOG_COMPONENT_DEFINE ("CcnxAppHelper"); |
| 28 | |
| 29 | namespace ns3 |
| 30 | { |
| 31 | |
| 32 | CcnxAppHelper::CcnxAppHelper (const std::string &app) |
| 33 | { |
| 34 | m_factory.SetTypeId (app); |
| 35 | } |
| 36 | |
| 37 | void |
| 38 | CcnxAppHelper::SetPrefix (const std::string &prefix) |
| 39 | { |
| 40 | m_factory.Set ("Prefix", StringValue(prefix)); |
| 41 | } |
| 42 | |
| 43 | void |
| 44 | CcnxAppHelper::SetAttribute (std::string name, const AttributeValue &value) |
| 45 | { |
| 46 | m_factory.Set (name, value); |
| 47 | } |
| 48 | |
| 49 | ApplicationContainer |
| 50 | CcnxAppHelper::Install (Ptr<Node> node) |
| 51 | { |
| 52 | return ApplicationContainer (InstallPriv (node)); |
| 53 | } |
| 54 | |
| 55 | ApplicationContainer |
| 56 | CcnxAppHelper::Install (std::string nodeName) |
| 57 | { |
| 58 | Ptr<Node> node = Names::Find<Node> (nodeName); |
| 59 | return ApplicationContainer (InstallPriv (node)); |
| 60 | } |
| 61 | |
| 62 | ApplicationContainer |
| 63 | CcnxAppHelper::Install (NodeContainer c) |
| 64 | { |
| 65 | ApplicationContainer apps; |
| 66 | for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) |
| 67 | { |
| 68 | apps.Add (InstallPriv (*i)); |
| 69 | } |
| 70 | |
| 71 | return apps; |
| 72 | } |
| 73 | |
| 74 | Ptr<Application> |
| 75 | CcnxAppHelper::InstallPriv (Ptr<Node> node) |
| 76 | { |
| 77 | Ptr<CcnxApp> app = m_factory.Create<CcnxApp> (); |
| 78 | node->AddApplication (app); |
| 79 | |
| 80 | return app; |
| 81 | } |
| 82 | |
| 83 | } |