add attribute to control loader type
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 15 Sep 2010 11:40:31 +0200
changeset 6 64c6f4f78c91
parent 5 e6642ce0d173
child 7 6c6b84ead145
add attribute to control loader type
helper/dce-manager-helper.cc
helper/dce-manager-helper.h
--- a/helper/dce-manager-helper.cc	Wed Sep 15 11:39:31 2010 +0200
+++ b/helper/dce-manager-helper.cc	Wed Sep 15 11:40:31 2010 +0200
@@ -6,14 +6,37 @@
 #include "ns3/loader-factory.h"
 #include "ns3/random-variable.h"
 #include "ns3/uinteger.h"
+#include "ns3/string.h"
+#include "ns3/config.h"
 
 namespace ns3 {
 
 UniformVariable g_firstPid;
 
+NS_OBJECT_ENSURE_REGISTERED (DceManagerHelper);
+
+TypeId 
+DceManagerHelper::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::DceManagerHelper")
+    .SetParent<ObjectBase> ()
+    .AddAttribute ("LoaderFactory", 
+		   "The kind of loader factory created when Install is called", 
+		   StringValue ("ns3::CoojaLoaderFactory[]"),
+		   MakeObjectFactoryAccessor (&DceManagerHelper::m_loaderFactory),
+		   MakeObjectFactoryChecker ())
+    ;
+  return tid;
+}
+TypeId 
+DceManagerHelper::GetInstanceTypeId (void) const
+{
+  return DceManagerHelper::GetTypeId ();
+}
+
 DceManagerHelper::DceManagerHelper ()
 {
-  m_loaderFactory.SetTypeId ("ns3::DlmLoaderFactory");
+  ConstructSelf (AttributeList ());
   m_taskManagerFactory.SetTypeId ("ns3::TaskManager");
   m_schedulerFactory.SetTypeId ("ns3::RrTaskScheduler");
   m_managerFactory.SetTypeId ("ns3::DceManager");
--- a/helper/dce-manager-helper.h	Wed Sep 15 11:39:31 2010 +0200
+++ b/helper/dce-manager-helper.h	Wed Sep 15 11:40:31 2010 +0200
@@ -3,14 +3,17 @@
 
 #include "ns3/object-factory.h"
 #include "ns3/attribute.h"
+#include "ns3/object-base.h"
 #include "ns3/node-container.h"
 #include <string>
 
 namespace ns3 {
 
-class DceManagerHelper
+class DceManagerHelper : public ObjectBase
 {
 public:
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   DceManagerHelper ();
   void SetScheduler (std::string type, 
 		     std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),