blob: fab41ad8840becd5f0950fe68bc37ca6732778f8 [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
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070024#include "ns3/ndnSIM/model/ndn-common.hpp"
25
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070026#include "ns3/object-factory.h"
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070027#include "ns3/attribute.h"
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070028#include "ns3/node-container.h"
29#include "ns3/application-container.h"
Alexander Afanasyev07827182011-12-13 01:07:32 -080030#include "ns3/ptr.h"
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070031
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070032namespace ns3 {
33namespace ndn {
Alexander Afanasyev4975f732011-12-20 17:52:19 -080034
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070035/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070036 * @ingroup ndn-helpers
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070037 * \brief A helper to make it easier to instantiate an ns3::NdnConsumer Application
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070038 * on a set of nodes.
39 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080040class AppHelper {
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070041public:
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070042 /**
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070043 * \brief Create an NdnAppHelper to make it easier to work with Ndn apps
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070044 *
Alexander Afanasyev4975f732011-12-20 17:52:19 -080045 * \param app Class of the application
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070046 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080047 AppHelper(const std::string& prefix);
Alexander Afanasyev120bf312011-12-19 01:24:47 -080048
49 /**
50 * @brief Set the prefix consumer will be requesting
51 */
52 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080053 SetPrefix(const std::string& prefix);
54
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070055 /**
56 * \brief Helper function used to set the underlying application attributes.
57 *
58 * \param name the name of the application attribute to set
59 * \param value the value of the application attribute to set
60 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080061 void
62 SetAttribute(std::string name, const AttributeValue& value);
63
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070064 /**
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070065 * Install an ns3::NdnConsumer on each node of the input container
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070066 * configured with all the attributes set with SetAttribute.
67 *
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080068 * \param c NodeContainer of the set of nodes on which an NdnConsumer
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070069 * will be installed.
70 * \returns Container of Ptr to the applications installed.
71 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080072 ApplicationContainer
73 Install(NodeContainer c);
74
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070075 /**
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080076 * Install an ns3::NdnConsumer on the node configured with all the
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070077 * attributes set with SetAttribute.
78 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070079 * \param node The node on which an NdnConsumer will be installed.
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070080 * \returns Container of Ptr to the applications installed.
81 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080082 ApplicationContainer
83 Install(Ptr<Node> node);
84
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070085 /**
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080086 * Install an ns3::NdnConsumer on the node configured with all the
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070087 * attributes set with SetAttribute.
88 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070089 * \param nodeName The node on which an NdnConsumer will be installed.
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070090 * \returns Container of Ptr to the applications installed.
91 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080092 ApplicationContainer
93 Install(std::string nodeName);
94
Ilya Moiseenkoa1214112011-08-29 13:03:55 -070095private:
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070096 /**
97 * \internal
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080098 * Install an ns3::NdnConsumer on the node configured with all the
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070099 * attributes set with SetAttribute.
100 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700101 * \param node The node on which an NdnConsumer will be installed.
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700102 * \returns Ptr to the application installed.
103 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800104 Ptr<Application>
105 InstallPriv(Ptr<Node> node);
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700106 ObjectFactory m_factory;
107};
Ilya Moiseenkoa1214112011-08-29 13:03:55 -0700108
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700109} // namespace ndn
Alexander Afanasyev4975f732011-12-20 17:52:19 -0800110} // namespace ns3
Ilya Moiseenkoa1214112011-08-29 13:03:55 -0700111
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700112#endif // NDN_APP_HELPER_H