OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /*· |
| 3 * Copyright (c) 2012 Michal Paszta |
| 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: Michal Paszta· |
| 19 */ |
| 20 |
| 21 #ifndef RNS_HELPER_H_ |
| 22 #define RNS_HELPER_H_ |
| 23 |
| 24 #include "ns3/rns.h" |
| 25 #include "ns3/object-factory.h" |
| 26 #include "ns3/attribute.h" |
| 27 #include "node-container.h" |
| 28 |
| 29 namespace ns3 { |
| 30 |
| 31 /** |
| 32 * \ingroup rns |
| 33 * \brief Helper class that adds RNS routing to nodes. |
| 34 */ |
| 35 template <class IdType> |
| 36 class RnsHelper |
| 37 { |
| 38 public: |
| 39 RnsHelper (); |
| 40 ~RnsHelper () {}; |
| 41 /** |
| 42 * \internal |
| 43 * \returns pointer to clone of this RnsHelper |
| 44 * |
| 45 * This method is mainly for internal use by the other helpers; |
| 46 * clients are expected to free the dynamic memory allocated by this method |
| 47 */ |
| 48 RnsHelper<IdType>* Copy (void) const; |
| 49 |
| 50 void Install (Ptr<Node> node) const; |
| 51 |
| 52 void Install (NodeContainer container) const; |
| 53 |
| 54 /** |
| 55 * \param name the name of the attribute to set |
| 56 * \param value the value of the attribute to set. |
| 57 * |
| 58 * This method controls the attributes of ns3::rns::Rns |
| 59 */ |
| 60 void Set (std::string name, const AttributeValue &value); |
| 61 |
| 62 private: |
| 63 ObjectFactory m_agentFactory; |
| 64 }; |
| 65 |
| 66 template <class IdType> |
| 67 RnsHelper<IdType>* RnsHelper<IdType>::Copy(void) const |
| 68 { |
| 69 return new RnsHelper<IdType> (*this); |
| 70 } |
| 71 |
| 72 template<class IdType> |
| 73 void RnsHelper<IdType>::Install (Ptr<Node> node) const |
| 74 { |
| 75 Ptr<Object> object = node; |
| 76 Ptr<rns::Rns<IdType> > agent = m_agentFactory.Create<rns::Rns<IdType> >(); |
| 77 object->AggregateObject (agent); |
| 78 agent->Start(node); |
| 79 } |
| 80 |
| 81 template<class IdType> |
| 82 void RnsHelper<IdType>::Install (NodeContainer container) const |
| 83 { |
| 84 Ptr<rns::Rns<IdType> > rns = m_agentFactory.Create<rns::Rns<IdType> >(); |
| 85 for (NodeContainer::Iterator iter = container.Begin(); |
| 86 iter != container.End(); iter++) |
| 87 { |
| 88 Install(*iter); |
| 89 } |
| 90 } |
| 91 |
| 92 template<class IdType> |
| 93 void RnsHelper<IdType>::Set (std::string name, const AttributeValue &value) |
| 94 { |
| 95 m_agentFactory.Set(name,value); |
| 96 } |
| 97 |
| 98 |
| 99 |
| 100 |
| 101 } // namespace ns3 |
| 102 |
| 103 #endif /* RNS_HELPER_H_ */ |
OLD | NEW |