blob: 63fa705684d397363124f5d3476b69294b3e257e [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
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070021#ifndef NDN_APP_HELPER_H
22#define NDN_APP_HELPER_H
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070023
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070024#include "ns3/object-factory.h"
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070025#include "ns3/attribute.h"
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070026#include "ns3/node-container.h"
27#include "ns3/application-container.h"
Alexander Afanasyev07827182011-12-13 01:07:32 -080028#include "ns3/ptr.h"
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070029
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070030namespace ns3 {
31namespace ndn {
Alexander Afanasyev4975f732011-12-20 17:52:19 -080032
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070033/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070034 * @ingroup ndn-helpers
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070035 * \brief A helper to make it easier to instantiate an ns3::NdnConsumer Application
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070036 * on a set of nodes.
37 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080038class AppHelper {
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070039public:
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070040 /**
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070041 * \brief Create an NdnAppHelper to make it easier to work with Ndn apps
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070042 *
Alexander Afanasyev4975f732011-12-20 17:52:19 -080043 * \param app Class of the application
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070044 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080045 AppHelper(const std::string& prefix);
Alexander Afanasyev120bf312011-12-19 01:24:47 -080046
47 /**
48 * @brief Set the prefix consumer will be requesting
49 */
50 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080051 SetPrefix(const std::string& prefix);
52
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070053 /**
54 * \brief Helper function used to set the underlying application attributes.
55 *
56 * \param name the name of the application attribute to set
57 * \param value the value of the application attribute to set
58 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080059 void
60 SetAttribute(std::string name, const AttributeValue& value);
61
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070062 /**
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070063 * Install an ns3::NdnConsumer on each node of the input container
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070064 * configured with all the attributes set with SetAttribute.
65 *
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080066 * \param c NodeContainer of the set of nodes on which an NdnConsumer
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070067 * will be installed.
68 * \returns Container of Ptr to the applications installed.
69 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080070 ApplicationContainer
71 Install(NodeContainer c);
72
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070073 /**
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080074 * Install an ns3::NdnConsumer on the node configured with all the
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070075 * attributes set with SetAttribute.
76 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070077 * \param node The node on which an NdnConsumer will be installed.
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070078 * \returns Container of Ptr to the applications installed.
79 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080080 ApplicationContainer
81 Install(Ptr<Node> node);
82
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070083 /**
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080084 * Install an ns3::NdnConsumer on the node configured with all the
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070085 * attributes set with SetAttribute.
86 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070087 * \param nodeName The node on which an NdnConsumer will be installed.
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070088 * \returns Container of Ptr to the applications installed.
89 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080090 ApplicationContainer
91 Install(std::string nodeName);
92
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070093private:
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070094 /**
95 * \internal
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080096 * Install an ns3::NdnConsumer on the node configured with all the
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070097 * attributes set with SetAttribute.
98 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070099 * \param node The node on which an NdnConsumer will be installed.
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700100 * \returns Ptr to the application installed.
101 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800102 Ptr<Application>
103 InstallPriv(Ptr<Node> node);
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700104 ObjectFactory m_factory;
105};
Ilya Moiseenkoa1214112011-08-29 13:03:55 -0700106
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700107} // namespace ndn
Alexander Afanasyev4975f732011-12-20 17:52:19 -0800108} // namespace ns3
Ilya Moiseenkoa1214112011-08-29 13:03:55 -0700109
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700110#endif // NDN_APP_HELPER_H