blob: dc29d9a4cf65d23bfe46dbda30e23c97040180d5 [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"
Alexander Afanasyev07827182011-12-13 01:07:32 -080022#include "ns3/log.h"
23#include "ns3/ccnx-name-components.h"
24#include "ns3/names.h"
25#include "../apps/ccnx-consumer.h"
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070026
27NS_LOG_COMPONENT_DEFINE ("CcnxConsumerHelper");
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070028
29namespace ns3
30{
31
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070032CcnxConsumerHelper::CcnxConsumerHelper (const std::string &prefix)
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070033{
34 m_factory.SetTypeId ("ns3::CcnxConsumer");
Alexander Afanasyev120bf312011-12-19 01:24:47 -080035
36 SetPrefix (prefix);
37}
38
39void
40CcnxConsumerHelper::SetPrefix (const std::string &prefix)
41{
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070042 CcnxNameComponentsValue prefixValue;
43 prefixValue.DeserializeFromString (prefix, MakeCcnxNameComponentsChecker ());
44 m_factory.Set ("InterestName", prefixValue);
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070045}
Alexander Afanasyev120bf312011-12-19 01:24:47 -080046
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070047void
48CcnxConsumerHelper::SetAttribute (std::string name, const AttributeValue &value)
49{
50 m_factory.Set (name, value);
51}
52
53ApplicationContainer
54CcnxConsumerHelper::Install (Ptr<Node> node)
55{
56 return ApplicationContainer (InstallPriv (node));
57}
58
59ApplicationContainer
60CcnxConsumerHelper::Install (std::string nodeName)
61{
62 Ptr<Node> node = Names::Find<Node> (nodeName);
63 return ApplicationContainer (InstallPriv (node));
64}
65
66ApplicationContainer
67CcnxConsumerHelper::Install (NodeContainer c)
68{
69 ApplicationContainer apps;
70 for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
71 {
72 apps.Add (InstallPriv (*i));
73 }
74
75 return apps;
76}
77
78Ptr<Application>
79CcnxConsumerHelper::InstallPriv (Ptr<Node> node)
80{
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070081 Ptr<CcnxConsumer> app = m_factory.Create<CcnxConsumer> ();
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070082 node->AddApplication (app);
83
84 return app;
85}
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070086
Alexander Afanasyev152cf112011-08-29 17:58:32 -070087}