blob: 20ad7464c934e00c0c06e8a34715f4f740d19810 [file] [log] [blame]
Alexander Afanasyev09e8d752012-04-10 16:05: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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 */
20
21#ifndef SYNC_LOGIC_HELPER_H
22#define SYNC_LOGIC_HELPER_H
23
24#include "ns3/object-factory.h"
25#include "ns3/attribute.h"
26#include "ns3/node-container.h"
27#include "ns3/application-container.h"
28#include "ns3/ptr.h"
29
30#include <boost/function.hpp>
31
32namespace Sync
33{
34
35class SeqNo;
36
37/**
38 * \brief A helper to make it easier to instantiate an ns3::CcnxConsumer Application
39 * on a set of nodes.
40 */
41class SyncLogicHelper
42{
43public:
44 typedef boost::function< void ( const std::string &/*prefix*/, const SeqNo &/*newSeq*/, const SeqNo &/*oldSeq*/ ) > LogicUpdateCallback;
45 typedef boost::function< void ( const std::string &/*prefix*/ ) > LogicRemoveCallback;
46
47 /**
48 * \brief Create an CcnxAppHelper to make it easier to work with CCNx apps
49 *
50 * \param app Class of the application
51 */
52 SyncLogicHelper ();
53
54 /**
55 * @brief Set the sync prefix
56 */
57 void
58 SetPrefix (const std::string &prefix);
59
60 /**
61 * @brief Set onUpdate and onRemove callbacks
62 */
63 void
64 SetCallbacks (LogicUpdateCallback onUpdate, LogicRemoveCallback onRemove);
65
66 /**
67 * Install an ns3::CcnxConsumer on each node of the input container
68 * configured with all the attributes set with SetAttribute.
69 *
70 * \param c NodeContainer of the set of nodes on which an CcnxConsumer
71 * will be installed.
72 * \returns Container of Ptr to the applications installed.
73 */
74 ns3::ApplicationContainer
75 Install (ns3::NodeContainer c);
76
77 /**
78 * Install an ns3::CcnxConsumer on the node configured with all the
79 * attributes set with SetAttribute.
80 *
81 * \param node The node on which an CcnxConsumer will be installed.
82 * \returns Container of Ptr to the applications installed.
83 */
84 ns3::ApplicationContainer
85 Install (ns3::Ptr<ns3::Node> node);
86
87 /**
88 * Install an ns3::CcnxConsumer on the node configured with all the
89 * attributes set with SetAttribute.
90 *
91 * \param nodeName The node on which an CcnxConsumer will be installed.
92 * \returns Container of Ptr to the applications installed.
93 */
94 ns3::ApplicationContainer
95 Install (std::string nodeName);
96
97private:
98 /**
99 * \internal
100 * Install an ns3::CcnxConsumer on the node configured with all the
101 * attributes set with SetAttribute.
102 *
103 * \param node The node on which an CcnxConsumer will be installed.
104 * \returns Ptr to the application installed.
105 */
106 ns3::Ptr<ns3::Application> InstallPriv (ns3::Ptr<ns3::Node> node);
107 std::string m_prefix; // sync prefix
108 LogicUpdateCallback m_onUpdate;
109 LogicRemoveCallback m_onRemove;
110};
111
112} // namespace Sync
113
114#endif // SYNC_LOGIC_HELPER_H
115