A Discrete-Event Network Simulator
API
config.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 "config.h"
21 #include "singleton.h"
22 #include "object.h"
23 #include "global-value.h"
24 #include "object-ptr-container.h"
25 #include "names.h"
26 #include "pointer.h"
27 #include "log.h"
28 
29 #include <sstream>
30 
37 namespace ns3 {
38 
39 NS_LOG_COMPONENT_DEFINE ("Config");
40 
41 namespace Config {
42 
44 {
45  NS_LOG_FUNCTION (this);
46 }
47 MatchContainer::MatchContainer (const std::vector<Ptr<Object> > &objects,
48  const std::vector<std::string> &contexts,
49  std::string path)
50  : m_objects (objects),
51  m_contexts (contexts),
52  m_path (path)
53 {
54  NS_LOG_FUNCTION (this << &objects << &contexts << path);
55 }
58 {
59  NS_LOG_FUNCTION (this);
60  return m_objects.begin ();
61 }
63 MatchContainer::End (void) const
64 {
65  NS_LOG_FUNCTION (this);
66  return m_objects.end ();
67 }
68 uint32_t
70 {
71  NS_LOG_FUNCTION (this);
72  return m_objects.size ();
73 }
75 MatchContainer::Get (uint32_t i) const
76 {
77  NS_LOG_FUNCTION (this << i);
78  return m_objects[i];
79 }
80 std::string
82 {
83  NS_LOG_FUNCTION (this << i);
84  return m_contexts[i];
85 }
86 std::string
88 {
89  NS_LOG_FUNCTION (this);
90  return m_path;
91 }
92 
93 void
94 MatchContainer::Set (std::string name, const AttributeValue &value)
95 {
96  NS_LOG_FUNCTION (this << name << &value);
97  for (Iterator tmp = Begin (); tmp != End (); ++tmp)
98  {
99  Ptr<Object> object = *tmp;
100  object->SetAttribute (name, value);
101  }
102 }
103 void
104 MatchContainer::Connect (std::string name, const CallbackBase &cb)
105 {
106  NS_LOG_FUNCTION (this << name << &cb);
107  NS_ASSERT (m_objects.size () == m_contexts.size ());
108  for (uint32_t i = 0; i < m_objects.size (); ++i)
109  {
110  Ptr<Object> object = m_objects[i];
111  std::string ctx = m_contexts[i] + name;
112  object->TraceConnect (name, ctx, cb);
113  }
114 }
115 void
117 {
118  NS_LOG_FUNCTION (this << name << &cb);
119 
120  for (Iterator tmp = Begin (); tmp != End (); ++tmp)
121  {
122  Ptr<Object> object = *tmp;
123  object->TraceConnectWithoutContext (name, cb);
124  }
125 }
126 void
127 MatchContainer::Disconnect (std::string name, const CallbackBase &cb)
128 {
129  NS_LOG_FUNCTION (this << name << &cb);
130  NS_ASSERT (m_objects.size () == m_contexts.size ());
131  for (uint32_t i = 0; i < m_objects.size (); ++i)
132  {
133  Ptr<Object> object = m_objects[i];
134  std::string ctx = m_contexts[i] + name;
135  object->TraceDisconnect (name, ctx, cb);
136  }
137 }
138 void
140 {
141  NS_LOG_FUNCTION (this << name << &cb);
142  for (Iterator tmp = Begin (); tmp != End (); ++tmp)
143  {
144  Ptr<Object> object = *tmp;
145  object->TraceDisconnectWithoutContext (name, cb);
146  }
147 }
148 
149 } // namespace Config
150 
152 {
153 public:
154  ArrayMatcher (std::string element);
155  bool Matches (uint32_t i) const;
156 private:
157  bool StringToUint32 (std::string str, uint32_t *value) const;
158  std::string m_element;
159 };
160 
161 
162 ArrayMatcher::ArrayMatcher (std::string element)
163  : m_element (element)
164 {
165  NS_LOG_FUNCTION (this << element);
166 }
167 bool
168 ArrayMatcher::Matches (uint32_t i) const
169 {
170  NS_LOG_FUNCTION (this << i);
171  if (m_element == "*")
172  {
173  NS_LOG_DEBUG ("Array "<<i<<" matches *");
174  return true;
175  }
176  std::string::size_type tmp;
177  tmp = m_element.find ("|");
178  if (tmp != std::string::npos)
179  {
180  std::string left = m_element.substr (0, tmp-0);
181  std::string right = m_element.substr (tmp+1, m_element.size () - (tmp + 1));
182  ArrayMatcher matcher = ArrayMatcher (left);
183  if (matcher.Matches (i))
184  {
185  NS_LOG_DEBUG ("Array "<<i<<" matches "<<left);
186  return true;
187  }
188  matcher = ArrayMatcher (right);
189  if (matcher.Matches (i))
190  {
191  NS_LOG_DEBUG ("Array "<<i<<" matches "<<right);
192  return true;
193  }
194  NS_LOG_DEBUG ("Array "<<i<<" does not match "<<m_element);
195  return false;
196  }
197  std::string::size_type leftBracket = m_element.find ("[");
198  std::string::size_type rightBracket = m_element.find ("]");
199  std::string::size_type dash = m_element.find ("-");
200  if (leftBracket == 0 && rightBracket == m_element.size () - 1 &&
201  dash > leftBracket && dash < rightBracket)
202  {
203  std::string lowerBound = m_element.substr (leftBracket + 1, dash - (leftBracket + 1));
204  std::string upperBound = m_element.substr (dash + 1, rightBracket - (dash + 1));
205  uint32_t min;
206  uint32_t max;
207  if (StringToUint32 (lowerBound, &min) &&
208  StringToUint32 (upperBound, &max) &&
209  i >= min && i <= max)
210  {
211  NS_LOG_DEBUG ("Array "<<i<<" matches "<<m_element);
212  return true;
213  }
214  else
215  {
216  NS_LOG_DEBUG ("Array "<<i<<" does not "<<m_element);
217  return false;
218  }
219  }
220  uint32_t value;
221  if (StringToUint32 (m_element, &value) &&
222  i == value)
223  {
224  NS_LOG_DEBUG ("Array "<<i<<" matches "<<m_element);
225  return true;
226  }
227  NS_LOG_DEBUG ("Array "<<i<<" does not match "<<m_element);
228  return false;
229 }
230 
231 bool
232 ArrayMatcher::StringToUint32 (std::string str, uint32_t *value) const
233 {
234  NS_LOG_FUNCTION (this << str << value);
235  std::istringstream iss;
236  iss.str (str);
237  iss >> (*value);
238  return !iss.bad () && !iss.fail ();
239 }
240 
241 
242 class Resolver
243 {
244 public:
245  Resolver (std::string path);
246  virtual ~Resolver ();
247 
248  void Resolve (Ptr<Object> root);
249 private:
250  void Canonicalize (void);
251  void DoResolve (std::string path, Ptr<Object> root);
252  void DoArrayResolve (std::string path, const ObjectPtrContainerValue &vector);
253  void DoResolveOne (Ptr<Object> object);
254  std::string GetResolvedPath (void) const;
255  virtual void DoOne (Ptr<Object> object, std::string path) = 0;
256  std::vector<std::string> m_workStack;
257  std::string m_path;
258 };
259 
260 Resolver::Resolver (std::string path)
261  : m_path (path)
262 {
263  NS_LOG_FUNCTION (this << path);
264  Canonicalize ();
265 }
267 {
268  NS_LOG_FUNCTION (this);
269 }
270 void
272 {
273  NS_LOG_FUNCTION (this);
274 
275  // ensure that we start and end with a '/'
276  std::string::size_type tmp = m_path.find ("/");
277  if (tmp != 0)
278  {
279  // no slash at start
280  m_path = "/" + m_path;
281  }
282  tmp = m_path.find_last_of ("/");
283  if (tmp != (m_path.size () - 1))
284  {
285  // no slash at end
286  m_path = m_path + "/";
287  }
288 }
289 
290 void
292 {
293  NS_LOG_FUNCTION (this << root);
294 
295  DoResolve (m_path, root);
296 }
297 
298 std::string
300 {
301  NS_LOG_FUNCTION (this);
302 
303  std::string fullPath = "/";
304  for (std::vector<std::string>::const_iterator i = m_workStack.begin (); i != m_workStack.end (); i++)
305  {
306  fullPath += *i + "/";
307  }
308  return fullPath;
309 }
310 
311 void
313 {
314  NS_LOG_FUNCTION (this << object);
315 
316  NS_LOG_DEBUG ("resolved="<<GetResolvedPath ());
317  DoOne (object, GetResolvedPath ());
318 }
319 
320 void
321 Resolver::DoResolve (std::string path, Ptr<Object> root)
322 {
323  NS_LOG_FUNCTION (this << path << root);
324  NS_ASSERT ((path.find ("/")) == 0);
325  std::string::size_type next = path.find ("/", 1);
326 
327  if (next == std::string::npos)
328  {
329  //
330  // If root is zero, we're beginning to see if we can use the object name
331  // service to resolve this path. It is impossible to have a object name
332  // associated with the root of the object name service since that root
333  // is not an object. This path must be referring to something in another
334  // namespace and it will have been found already since the name service
335  // is always consulted last.
336  //
337  if (root)
338  {
339  DoResolveOne (root);
340  }
341  return;
342  }
343  std::string item = path.substr (1, next-1);
344  std::string pathLeft = path.substr (next, path.size ()-next);
345 
346  //
347  // If root is zero, we're beginning to see if we can use the object name
348  // service to resolve this path. In this case, we must see the name space
349  // "/Names" on the front of this path. There is no object associated with
350  // the root of the "/Names" namespace, so we just ignore it and move on to
351  // the next segment.
352  //
353  if (root == 0)
354  {
355  std::string::size_type offset = path.find ("/Names");
356  if (offset == 0)
357  {
358  m_workStack.push_back (item);
359  DoResolve (pathLeft, root);
360  m_workStack.pop_back ();
361  return;
362  }
363  }
364 
365  //
366  // We have an item (possibly a segment of a namespace path. Check to see if
367  // we can determine that this segment refers to a named object. If root is
368  // zero, this means to look in the root of the "/Names" name space, otherwise
369  // it refers to a name space context (level).
370  //
371  Ptr<Object> namedObject = Names::Find<Object> (root, item);
372  if (namedObject)
373  {
374  NS_LOG_DEBUG ("Name system resolved item = " << item << " to " << namedObject);
375  m_workStack.push_back (item);
376  DoResolve (pathLeft, namedObject);
377  m_workStack.pop_back ();
378  return;
379  }
380 
381  //
382  // We're done with the object name service hooks, so proceed down the path
383  // of types and attributes; but only if root is nonzero. If root is zero
384  // and we find ourselves here, we are trying to check in the namespace for
385  // a path that is not in the "/Names" namespace. We will have previously
386  // found any matches, so we just bail out.
387  //
388  if (root == 0)
389  {
390  return;
391  }
392  std::string::size_type dollarPos = item.find ("$");
393  if (dollarPos == 0)
394  {
395  // This is a call to GetObject
396  std::string tidString = item.substr (1, item.size () - 1);
397  NS_LOG_DEBUG ("GetObject="<<tidString<<" on path="<<GetResolvedPath ());
398  TypeId tid = TypeId::LookupByName (tidString);
399  Ptr<Object> object = root->GetObject<Object> (tid);
400  if (object == 0)
401  {
402  NS_LOG_DEBUG ("GetObject ("<<tidString<<") failed on path="<<GetResolvedPath ());
403  return;
404  }
405  m_workStack.push_back (item);
406  DoResolve (pathLeft, object);
407  m_workStack.pop_back ();
408  }
409  else
410  {
411  // this is a normal attribute.
412  TypeId tid;
413  TypeId nextTid = root->GetInstanceTypeId ();
414  bool foundMatch = false;
415 
416  do
417  {
418  tid = nextTid;
419 
420  for (uint32_t i = 0; i < tid.GetAttributeN(); i++)
421  {
422  struct TypeId::AttributeInformation info;
423  info = tid.GetAttribute(i);
424  if (info.name != item && item != "*")
425  {
426  continue;
427  }
428  // attempt to cast to a pointer checker.
429  const PointerChecker *ptr = dynamic_cast<const PointerChecker *> (PeekPointer (info.checker));
430  if (ptr != 0)
431  {
432  NS_LOG_DEBUG ("GetAttribute(ptr)="<<info.name<<" on path="<<GetResolvedPath ());
433  PointerValue ptr;
434  root->GetAttribute (info.name, ptr);
435  Ptr<Object> object = ptr.Get<Object> ();
436  if (object == 0)
437  {
438  NS_LOG_ERROR ("Requested object name=\""<<item<<
439  "\" exists on path=\""<<GetResolvedPath ()<<"\""
440  " but is null.");
441  continue;
442  }
443  foundMatch = true;
444  m_workStack.push_back (info.name);
445  DoResolve (pathLeft, object);
446  m_workStack.pop_back ();
447  }
448  // attempt to cast to an object vector.
449  const ObjectPtrContainerChecker *vectorChecker =
450  dynamic_cast<const ObjectPtrContainerChecker *> (PeekPointer (info.checker));
451  if (vectorChecker != 0)
452  {
453  NS_LOG_DEBUG ("GetAttribute(vector)="<<info.name<<" on path="<<GetResolvedPath () << pathLeft);
454  foundMatch = true;
456  root->GetAttribute (info.name, vector);
457  m_workStack.push_back (info.name);
458  DoArrayResolve (pathLeft, vector);
459  m_workStack.pop_back ();
460  }
461  // this could be anything else and we don't know what to do with it.
462  // So, we just ignore it.
463  }
464 
465  nextTid = tid.GetParent ();
466  } while (nextTid != tid);
467 
468  if (!foundMatch)
469  {
470  NS_LOG_DEBUG ("Requested item="<<item<<" does not exist on path="<<GetResolvedPath ());
471  return;
472  }
473  }
474 }
475 
476 void
477 Resolver::DoArrayResolve (std::string path, const ObjectPtrContainerValue &container)
478 {
479  NS_LOG_FUNCTION(this << path << &container);
480  NS_ASSERT (path != "");
481  NS_ASSERT ((path.find ("/")) == 0);
482  std::string::size_type next = path.find ("/", 1);
483  if (next == std::string::npos)
484  {
485  return;
486  }
487  std::string item = path.substr (1, next-1);
488  std::string pathLeft = path.substr (next, path.size ()-next);
489 
490  ArrayMatcher matcher = ArrayMatcher (item);
492  for (it = container.Begin (); it != container.End (); ++it)
493  {
494  if (matcher.Matches ((*it).first))
495  {
496  std::ostringstream oss;
497  oss << (*it).first;
498  m_workStack.push_back (oss.str ());
499  DoResolve (pathLeft, (*it).second);
500  m_workStack.pop_back ();
501  }
502  }
503 }
504 
505 
507 {
508 public:
509  void Set (std::string path, const AttributeValue &value);
510  void ConnectWithoutContext (std::string path, const CallbackBase &cb);
511  void Connect (std::string path, const CallbackBase &cb);
512  void DisconnectWithoutContext (std::string path, const CallbackBase &cb);
513  void Disconnect (std::string path, const CallbackBase &cb);
514  Config::MatchContainer LookupMatches (std::string path);
515 
518 
519  uint32_t GetRootNamespaceObjectN (void) const;
520  Ptr<Object> GetRootNamespaceObject (uint32_t i) const;
521 
522 private:
523  void ParsePath (std::string path, std::string *root, std::string *leaf) const;
524  typedef std::vector<Ptr<Object> > Roots;
525  Roots m_roots;
526 };
527 
528 void
529 ConfigImpl::ParsePath (std::string path, std::string *root, std::string *leaf) const
530 {
531  NS_LOG_FUNCTION (this << path << root << leaf);
532 
533  std::string::size_type slash = path.find_last_of ("/");
534  NS_ASSERT (slash != std::string::npos);
535  *root = path.substr (0, slash);
536  *leaf = path.substr (slash+1, path.size ()-(slash+1));
537  NS_LOG_FUNCTION (path << *root << *leaf);
538 }
539 
540 void
541 ConfigImpl::Set (std::string path, const AttributeValue &value)
542 {
543  NS_LOG_FUNCTION (this << path << &value);
544 
545  std::string root, leaf;
546  ParsePath (path, &root, &leaf);
547  Config::MatchContainer container = LookupMatches (root);
548  container.Set (leaf, value);
549 }
550 void
551 ConfigImpl::ConnectWithoutContext (std::string path, const CallbackBase &cb)
552 {
553  NS_LOG_FUNCTION (this << path << &cb);
554  std::string root, leaf;
555  ParsePath (path, &root, &leaf);
556  Config::MatchContainer container = LookupMatches (root);
557  container.ConnectWithoutContext (leaf, cb);
558 }
559 void
561 {
562  NS_LOG_FUNCTION (this << path << &cb);
563  std::string root, leaf;
564  ParsePath (path, &root, &leaf);
565  Config::MatchContainer container = LookupMatches (root);
566  container.DisconnectWithoutContext (leaf, cb);
567 }
568 void
569 ConfigImpl::Connect (std::string path, const CallbackBase &cb)
570 {
571  NS_LOG_FUNCTION (this << path << &cb);
572 
573  std::string root, leaf;
574  ParsePath (path, &root, &leaf);
575  Config::MatchContainer container = LookupMatches (root);
576  container.Connect (leaf, cb);
577 }
578 void
579 ConfigImpl::Disconnect (std::string path, const CallbackBase &cb)
580 {
581  NS_LOG_FUNCTION (this << path << &cb);
582 
583  std::string root, leaf;
584  ParsePath (path, &root, &leaf);
585  Config::MatchContainer container = LookupMatches (root);
586  container.Disconnect (leaf, cb);
587 }
588 
590 ConfigImpl::LookupMatches (std::string path)
591 {
592  NS_LOG_FUNCTION (this << path);
593  class LookupMatchesResolver : public Resolver
594  {
595  public:
596  LookupMatchesResolver (std::string path)
597  : Resolver (path)
598  {}
599  virtual void DoOne (Ptr<Object> object, std::string path) {
600  m_objects.push_back (object);
601  m_contexts.push_back (path);
602  }
603  std::vector<Ptr<Object> > m_objects;
604  std::vector<std::string> m_contexts;
605  } resolver = LookupMatchesResolver (path);
606  for (Roots::const_iterator i = m_roots.begin (); i != m_roots.end (); i++)
607  {
608  resolver.Resolve (*i);
609  }
610 
611  //
612  // See if we can do something with the object name service. Starting with
613  // the root pointer zeroed indicates to the resolver that it should start
614  // looking at the root of the "/Names" namespace during this go.
615  //
616  resolver.Resolve (0);
617 
618  return Config::MatchContainer (resolver.m_objects, resolver.m_contexts, path);
619 }
620 
621 void
623 {
624  NS_LOG_FUNCTION (this << obj);
625  m_roots.push_back (obj);
626 }
627 
628 void
630 {
631  NS_LOG_FUNCTION (this << obj);
632 
633  for (std::vector<Ptr<Object> >::iterator i = m_roots.begin (); i != m_roots.end (); i++)
634  {
635  if (*i == obj)
636  {
637  m_roots.erase (i);
638  return;
639  }
640  }
641 }
642 
643 uint32_t
645 {
646  NS_LOG_FUNCTION (this);
647  return m_roots.size ();
648 }
651 {
652  NS_LOG_FUNCTION (this << i);
653  return m_roots[i];
654 }
655 
656 namespace Config {
657 
658 void Reset (void)
659 {
661  // First, let's reset the initial value of every attribute
662  for (uint32_t i = 0; i < TypeId::GetRegisteredN (); i++)
663  {
664  TypeId tid = TypeId::GetRegistered (i);
665  for (uint32_t j = 0; j < tid.GetAttributeN (); j++)
666  {
667  struct TypeId::AttributeInformation info = tid.GetAttribute (j);
669  }
670  }
671  // now, let's reset the initial value of every global value.
673  {
674  (*i)->ResetInitialValue ();
675  }
676 }
677 
678 void Set (std::string path, const AttributeValue &value)
679 {
680  NS_LOG_FUNCTION (path << &value);
681  Singleton<ConfigImpl>::Get ()->Set (path, value);
682 }
683 void SetDefault (std::string name, const AttributeValue &value)
684 {
685  NS_LOG_FUNCTION (name << &value);
686  if (!SetDefaultFailSafe(name, value))
687  {
688  NS_FATAL_ERROR ("Could not set default value for " << name);
689  }
690 }
691 bool SetDefaultFailSafe (std::string fullName, const AttributeValue &value)
692 {
693  NS_LOG_FUNCTION (fullName << &value);
694  std::string::size_type pos = fullName.rfind ("::");
695  if (pos == std::string::npos)
696  {
697  return false;
698  }
699  std::string tidName = fullName.substr (0, pos);
700  std::string paramName = fullName.substr (pos+2, fullName.size () - (pos+2));
701  TypeId tid;
702  bool ok = TypeId::LookupByNameFailSafe (tidName, &tid);
703  if (!ok)
704  {
705  return false;
706  }
707  for (uint32_t j = 0; j < tid.GetAttributeN (); j++)
708  {
709  struct TypeId::AttributeInformation tmp = tid.GetAttribute(j);
710  if (tmp.name == paramName)
711  {
712  Ptr<AttributeValue> v = tmp.checker->CreateValidValue (value);
713  if (v == 0)
714  {
715  return false;
716  }
717  tid.SetAttributeInitialValue (j, v);
718  return true;
719  }
720  }
721  return false;
722 }
723 void SetGlobal (std::string name, const AttributeValue &value)
724 {
725  NS_LOG_FUNCTION (name << &value);
726  GlobalValue::Bind (name, value);
727 }
728 bool SetGlobalFailSafe (std::string name, const AttributeValue &value)
729 {
730  NS_LOG_FUNCTION (name << &value);
731  return GlobalValue::BindFailSafe (name, value);
732 }
733 void ConnectWithoutContext (std::string path, const CallbackBase &cb)
734 {
735  NS_LOG_FUNCTION (path << &cb);
736  Singleton<ConfigImpl>::Get ()->ConnectWithoutContext (path, cb);
737 }
738 void DisconnectWithoutContext (std::string path, const CallbackBase &cb)
739 {
740  NS_LOG_FUNCTION (path << &cb);
741  Singleton<ConfigImpl>::Get ()->DisconnectWithoutContext (path, cb);
742 }
743 void
744 Connect (std::string path, const CallbackBase &cb)
745 {
746  NS_LOG_FUNCTION (path << &cb);
747  Singleton<ConfigImpl>::Get ()->Connect (path, cb);
748 }
749 void
750 Disconnect (std::string path, const CallbackBase &cb)
751 {
752  NS_LOG_FUNCTION (path << &cb);
753  Singleton<ConfigImpl>::Get ()->Disconnect (path, cb);
754 }
756 {
757  NS_LOG_FUNCTION (path);
758  return Singleton<ConfigImpl>::Get ()->LookupMatches (path);
759 }
760 
762 {
763  NS_LOG_FUNCTION (obj);
764  Singleton<ConfigImpl>::Get ()->RegisterRootNamespaceObject (obj);
765 }
766 
768 {
769  NS_LOG_FUNCTION (obj);
770  Singleton<ConfigImpl>::Get ()->UnregisterRootNamespaceObject (obj);
771 }
772 
773 uint32_t GetRootNamespaceObjectN (void)
774 {
776  return Singleton<ConfigImpl>::Get ()->GetRootNamespaceObjectN ();
777 }
778 
780 {
781  NS_LOG_FUNCTION (i);
782  return Singleton<ConfigImpl>::Get ()->GetRootNamespaceObject (i);
783 }
784 
785 } // namespace Config
786 
787 } // namespace ns3
uint32_t GetAttributeN(void) const
Definition: type-id.cc:780
uint32_t GetRootNamespaceObjectN(void) const
Definition: config.cc:644
Ptr< T > Get(void) const
Definition: pointer.h:184
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
ns3::Singleton declaration and template implementation.
bool SetDefaultFailSafe(std::string fullName, const AttributeValue &value)
Definition: config.cc:691
void DisconnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:560
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:678
bool SetGlobalFailSafe(std::string name, const AttributeValue &value)
Definition: config.cc:728
void UnregisterRootNamespaceObject(Ptr< Object > obj)
Definition: config.cc:767
Hold a value for an Attribute.
Definition: attribute.h:68
Ptr< const AttributeValue > originalInitialValue
Definition: type-id.h:73
void DoResolve(std::string path, Ptr< Object > root)
Definition: config.cc:321
std::string m_element
Definition: config.cc:158
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:562
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
TypeId GetParent(void) const
Definition: type-id.cc:659
Vector::const_iterator Iterator
Definition: global-value.h:58
Base class for Callback class.
Definition: callback.h:906
std::string GetMatchedPath(uint32_t i) const
Definition: config.cc:81
void Disconnect(std::string name, const CallbackBase &cb)
Definition: config.cc:127
void DisconnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:738
#define NS_FATAL_ERROR(msg)
Fatal error handling.
Definition: fatal-error.h:100
static bool LookupByNameFailSafe(std::string name, TypeId *tid)
Definition: type-id.cc:571
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
std::vector< Ptr< Object > > Roots
Definition: config.cc:524
Declaration of the various ns3::Config functions and classes.
static T * Get(void)
Get a pointer to the singleton instance.
Definition: singleton.h:97
void RegisterRootNamespaceObject(Ptr< Object > obj)
Definition: config.cc:761
std::vector< std::string > m_workStack
Definition: config.cc:256
std::map< uint32_t, Ptr< Object > >::const_iterator Iterator
Iterator type for traversing this container.
void UnregisterRootNamespaceObject(Ptr< Object > obj)
Definition: config.cc:629
MatchContainer::Iterator End(void) const
Definition: config.cc:63
virtual void DoOne(Ptr< Object > object, std::string path)=0
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:551
Config::MatchContainer LookupMatches(std::string path)
Definition: config.cc:590
void ConnectWithoutContext(std::string name, const CallbackBase &cb)
Definition: config.cc:116
ObjectPtrContainer attribute value declarations and template implementations.
static uint32_t GetRegisteredN(void)
Definition: type-id.cc:603
static Iterator Begin(void)
Ptr< Object > GetRootNamespaceObject(uint32_t i)
Definition: config.cc:779
void Resolve(Ptr< Object > root)
Definition: config.cc:291
AttributeChecker implementation for ObjectPtrContainerValue.
bool TraceDisconnectWithoutContext(std::string name, const CallbackBase &cb)
Disconnect from a TraceSource a Callback previously connected without a context.
Definition: object-base.cc:324
static TypeId GetRegistered(uint32_t i)
Definition: type-id.cc:609
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:733
static void Bind(std::string name, const AttributeValue &value)
void ParsePath(std::string path, std::string *root, std::string *leaf) const
Definition: config.cc:529
uint32_t GetRootNamespaceObjectN(void)
Definition: config.cc:773
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:569
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:744
void DoResolveOne(Ptr< Object > object)
Definition: config.cc:312
uint32_t GetN(void) const
Definition: config.cc:69
void Disconnect(std::string path, const CallbackBase &cb)
Definition: config.cc:579
Ptr< const AttributeChecker > checker
Definition: type-id.h:76
void DoArrayResolve(std::string path, const ObjectPtrContainerValue &vector)
Definition: config.cc:477
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:298
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hold objects of type Ptr.
Definition: pointer.h:36
Ptr< Object > Get(uint32_t i) const
Definition: config.cc:75
Iterator Begin(void) const
Get an iterator to the first Object.
ns3::GlobalValue declaration.
hold a set of objects which match a specific search string.
Definition: config.h:150
std::vector< Ptr< Object > > m_objects
Definition: config.h:236
std::string m_path
Definition: config.cc:257
void Connect(std::string name, const CallbackBase &cb)
Definition: config.cc:104
void Reset(void)
Reset the initial value of every attribute as well as the value of every global to what they were bef...
Definition: config.cc:658
bool SetAttributeInitialValue(uint32_t i, Ptr< const AttributeValue > initialValue)
Definition: type-id.cc:754
Config::MatchContainer LookupMatches(std::string path)
Definition: config.cc:755
ns3::Object class declaration, which is the root of the Object hierarchy and Aggregation.
void DisconnectWithoutContext(std::string name, const CallbackBase &cb)
Definition: config.cc:139
virtual ~Resolver()
Definition: config.cc:266
AttributeChecker implementation for PointerValue.
Definition: pointer.h:93
void SetGlobal(std::string name, const AttributeValue &value)
Definition: config.cc:723
std::vector< std::string > m_contexts
Definition: config.h:237
static Iterator End(void)
static bool BindFailSafe(std::string name, const AttributeValue &value)
void Canonicalize(void)
Definition: config.cc:271
void RegisterRootNamespaceObject(Ptr< Object > obj)
Definition: config.cc:622
Iterator End(void) const
Get an iterator to the past-the-end Object.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:236
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:683
bool Matches(uint32_t i) const
Definition: config.cc:168
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:541
Declaration of class ns3::Names.
std::vector< Ptr< Object > >::const_iterator Iterator
Definition: config.h:153
std::string GetResolvedPath(void) const
Definition: config.cc:299
bool StringToUint32(std::string str, uint32_t *value) const
Definition: config.cc:232
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:220
void Set(std::string name, const AttributeValue &value)
Definition: config.cc:94
A base class which provides memory management and object aggregation.
Definition: object.h:87
MatchContainer::Iterator Begin(void) const
Definition: config.cc:57
Container for a set of ns3::Object pointers.
ArrayMatcher(std::string element)
Definition: config.cc:162
struct TypeId::AttributeInformation GetAttribute(uint32_t i) const
Definition: type-id.cc:787
Debug message logging.
Ptr< Object > GetRootNamespaceObject(uint32_t i) const
Definition: config.cc:650
void Disconnect(std::string path, const CallbackBase &cb)
Definition: config.cc:750
std::string GetPath(void) const
Definition: config.cc:87
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:190
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:455
Pointer attribute value declarations and template implementations.
a unique identifier for an interface.
Definition: type-id.h:57
Resolver(std::string path)
Definition: config.cc:260
Roots m_roots
Definition: config.cc:525
static TypeId LookupByName(std::string name)
Definition: type-id.cc:563