blob: ec44aca42c1779583d64740fdb00f0ff42bcc66b [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-producer-helper.h"
Alexander Afanasyev07827182011-12-13 01:07:32 -080022#include "ns3/log.h"
23#include "ns3/ccnx-name-components.h"
24#include "ns3/uinteger.h"
25#include "ns3/names.h"
26#include "../apps/ccnx-producer.h"
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070027
28NS_LOG_COMPONENT_DEFINE ("CcnxProducerHelper");
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070029
30namespace ns3
31{
32
Ilya Moiseenkofb2362f2011-10-28 13:08:05 -070033CcnxProducerHelper::CcnxProducerHelper (const std::string &prefix, uint32_t virtualPayloadSize)
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070034{
Ilya Moiseenko332add02011-12-24 17:21:25 -080035 m_factory.SetTypeId ("ns3::CcnxProducer");
Ilya Moiseenkofb2362f2011-10-28 13:08:05 -070036
Ilya Moiseenko332add02011-12-24 17:21:25 -080037 CcnxNameComponentsValue prefixValue;
38 prefixValue.DeserializeFromString (prefix, MakeCcnxNameComponentsChecker ());
39 m_factory.Set ("Prefix", prefixValue);
Ilya Moiseenkofb2362f2011-10-28 13:08:05 -070040
Ilya Moiseenko332add02011-12-24 17:21:25 -080041 m_factory.Set ("PayloadSize", UintegerValue (virtualPayloadSize));
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070042}
43
44void
45CcnxProducerHelper::SetAttribute (std::string name, const AttributeValue &value)
46{
Ilya Moiseenko332add02011-12-24 17:21:25 -080047 m_factory.Set (name, value);
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070048}
49
50ApplicationContainer
51CcnxProducerHelper::Install (Ptr<Node> node)
52{
Ilya Moiseenko332add02011-12-24 17:21:25 -080053 NS_LOG_FUNCTION(this);
54 return ApplicationContainer (InstallPriv (node));
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070055}
Ilya Moiseenkofb2362f2011-10-28 13:08:05 -070056
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070057ApplicationContainer
58CcnxProducerHelper::Install (std::string nodeName)
59{
Ilya Moiseenko332add02011-12-24 17:21:25 -080060 Ptr<Node> node = Names::Find<Node> (nodeName);
61 return ApplicationContainer (InstallPriv (node));
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070062}
63
64ApplicationContainer
65CcnxProducerHelper::Install (NodeContainer c)
66{
Ilya Moiseenko332add02011-12-24 17:21:25 -080067 ApplicationContainer apps;
68 for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070069 {
Ilya Moiseenko332add02011-12-24 17:21:25 -080070 apps.Add (InstallPriv (*i));
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070071 }
72
Ilya Moiseenko332add02011-12-24 17:21:25 -080073 return apps;
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070074}
Ilya Moiseenko332add02011-12-24 17:21:25 -080075
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070076Ptr<Application>
77CcnxProducerHelper::InstallPriv (Ptr<Node> node)
78{
Ilya Moiseenko332add02011-12-24 17:21:25 -080079 NS_LOG_INFO ("InstallPriv started");
80 Ptr<CcnxProducer> app = m_factory.Create<CcnxProducer> ();
81 node->AddApplication (app);
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070082
Ilya Moiseenko332add02011-12-24 17:21:25 -080083 return app;
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070084}
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070085}