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