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 = root->GetInstanceTypeId ();
407  bool foundMatch = false;
408  for (uint32_t i = 0; i < tid.GetAttributeN(); i++)
409  {
410  struct TypeId::AttributeInformation info;
411  info = tid.GetAttribute(i);
412  if (info.name != item && item != "*")
413  {
414  continue;
415  }
416  // attempt to cast to a pointer checker.
417  const PointerChecker *ptr = dynamic_cast<const PointerChecker *> (PeekPointer (info.checker));
418  if (ptr != 0)
419  {
420  NS_LOG_DEBUG ("GetAttribute(ptr)="<<info.name<<" on path="<<GetResolvedPath ());
421  PointerValue ptr;
422  root->GetAttribute (info.name, ptr);
423  Ptr<Object> object = ptr.Get<Object> ();
424  if (object == 0)
425  {
426  NS_LOG_ERROR ("Requested object name=\""<<item<<
427  "\" exists on path=\""<<GetResolvedPath ()<<"\""
428  " but is null.");
429  continue;
430  }
431  foundMatch = true;
432  m_workStack.push_back (info.name);
433  DoResolve (pathLeft, object);
434  m_workStack.pop_back ();
435  }
436  // attempt to cast to an object vector.
437  const ObjectPtrContainerChecker *vectorChecker =
438  dynamic_cast<const ObjectPtrContainerChecker *> (PeekPointer (info.checker));
439  if (vectorChecker != 0)
440  {
441  NS_LOG_DEBUG ("GetAttribute(vector)="<<info.name<<" on path="<<GetResolvedPath () << pathLeft);
442  foundMatch = true;
444  root->GetAttribute (info.name, vector);
445  m_workStack.push_back (info.name);
446  DoArrayResolve (pathLeft, vector);
447  m_workStack.pop_back ();
448  }
449  // this could be anything else and we don't know what to do with it.
450  // So, we just ignore it.
451  }
452  if (!foundMatch)
453  {
454  NS_LOG_DEBUG ("Requested item="<<item<<" does not exist on path="<<GetResolvedPath ());
455  return;
456  }
457  }
458 }
459 
460 void
461 Resolver::DoArrayResolve (std::string path, const ObjectPtrContainerValue &container)
462 {
463  NS_LOG_FUNCTION(this << path << &container);
464  NS_ASSERT (path != "");
465  NS_ASSERT ((path.find ("/")) == 0);
466  std::string::size_type next = path.find ("/", 1);
467  if (next == std::string::npos)
468  {
469  return;
470  }
471  std::string item = path.substr (1, next-1);
472  std::string pathLeft = path.substr (next, path.size ()-next);
473 
474  ArrayMatcher matcher = ArrayMatcher (item);
476  for (it = container.Begin (); it != container.End (); ++it)
477  {
478  if (matcher.Matches ((*it).first))
479  {
480  std::ostringstream oss;
481  oss << (*it).first;
482  m_workStack.push_back (oss.str ());
483  DoResolve (pathLeft, (*it).second);
484  m_workStack.pop_back ();
485  }
486  }
487 }
488 
489 
491 {
492 public:
493  void Set (std::string path, const AttributeValue &value);
494  void ConnectWithoutContext (std::string path, const CallbackBase &cb);
495  void Connect (std::string path, const CallbackBase &cb);
496  void DisconnectWithoutContext (std::string path, const CallbackBase &cb);
497  void Disconnect (std::string path, const CallbackBase &cb);
498  Config::MatchContainer LookupMatches (std::string path);
499 
502 
503  uint32_t GetRootNamespaceObjectN (void) const;
504  Ptr<Object> GetRootNamespaceObject (uint32_t i) const;
505 
506 private:
507  void ParsePath (std::string path, std::string *root, std::string *leaf) const;
508  typedef std::vector<Ptr<Object> > Roots;
510 };
511 
512 void
513 ConfigImpl::ParsePath (std::string path, std::string *root, std::string *leaf) const
514 {
515  NS_LOG_FUNCTION (this << path << root << leaf);
516 
517  std::string::size_type slash = path.find_last_of ("/");
518  NS_ASSERT (slash != std::string::npos);
519  *root = path.substr (0, slash);
520  *leaf = path.substr (slash+1, path.size ()-(slash+1));
521  NS_LOG_FUNCTION (path << *root << *leaf);
522 }
523 
524 void
525 ConfigImpl::Set (std::string path, const AttributeValue &value)
526 {
527  NS_LOG_FUNCTION (this << path << &value);
528 
529  std::string root, leaf;
530  ParsePath (path, &root, &leaf);
531  Config::MatchContainer container = LookupMatches (root);
532  container.Set (leaf, value);
533 }
534 void
535 ConfigImpl::ConnectWithoutContext (std::string path, const CallbackBase &cb)
536 {
537  NS_LOG_FUNCTION (this << path << &cb);
538  std::string root, leaf;
539  ParsePath (path, &root, &leaf);
540  Config::MatchContainer container = LookupMatches (root);
541  container.ConnectWithoutContext (leaf, cb);
542 }
543 void
545 {
546  NS_LOG_FUNCTION (this << path << &cb);
547  std::string root, leaf;
548  ParsePath (path, &root, &leaf);
549  Config::MatchContainer container = LookupMatches (root);
550  container.DisconnectWithoutContext (leaf, cb);
551 }
552 void
553 ConfigImpl::Connect (std::string path, const CallbackBase &cb)
554 {
555  NS_LOG_FUNCTION (this << path << &cb);
556 
557  std::string root, leaf;
558  ParsePath (path, &root, &leaf);
559  Config::MatchContainer container = LookupMatches (root);
560  container.Connect (leaf, cb);
561 }
562 void
563 ConfigImpl::Disconnect (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.Disconnect (leaf, cb);
571 }
572 
574 ConfigImpl::LookupMatches (std::string path)
575 {
576  NS_LOG_FUNCTION (this << path);
577  class LookupMatchesResolver : public Resolver
578  {
579  public:
580  LookupMatchesResolver (std::string path)
581  : Resolver (path)
582  {}
583  virtual void DoOne (Ptr<Object> object, std::string path) {
584  m_objects.push_back (object);
585  m_contexts.push_back (path);
586  }
587  std::vector<Ptr<Object> > m_objects;
588  std::vector<std::string> m_contexts;
589  } resolver = LookupMatchesResolver (path);
590  for (Roots::const_iterator i = m_roots.begin (); i != m_roots.end (); i++)
591  {
592  resolver.Resolve (*i);
593  }
594 
595  //
596  // See if we can do something with the object name service. Starting with
597  // the root pointer zeroed indicates to the resolver that it should start
598  // looking at the root of the "/Names" namespace during this go.
599  //
600  resolver.Resolve (0);
601 
602  return Config::MatchContainer (resolver.m_objects, resolver.m_contexts, path);
603 }
604 
605 void
607 {
608  NS_LOG_FUNCTION (this << obj);
609  m_roots.push_back (obj);
610 }
611 
612 void
614 {
615  NS_LOG_FUNCTION (this << obj);
616 
617  for (std::vector<Ptr<Object> >::iterator i = m_roots.begin (); i != m_roots.end (); i++)
618  {
619  if (*i == obj)
620  {
621  m_roots.erase (i);
622  return;
623  }
624  }
625 }
626 
627 uint32_t
629 {
630  NS_LOG_FUNCTION (this);
631  return m_roots.size ();
632 }
635 {
636  NS_LOG_FUNCTION (this << i);
637  return m_roots[i];
638 }
639 
640 namespace Config {
641 
642 void Reset (void)
643 {
645  // First, let's reset the initial value of every attribute
646  for (uint32_t i = 0; i < TypeId::GetRegisteredN (); i++)
647  {
648  TypeId tid = TypeId::GetRegistered (i);
649  for (uint32_t j = 0; j < tid.GetAttributeN (); j++)
650  {
651  struct TypeId::AttributeInformation info = tid.GetAttribute (j);
653  }
654  }
655  // now, let's reset the initial value of every global value.
657  {
658  (*i)->ResetInitialValue ();
659  }
660 }
661 
662 void Set (std::string path, const AttributeValue &value)
663 {
664  NS_LOG_FUNCTION (path << &value);
665  Singleton<ConfigImpl>::Get ()->Set (path, value);
666 }
667 void SetDefault (std::string name, const AttributeValue &value)
668 {
669  NS_LOG_FUNCTION (name << &value);
670  if (!SetDefaultFailSafe(name, value))
671  {
672  NS_FATAL_ERROR ("Could not set default value for " << name);
673  }
674 }
675 bool SetDefaultFailSafe (std::string fullName, const AttributeValue &value)
676 {
677  NS_LOG_FUNCTION (fullName << &value);
678  std::string::size_type pos = fullName.rfind ("::");
679  if (pos == std::string::npos)
680  {
681  return false;
682  }
683  std::string tidName = fullName.substr (0, pos);
684  std::string paramName = fullName.substr (pos+2, fullName.size () - (pos+2));
685  TypeId tid;
686  bool ok = TypeId::LookupByNameFailSafe (tidName, &tid);
687  if (!ok)
688  {
689  return false;
690  }
691  for (uint32_t j = 0; j < tid.GetAttributeN (); j++)
692  {
693  struct TypeId::AttributeInformation tmp = tid.GetAttribute(j);
694  if (tmp.name == paramName)
695  {
696  Ptr<AttributeValue> v = tmp.checker->CreateValidValue (value);
697  if (v == 0)
698  {
699  return false;
700  }
701  tid.SetAttributeInitialValue (j, v);
702  return true;
703  }
704  }
705  return false;
706 }
707 void SetGlobal (std::string name, const AttributeValue &value)
708 {
709  NS_LOG_FUNCTION (name << &value);
710  GlobalValue::Bind (name, value);
711 }
712 bool SetGlobalFailSafe (std::string name, const AttributeValue &value)
713 {
714  NS_LOG_FUNCTION (name << &value);
715  return GlobalValue::BindFailSafe (name, value);
716 }
717 void ConnectWithoutContext (std::string path, const CallbackBase &cb)
718 {
719  NS_LOG_FUNCTION (path << &cb);
720  Singleton<ConfigImpl>::Get ()->ConnectWithoutContext (path, cb);
721 }
722 void DisconnectWithoutContext (std::string path, const CallbackBase &cb)
723 {
724  NS_LOG_FUNCTION (path << &cb);
725  Singleton<ConfigImpl>::Get ()->DisconnectWithoutContext (path, cb);
726 }
727 void
728 Connect (std::string path, const CallbackBase &cb)
729 {
730  NS_LOG_FUNCTION (path << &cb);
731  Singleton<ConfigImpl>::Get ()->Connect (path, cb);
732 }
733 void
734 Disconnect (std::string path, const CallbackBase &cb)
735 {
736  NS_LOG_FUNCTION (path << &cb);
737  Singleton<ConfigImpl>::Get ()->Disconnect (path, cb);
738 }
740 {
741  NS_LOG_FUNCTION (path);
742  return Singleton<ConfigImpl>::Get ()->LookupMatches (path);
743 }
744 
746 {
747  NS_LOG_FUNCTION (obj);
748  Singleton<ConfigImpl>::Get ()->RegisterRootNamespaceObject (obj);
749 }
750 
752 {
753  NS_LOG_FUNCTION (obj);
754  Singleton<ConfigImpl>::Get ()->UnregisterRootNamespaceObject (obj);
755 }
756 
757 uint32_t GetRootNamespaceObjectN (void)
758 {
760  return Singleton<ConfigImpl>::Get ()->GetRootNamespaceObjectN ();
761 }
762 
764 {
765  NS_LOG_FUNCTION (i);
766  return Singleton<ConfigImpl>::Get ()->GetRootNamespaceObject (i);
767 }
768 
769 } // namespace Config
770 
771 } // namespace ns3
uint32_t GetAttributeN(void) const
Definition: type-id.cc:739
uint32_t GetRootNamespaceObjectN(void) const
Definition: config.cc:628
Ptr< T > Get(void) const
Definition: pointer.h:148
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
void DisconnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:544
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:642
NS_LOG_COMPONENT_DEFINE("Config")
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:734
#define NS_ASSERT(condition)
Definition: assert.h:64
Vector::const_iterator Iterator
Definition: global-value.h:51
Base class for Callback class.
Definition: callback.h:844
std::string GetMatchedPath(uint32_t i) const
Definition: config.cc:75
void Disconnect(std::string name, const CallbackBase &cb)
Definition: config.cc:121
static bool LookupByNameFailSafe(std::string name, TypeId *tid)
Definition: type-id.cc:544
void UnregisterRootNamespaceObject(Ptr< Object > obj)
Definition: config.cc:751
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition: log.h:309
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:662
std::vector< Ptr< Object > > Roots
Definition: config.cc:508
Ptr< Object > GetRootNamespaceObject(uint32_t i)
Definition: config.cc:763
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:728
static T * Get(void)
Definition: singleton.h:50
std::vector< std::string > m_workStack
Definition: config.cc:250
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
std::map< uint32_t, Ptr< Object > >::const_iterator Iterator
void UnregisterRootNamespaceObject(Ptr< Object > obj)
Definition: config.cc:613
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:535
bool SetDefaultFailSafe(std::string fullName, const AttributeValue &value)
Definition: config.cc:675
Config::MatchContainer LookupMatches(std::string path)
Definition: config.cc:574
Config::MatchContainer LookupMatches(std::string path)
Definition: config.cc:739
void ConnectWithoutContext(std::string name, const CallbackBase &cb)
Definition: config.cc:110
static uint32_t GetRegisteredN(void)
Definition: type-id.cc:576
static Iterator Begin(void)
void Resolve(Ptr< Object > root)
Definition: config.cc:285
T * PeekPointer(const Ptr< T > &p)
Definition: ptr.h:279
bool TraceDisconnectWithoutContext(std::string name, const CallbackBase &cb)
Definition: object-base.cc:295
static TypeId GetRegistered(uint32_t i)
Definition: type-id.cc:582
static void Bind(std::string name, const AttributeValue &value)
void ParsePath(std::string path, std::string *root, std::string *leaf) const
Definition: config.cc:513
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:553
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:563
Ptr< const AttributeChecker > checker
Definition: type-id.h:68
void DoArrayResolve(std::string path, const ObjectPtrContainerValue &vector)
Definition: config.cc:461
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Definition: object-base.cc:269
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:667
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:745
bool SetAttributeInitialValue(uint32_t i, Ptr< const AttributeValue > initialValue)
Definition: type-id.cc:713
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:712
void DisconnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:722
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:606
#define NS_LOG_DEBUG(msg)
Definition: log.h:289
bool Matches(uint32_t i) const
Definition: config.cc:162
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:525
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:757
bool StringToUint32(std::string str, uint32_t *value) const
Definition: config.cc:226
#define NS_LOG_ERROR(msg)
Definition: log.h:271
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:63
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:746
Ptr< Object > GetRootNamespaceObject(uint32_t i) const
Definition: config.cc:634
std::string GetPath(void) const
Definition: config.cc:81
void SetAttribute(std::string name, const AttributeValue &value)
Definition: object-base.cc:161
Ptr< T > GetObject(void) const
Definition: object.h:361
a unique identifier for an interface.
Definition: type-id.h:49
void SetGlobal(std::string name, const AttributeValue &value)
Definition: config.cc:707
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:717
Resolver(std::string path)
Definition: config.cc:254
Roots m_roots
Definition: config.cc:509
static TypeId LookupByName(std::string name)
Definition: type-id.cc:536