A Discrete-Event Network Simulator
API
config-test-suite.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
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  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #include "ns3/config.h"
21 #include "ns3/test.h"
22 #include "ns3/integer.h"
23 #include "ns3/traced-value.h"
24 #include "ns3/trace-source-accessor.h"
25 #include "ns3/callback.h"
26 
27 #include "ns3/singleton.h"
28 #include "ns3/object.h"
29 #include "ns3/object-vector.h"
30 #include "ns3/names.h"
31 #include "ns3/pointer.h"
32 #include "ns3/log.h"
33 
34 
35 #include <sstream>
36 
50 namespace ns3 {
51 
52  namespace tests {
53 
54 
59 class ConfigTestObject : public Object
60 {
61 public:
66  static TypeId GetTypeId (void);
67 
78 
89 
94  int8_t GetA (void) const;
99  int8_t GetB (void) const;
100 
101 private:
102  std::vector<Ptr<ConfigTestObject> > m_nodesA;
103  std::vector<Ptr<ConfigTestObject> > m_nodesB;
106  int8_t m_a;
107  int8_t m_b;
109 };
110 
111 TypeId
113 {
114  static TypeId tid = TypeId ("ConfigTestObject")
115  .SetParent<Object> ()
116  .AddAttribute ("NodesA", "",
119  MakeObjectVectorChecker<ConfigTestObject> ())
120  .AddAttribute ("NodesB", "",
123  MakeObjectVectorChecker<ConfigTestObject> ())
124  .AddAttribute ("NodeA", "",
125  PointerValue (),
127  MakePointerChecker<ConfigTestObject> ())
128  .AddAttribute ("NodeB", "",
129  PointerValue (),
131  MakePointerChecker<ConfigTestObject> ())
132  .AddAttribute ("A", "",
133  IntegerValue (10),
135  MakeIntegerChecker<int8_t> ())
136  .AddAttribute ("B", "",
137  IntegerValue (9),
139  MakeIntegerChecker<int8_t> ())
140  .AddAttribute ("Source", "XX",
141  IntegerValue (-1),
143  MakeIntegerChecker<int16_t> ())
144  .AddTraceSource ("Source", "XX",
146  "ns3::TracedValueCallback::Int16")
147  ;
148  return tid;
149 }
150 
151 void
153 {
154  m_nodeA = a;
155 }
156 
157 void
159 {
160  m_nodeB = b;
161 }
162 
163 void
165 {
166  m_nodesA.push_back (a);
167 }
168 
169 void
171 {
172  m_nodesB.push_back (b);
173 }
174 
175 int8_t
177 {
178  return m_a;
179 }
180 
181 int8_t
183 {
184  return m_b;
185 }
186 
192 {
193 public:
198  static TypeId GetTypeId (void);
202  virtual ~DerivedConfigTestObject (void) {}
203 };
204 
205 TypeId
207 {
208  static TypeId tid = TypeId ("DerivedConfigTestObject")
210  ;
211  return tid;
212 }
213 
218 class BaseConfigObject : public Object
219 {
220 public:
225  static TypeId GetTypeId (void);
227  BaseConfigObject (void) : m_x(15) {}
229  virtual ~BaseConfigObject (void) {}
230 private:
231  int8_t m_x;
232 
233  void Increment (void) { m_x++; }
234 };
235 
236 TypeId
238 {
239  static TypeId tid = TypeId ("BaseConfigObject")
240  .SetParent<Object> ()
241  .AddAttribute ("X", "",
242  IntegerValue (10),
244  MakeIntegerChecker<int8_t> ())
245  ;
246  return tid;
247 }
248 
254 {
255 public:
260  static TypeId GetTypeId (void);
264  virtual ~DerivedConfigObject (void) {}
265 };
266 
267 TypeId
269 {
270  static TypeId tid = TypeId ("DerivedConfigObject")
272  ;
273  return tid;
274 }
275 
276 
282 {
283 public:
288 
289 private:
290  virtual void DoRun (void);
291 };
292 
294  : TestCase ("Check ability to register a root namespace and use it")
295 {
296 }
297 
298 void
300 {
301  IntegerValue iv;
302  //
303  // Create an object and register its attributes directly in the root
304  // namespace.
305  //
306  Ptr<ConfigTestObject> root = CreateObject<ConfigTestObject> ();
308 
309  //
310  // We should find the default values there.
311  //
312  root->GetAttribute ("A", iv);
313  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" not initialized as expected");
314 
315  //
316  // Now use the config mechanism to set the attribute; and we should find the
317  // new value.
318  //
319  Config::Set ("/A", IntegerValue (1));
320  root->GetAttribute ("A", iv);
321  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 1, "Object Attribute \"A\" not set correctly");
322 
323  //
324  // We should find the default values of "B" too.
325  //
326  root->GetAttribute ("B", iv);
327  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 9, "Object Attribute \"B\" not initialized as expected");
328 
329  //
330  // Now use the config mechanism to set the attribute; and we should find the
331  // new value.
332  //
333  Config::Set ("/B", IntegerValue (-1));
334  root->GetAttribute ("B", iv);
335  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -1, "Object Attribute \"B\" not set correctly");
336 }
337 
343 {
344 public:
349 
350 private:
351  virtual void DoRun (void);
352 };
353 
355  : TestCase ("Check ability to register an object under the root namespace and use it")
356 {
357 }
358 
359 void
361 {
362  IntegerValue iv;
363  //
364  // Create an object and register its attributes directly in the root
365  // namespace.
366  //
367  Ptr<ConfigTestObject> root = CreateObject<ConfigTestObject> ();
369 
370  Ptr<ConfigTestObject> a = CreateObject<ConfigTestObject> ();
371  root->SetNodeA (a);
372 
373  //
374  // We should find the default values there.
375  //
376  a->GetAttribute ("A", iv);
377  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" not initialized as expected");
378 
379  //
380  // Now use the config mechanism to set the attribute; and we should find the
381  // new value.
382  //
383  Config::Set ("/NodeA/A", IntegerValue (1));
384  a->GetAttribute ("A", iv);
385  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 1, "Object Attribute \"A\" not set correctly");
386 
387 
388  //
389  // We should find the default values of "B" too.
390  //
391  a->GetAttribute ("B", iv);
392  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 9, "Object Attribute \"B\" not initialized as expected");
393 
394  //
395  // Now use the config mechanism to set the attribute; and we should find the
396  // new value.
397  //
398  Config::Set ("/NodeA/B", IntegerValue (-1));
399  a->GetAttribute ("B", iv);
400  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -1, "Object Attribute \"B\" not set correctly");
401 
402  //
403  // Try and set through a nonexistent path. Should do nothing.
404  //
405  Config::Set ("/NodeB/A", IntegerValue (1234));
406  a->GetAttribute ("A", iv);
407  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 1, "Object Attribute \"A\" unexpectedly set via bad path");
408 
409  Config::Set ("/NodeB/B", IntegerValue (1234));
410  a->GetAttribute ("B", iv);
411  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -1, "Object Attribute \"B\" unexpectedly set via bad path");
412 
413  //
414  // Step down one level of recursion and try again
415  //
416  Ptr<ConfigTestObject> b = CreateObject<ConfigTestObject> ();
417 
418  //
419  // We should find the default values there.
420  //
421  b->GetAttribute ("A", iv);
422  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" not initialized as expected");
423  b->GetAttribute ("B", iv);
424  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 9, "Object Attribute \"B\" not initialized as expected");
425 
426  //
427  // Now tell A that it has a B; and we should be able to set this new object's
428  // Attributes.
429  //
430  a->SetNodeB (b);
431 
432  Config::Set ("/NodeA/NodeB/A", IntegerValue (4));
433  Config::Set ("/NodeA/NodeB/B", IntegerValue (-4));
434  b->GetAttribute ("A", iv);
435  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 4, "Object Attribute \"A\" not set as expected");
436  b->GetAttribute ("B", iv);
437  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -4, "Object Attribute \"B\" not set as expected");
438 
439 
440  //
441  // Try '*' for attributes
442  //
443  Config::Set ("/*/A", IntegerValue (2));
444  a->GetAttribute ("A", iv);
445  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 2, "Object Attribute \"A\" not set correctly");
446  b->GetAttribute ("A", iv);
447  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 4, "Object Attribute \"A\" not set correctly");
448 }
449 
455 {
456 public:
461 
462 private:
463  virtual void DoRun (void);
464 };
465 
467  : TestCase ("Check ability to configure vectors of Object using regular expressions")
468 {
469 }
470 
471 void
473 {
474  IntegerValue iv;
475 
476  //
477  // Create a root namespace object
478  //
479  Ptr<ConfigTestObject> root = CreateObject<ConfigTestObject> ();
481 
482  //
483  // Create an object under the root.
484  //
485  Ptr<ConfigTestObject> a = CreateObject<ConfigTestObject> ();
486  root->SetNodeA (a);
487 
488  //
489  // Create an object one level down.
490  //
491  Ptr<ConfigTestObject> b = CreateObject<ConfigTestObject> ();
492  a->SetNodeB (b);
493 
494  //
495  // Add four objects to the ObjectVector Attribute at the bottom of the
496  // object hierarchy. By this point, we believe that the Attributes
497  // will be initialized correctly.
498  //
499  Ptr<ConfigTestObject> obj0 = CreateObject<ConfigTestObject> ();
500  Ptr<ConfigTestObject> obj1 = CreateObject<ConfigTestObject> ();
501  Ptr<ConfigTestObject> obj2 = CreateObject<ConfigTestObject> ();
502  Ptr<ConfigTestObject> obj3 = CreateObject<ConfigTestObject> ();
503  b->AddNodeB (obj0);
504  b->AddNodeB (obj1);
505  b->AddNodeB (obj2);
506  b->AddNodeB (obj3);
507 
508  //
509  // Set an Attribute of the zeroth Object in the vector by explicitly writing
510  // the '0' and make sure that only the one thing changed.
511  //
512  Config::Set ("/NodeA/NodeB/NodesB/0/A", IntegerValue (-11));
513  obj0->GetAttribute ("A", iv);
514  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -11, "Object Attribute \"A\" not set as expected");
515 
516  obj1->GetAttribute ("A", iv);
517  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
518 
519  obj2->GetAttribute ("A", iv);
520  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
521 
522  obj3->GetAttribute ("A", iv);
523  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
524 
525  //
526  // Start using regular expression-like syntax to set Attributes. First try
527  // the OR syntax. Make sure that the two objects changed and nothing else
528  //
529  Config::Set ("/NodeA/NodeB/NodesB/0|1/A", IntegerValue (-12));
530  obj0->GetAttribute ("A", iv);
531  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -12, "Object Attribute \"A\" not set as expected");
532 
533  obj1->GetAttribute ("A", iv);
534  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -12, "Object Attribute \"A\" not set as expected");
535 
536  obj2->GetAttribute ("A", iv);
537  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
538 
539  obj3->GetAttribute ("A", iv);
540  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
541 
542  //
543  // Make sure that extra '|' are allowed at the start and end of the regular expression
544  //
545  Config::Set ("/NodeA/NodeB/NodesB/|0|1|/A", IntegerValue (-13));
546  obj0->GetAttribute ("A", iv);
547  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -13, "Object Attribute \"A\" not set as expected");
548 
549  obj1->GetAttribute ("A", iv);
550  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -13, "Object Attribute \"A\" not set as expected");
551 
552  obj2->GetAttribute ("A", iv);
553  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
554 
555  obj3->GetAttribute ("A", iv);
556  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
557 
558  //
559  // Try the [x-y] syntax
560  //
561  Config::Set ("/NodeA/NodeB/NodesB/[0-2]/A", IntegerValue (-14));
562  obj0->GetAttribute ("A", iv);
563  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -14, "Object Attribute \"A\" not set as expected");
564 
565  obj1->GetAttribute ("A", iv);
566  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -14, "Object Attribute \"A\" not set as expected");
567 
568  obj2->GetAttribute ("A", iv);
569  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -14, "Object Attribute \"A\" not set as expected");
570 
571  obj3->GetAttribute ("A", iv);
572  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
573 
574  //
575  // Try the [x-y] syntax at the other limit
576  //
577  Config::Set ("/NodeA/NodeB/NodesB/[1-3]/A", IntegerValue (-15));
578  obj0->GetAttribute ("A", iv);
579  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -14, "Object Attribute \"A\" unexpectedly set");
580 
581  obj1->GetAttribute ("A", iv);
582  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -15, "Object Attribute \"A\" not set as expected");
583 
584  obj2->GetAttribute ("A", iv);
585  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -15, "Object Attribute \"A\" not set as expected");
586 
587  obj3->GetAttribute ("A", iv);
588  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -15, "Object Attribute \"A\" not set as expected");
589 
590  //
591  // Combine the [x-y] syntax and the OR sntax
592  //
593  Config::Set ("/NodeA/NodeB/NodesB/[0-1]|3/A", IntegerValue (-16));
594  obj0->GetAttribute ("A", iv);
595  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -16, "Object Attribute \"A\" not set as expected");
596 
597  obj1->GetAttribute ("A", iv);
598  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -16, "Object Attribute \"A\" not set as expected");
599 
600  obj2->GetAttribute ("A", iv);
601  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -15, "Object Attribute \"A\" unexpectedly set");
602 
603  obj3->GetAttribute ("A", iv);
604  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -16, "Object Attribute \"A\" not set as expected");
605 }
606 
612 {
613 public:
618 
624  void Trace (int16_t oldValue, int16_t newValue) { m_newValue = newValue; }
631  void TraceWithPath (std::string path, int16_t old, int16_t newValue)
632  { m_newValue = newValue; m_path = path; }
633 
634 private:
635  virtual void DoRun (void);
636 
637  int16_t m_newValue;
638  std::string m_path;
639 };
640 
642  : TestCase ("Check ability to trace connect through vectors of Object using regular expressions")
643 {
644 }
645 
646 void
648 {
649  IntegerValue iv;
650 
651  //
652  // Create a root namespace object
653  //
654  Ptr<ConfigTestObject> root = CreateObject<ConfigTestObject> ();
656 
657  //
658  // Create an object under the root.
659  //
660  Ptr<ConfigTestObject> a = CreateObject<ConfigTestObject> ();
661  root->SetNodeA (a);
662 
663  //
664  // Create an object one level down.
665  //
666  Ptr<ConfigTestObject> b = CreateObject<ConfigTestObject> ();
667  a->SetNodeB (b);
668 
669  //
670  // Add four objects to the ObjectVector Attribute at the bottom of the
671  // object hierarchy. By this point, we believe that the Attributes
672  // will be initialized correctly.
673  //
674  Ptr<ConfigTestObject> obj0 = CreateObject<ConfigTestObject> ();
675  Ptr<ConfigTestObject> obj1 = CreateObject<ConfigTestObject> ();
676  Ptr<ConfigTestObject> obj2 = CreateObject<ConfigTestObject> ();
677  Ptr<ConfigTestObject> obj3 = CreateObject<ConfigTestObject> ();
678  b->AddNodeB (obj0);
679  b->AddNodeB (obj1);
680  b->AddNodeB (obj2);
681  b->AddNodeB (obj3);
682 
683  //
684  // Do a trace connect to some of the sources. We already checked parsing of
685  // the regular expressions, so we'll concentrate on the tracing part of the
686  // puzzle here.
687  //
688  Config::ConnectWithoutContext ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
690 
691  //
692  // If we bug the trace source referred to by index '0' above, we should see
693  // the trace fire.
694  //
695  m_newValue = 0;
696  obj0->SetAttribute ("Source", IntegerValue (-1));
697  NS_TEST_ASSERT_MSG_EQ (m_newValue, -1, "Trace 0 did not fire as expected");
698 
699  //
700  // If we bug the trace source referred to by index '1' above, we should see
701  // the trace fire.
702  //
703  m_newValue = 0;
704  obj1->SetAttribute ("Source", IntegerValue (-2));
705  NS_TEST_ASSERT_MSG_EQ (m_newValue, -2, "Trace 1 did not fire as expected");
706 
707  //
708  // If we bug the trace source referred to by index '2' which is skipped above,
709  // we should not see the trace fire.
710  //
711  m_newValue = 0;
712  obj2->SetAttribute ("Source", IntegerValue (-3));
713  NS_TEST_ASSERT_MSG_EQ (m_newValue, 0, "Trace 2 fired unexpectedly");
714 
715  //
716  // If we bug the trace source referred to by index '3' above, we should see
717  // the trace fire.
718  //
719  m_newValue = 0;
720  obj3->SetAttribute ("Source", IntegerValue (-4));
721  NS_TEST_ASSERT_MSG_EQ (m_newValue, -4, "Trace 3 did not fire as expected");
722 
723  //
724  // Do a trace connect (with context) to some of the sources.
725  //
726  Config::Connect ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
728 
729  //
730  // If we bug the trace source referred to by index '0' above, we should see
731  // the trace fire with the expected context path.
732  //
733  m_newValue = 0;
734  m_path = "";
735  obj0->SetAttribute ("Source", IntegerValue (-1));
736  NS_TEST_ASSERT_MSG_EQ (m_newValue, -1, "Trace 0 did not fire as expected");
737  NS_TEST_ASSERT_MSG_EQ (m_path, "/NodeA/NodeB/NodesB/0/Source", "Trace 0 did not provide expected context");
738 
739  //
740  // If we bug the trace source referred to by index '1' above, we should see
741  // the trace fire with the expected context path.
742  //
743  m_newValue = 0;
744  m_path = "";
745  obj1->SetAttribute ("Source", IntegerValue (-2));
746  NS_TEST_ASSERT_MSG_EQ (m_newValue, -2, "Trace 1 did not fire as expected");
747  NS_TEST_ASSERT_MSG_EQ (m_path, "/NodeA/NodeB/NodesB/1/Source", "Trace 1 did not provide expected context");
748 
749  //
750  // If we bug the trace source referred to by index '2' which is skipped above,
751  // we should not see the trace fire.
752  //
753  m_newValue = 0;
754  m_path = "";
755  obj2->SetAttribute ("Source", IntegerValue (-3));
756  NS_TEST_ASSERT_MSG_EQ (m_newValue, 0, "Trace 2 fired unexpectedly");
757 
758  //
759  // If we bug the trace source referred to by index '3' above, we should see
760  // the trace fire with the expected context path.
761  //
762  m_newValue = 0;
763  m_path = "";
764  obj3->SetAttribute ("Source", IntegerValue (-4));
765  NS_TEST_ASSERT_MSG_EQ (m_newValue, -4, "Trace 3 did not fire as expected");
766  NS_TEST_ASSERT_MSG_EQ (m_path, "/NodeA/NodeB/NodesB/1/Source", "Trace 1 did not provide expected context");
767 }
768 
778 {
779 public:
784 
785 private:
786  virtual void DoRun (void);
787 
788 };
789 
791  : TestCase ("Check that attributes of base class are searchable from paths including objects of derived class")
792 {
793 }
794 
795 void
797 {
798  IntegerValue iv;
799  //
800  // Create a root namespace object that doesn't have attributes but
801  // whose parent class has 'NodeA' attribute
802  //
803  Ptr<DerivedConfigTestObject> root = CreateObject<DerivedConfigTestObject> ();
805 
806  //
807  // Instantiate /NodeA
808  //
809  Ptr<DerivedConfigTestObject> a = CreateObject<DerivedConfigTestObject> ();
810  root->SetNodeA (a);
811 
812  //
813  // BaseConfigObject has attribute X, but we aggregate DerivedConfigObject
814  // instead
815  //
816  Ptr<DerivedConfigObject> derived = CreateObject<DerivedConfigObject> ();
817  a->AggregateObject (derived);
818  Config::Set ("/NodeA/$DerivedConfigObject/X", IntegerValue (42));
819  derived->GetAttribute ("X", iv);
820  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 42, "Object Attribute \"X\" not settable in derived class");
821 
822 }
823 
829 {
830 public:
832  ConfigTestSuite ();
833 };
834 
836  : TestSuite ("config")
837 {
842 }
843 
849 
850 
851  } // namespace tests
852 
853 } // namespace ns3
854 
static TypeId GetTypeId(void)
Get the type ID.
static TypeId GetTypeId(void)
Get the type ID.
void TraceWithPath(std::string path, int16_t old, int16_t newValue)
Trace callback with context path.
Test for the ability to register and use a root namespace.
void AddNodeA(Ptr< ConfigTestObject > a)
Add node A function.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
BaseConfigObject(void)
Constructor.
virtual ~BaseConfigObject(void)
Destructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~RootNamespaceConfigTestCase()
Destructor.
static TypeId GetTypeId(void)
Get the type ID.
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:777
A suite of tests to run.
Definition: test.h:1342
static TypeId GetTypeId(void)
Get the type ID.
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Definition: object-vector.h:81
static ConfigTestSuite g_configTestSuite
ConfigTestSuite instance variable.
Hold a signed integer type.
Definition: integer.h:44
void SetNodeA(Ptr< ConfigTestObject > a)
Set node A function.
Test for the ability to search attributes of parent classes when Resolver searches for attributes in ...
Test for the ability to trace configure with vectors of objects.
encapsulates test code
Definition: test.h:1155
virtual ~ObjectVectorConfigTestCase()
Destructor.
void RegisterRootNamespaceObject(Ptr< Object > obj)
Definition: config.cc:860
Ptr< ConfigTestObject > m_nodeB
NodeB attribute target.
virtual void DoRun(void)
Implementation to actually run this TestCase.
int8_t GetA(void) const
Get node A function.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
int8_t m_a
A attribute target.
The Test Suite that glues all of the Test Cases together.
Test for the ability to add an object under the root namespace.
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: integer.h:45
int64_t Get(void) const
Definition: integer.cc:35
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: pointer.h:220
virtual void DoRun(void)
Implementation to actually run this TestCase.
std::vector< Ptr< ConfigTestObject > > m_nodesA
NodesA attribute target.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
Ptr< ConfigTestObject > m_nodeA
NodeA attribute target.
TracedValue< int16_t > m_trace
Source TraceSource target.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition: test.h:168
void SetNodeB(Ptr< ConfigTestObject > b)
Set node b function.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:832
virtual ~DerivedConfigObject(void)
Destructor.
void AddNodeB(Ptr< ConfigTestObject > b)
Add node B function.
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:843
An object with some attributes that we can play with using config.
void Increment(void)
Silence unused variable warning.
int8_t m_b
B attribute target.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hold objects of type Ptr.
Definition: pointer.h:36
std::vector< Ptr< ConfigTestObject > > m_nodesB
NodesB attribute target.
int8_t GetB(void) const
Get node b function.
int8_t m_x
X attribute target.
int16_t m_newValue
Flag to detect tracing result.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~DerivedConfigTestObject(void)
Destructor.
A base class which provides memory management and object aggregation.
Definition: object.h:87
virtual void DoRun(void)
Implementation to actually run this TestCase.
Container for a set of ns3::Object pointers.
Test for the ability to deal configure with vectors of objects.
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:914
void Trace(int16_t oldValue, int16_t newValue)
Trace callback without context.