blob: d52a00508f82b619a16e89f9f44fc8b5c086292c [file] [log] [blame]
Alexander Afanasyev4975f732011-12-20 17:52:19 -08001/* -*- 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
27NS_LOG_COMPONENT_DEFINE ("CcnxAppHelper");
28
29namespace ns3
30{
31
32CcnxAppHelper::CcnxAppHelper (const std::string &app)
33{
34 m_factory.SetTypeId (app);
35}
36
37void
38CcnxAppHelper::SetPrefix (const std::string &prefix)
39{
40 m_factory.Set ("Prefix", StringValue(prefix));
41}
42
43void
44CcnxAppHelper::SetAttribute (std::string name, const AttributeValue &value)
45{
46 m_factory.Set (name, value);
47}
48
49ApplicationContainer
50CcnxAppHelper::Install (Ptr<Node> node)
51{
52 return ApplicationContainer (InstallPriv (node));
53}
54
55ApplicationContainer
56CcnxAppHelper::Install (std::string nodeName)
57{
58 Ptr<Node> node = Names::Find<Node> (nodeName);
59 return ApplicationContainer (InstallPriv (node));
60}
61
62ApplicationContainer
63CcnxAppHelper::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
74Ptr<Application>
75CcnxAppHelper::InstallPriv (Ptr<Node> node)
76{
77 Ptr<CcnxApp> app = m_factory.Create<CcnxApp> ();
78 node->AddApplication (app);
79
80 return app;
81}
82
83}