blob: adb3c6efc4ce3791f5744e7956a611834907be1c [file] [log] [blame]
Ilya Moiseenkoa1214112011-08-29 13:03:55 -07001/* -*- 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"
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070022
23NS_LOG_COMPONENT_DEFINE ("CcnxConsumerHelper");
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070024
25namespace ns3
26{
27
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070028CcnxConsumerHelper::CcnxConsumerHelper (const std::string &prefix)
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070029{
30 m_factory.SetTypeId ("ns3::CcnxConsumer");
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070031
32 CcnxNameComponentsValue prefixValue;
33 prefixValue.DeserializeFromString (prefix, MakeCcnxNameComponentsChecker ());
34 m_factory.Set ("InterestName", prefixValue);
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070035}
36
37void
38CcnxConsumerHelper::SetAttribute (std::string name, const AttributeValue &value)
39{
40 m_factory.Set (name, value);
41}
42
43ApplicationContainer
44CcnxConsumerHelper::Install (Ptr<Node> node)
45{
46 return ApplicationContainer (InstallPriv (node));
47}
48
49ApplicationContainer
50CcnxConsumerHelper::Install (std::string nodeName)
51{
52 Ptr<Node> node = Names::Find<Node> (nodeName);
53 return ApplicationContainer (InstallPriv (node));
54}
55
56ApplicationContainer
57CcnxConsumerHelper::Install (NodeContainer c)
58{
59 ApplicationContainer apps;
60 for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
61 {
62 apps.Add (InstallPriv (*i));
63 }
64
65 return apps;
66}
67
68Ptr<Application>
69CcnxConsumerHelper::InstallPriv (Ptr<Node> node)
70{
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070071 Ptr<CcnxConsumer> app = m_factory.Create<CcnxConsumer> ();
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070072 node->AddApplication (app);
73
74 return app;
75}
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070076
Alexander Afanasyev152cf112011-08-29 17:58:32 -070077}