48 const std::vector<std::string> &contexts,
50 : m_objects (objects),
51 m_contexts (contexts),
108 for (uint32_t i = 0; i <
m_objects.size (); ++i)
112 object->TraceConnect (name, ctx, cb);
131 for (uint32_t i = 0; i <
m_objects.size (); ++i)
135 object->TraceDisconnect (name, ctx, cb);
169 bool Matches (std::size_t i)
const;
186 : m_element (element)
199 std::string::size_type tmp;
201 if (tmp != std::string::npos)
203 std::string left =
m_element.substr (0, tmp-0);
220 std::string::size_type leftBracket =
m_element.find (
"[");
221 std::string::size_type rightBracket =
m_element.find (
"]");
222 std::string::size_type dash =
m_element.find (
"-");
223 if (leftBracket == 0 && rightBracket ==
m_element.size () - 1 &&
224 dash > leftBracket && dash < rightBracket)
226 std::string lowerBound =
m_element.substr (leftBracket + 1, dash - (leftBracket + 1));
227 std::string upperBound =
m_element.substr (dash + 1, rightBracket - (dash + 1));
258 std::istringstream iss;
261 return !iss.bad () && !iss.fail ();
350 std::string::size_type tmp =
m_path.find (
"/");
356 tmp =
m_path.find_last_of (
"/");
357 if (tmp != (
m_path.size () - 1))
377 std::string fullPath =
"/";
380 fullPath += *i +
"/";
399 std::string::size_type next = path.find (
"/", 1);
401 if (next == std::string::npos)
417 std::string item = path.substr (1, next-1);
418 std::string pathLeft = path.substr (next, path.size ()-next);
429 std::string::size_type offset = path.find (
"/Names");
445 Ptr<Object> namedObject = Names::Find<Object> (root, item);
448 NS_LOG_DEBUG (
"Name system resolved item = " << item <<
" to " << namedObject);
466 std::string::size_type dollarPos = item.find (
"$");
470 std::string tidString = item.substr (1, item.size () - 1);
487 TypeId nextTid = root->GetInstanceTypeId ();
488 bool foundMatch =
false;
498 if (info.name != item && item !=
"*")
508 root->GetAttribute (info.name, pValue);
525 if (vectorChecker != 0)
530 root->GetAttribute (info.name, vector);
540 }
while (nextTid != tid);
556 std::string::size_type next = path.find (
"/", 1);
557 if (next == std::string::npos)
561 std::string item = path.substr (1, next-1);
562 std::string pathLeft = path.substr (next, path.size ()-next);
566 for (it = container.
Begin (); it != container.
End (); ++it)
568 if (matcher.
Matches ((*it).first))
570 std::ostringstream oss;
617 void ParsePath (std::string path, std::string *root, std::string *leaf)
const;
620 typedef std::vector<Ptr<Object> >
Roots;
632 std::string::size_type slash = path.find_last_of (
"/");
634 *root = path.substr (0, slash);
635 *leaf = path.substr (slash+1, path.size ()-(slash+1));
644 std::string root, leaf;
647 container.
Set (leaf, value);
653 std::string root, leaf;
662 std::string root, leaf;
672 std::string root, leaf;
682 std::string root, leaf;
692 class LookupMatchesResolver :
public Resolver 695 LookupMatchesResolver (std::string path)
698 virtual void DoOne (
Ptr<Object> object, std::string path)
700 m_objects.push_back (
object);
701 m_contexts.push_back (path);
703 std::vector<Ptr<Object> > m_objects;
704 std::vector<std::string> m_contexts;
705 } resolver = LookupMatchesResolver (path);
706 for (Roots::const_iterator i =
m_roots.begin (); i !=
m_roots.end (); i++)
708 resolver.Resolve (*i);
716 resolver.Resolve (0);
718 return MatchContainer (resolver.m_objects, resolver.m_contexts, path);
773 (*i)->ResetInitialValue ();
793 std::string::size_type pos = fullName.rfind (
"::");
794 if (pos == std::string::npos)
798 std::string tidName = fullName.substr (0, pos);
799 std::string paramName = fullName.substr (pos+2, fullName.size () - (pos+2));
809 if (tmp.
name == paramName)
std::string GetMatchedPath(uint32_t i) const
void ParsePath(std::string path, std::string *root, std::string *leaf) const
Break a Config path into the leading path and the last leaf token.
#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)
std::vector< std::string > m_workStack
Current list of path tokens.
Roots m_roots
The list of Config path roots.
void Set(std::string path, const AttributeValue &value)
bool SetGlobalFailSafe(std::string name, const AttributeValue &value)
void UnregisterRootNamespaceObject(Ptr< Object > obj)
Hold a value for an Attribute.
std::size_t GetRootNamespaceObjectN(void) const
Helper to test if an array entry matches a config path specification.
void RegisterRootNamespaceObject(Ptr< Object > obj)
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
U * PeekPointer(const Ptr< U > &p)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void DoResolveOne(Ptr< Object > object)
Handle one object found on the path.
Vector::const_iterator Iterator
Iterator type for the list of all global values.
Base class for Callback class.
static TypeId GetRegistered(uint16_t i)
Get a TypeId by index.
Config system implementation class.
void Disconnect(std::string name, const CallbackBase &cb)
void DisconnectWithoutContext(std::string path, const CallbackBase &cb)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
static bool LookupByNameFailSafe(std::string name, TypeId *tid)
Get a TypeId by name.
Ptr< Object > GetRootNamespaceObject(std::size_t i) const
void UnregisterRootNamespaceObject(Ptr< Object > obj)
Ptr< Object > Get(std::size_t i) const
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
std::size_t GetN(void) const
Declaration of the various ns3::Config functions and classes.
static ConfigImpl * Get(void)
Get a pointer to the singleton instance.
void RegisterRootNamespaceObject(Ptr< Object > obj)
bool SetAttributeInitialValue(std::size_t i, Ptr< const AttributeValue > initialValue)
Set the initial value of an Attribute.
TypeId GetParent(void) const
Get the parent of this TypeId.
void ConnectWithoutContext(std::string name, const CallbackBase &cb)
ns3::ObjectPtrContainerValue attribute value declarations and template implementations.
bool StringToUint32(std::string str, uint32_t *value) const
Convert a string to an uint32_t.
static Iterator Begin(void)
The Begin iterator.
Iterator Begin(void) const
Get an iterator to the first Object.
ArrayMatcher(std::string element)
Construct from a Config path specification.
std::string m_element
The Config path element.
std::map< std::size_t, Ptr< Object > >::const_iterator Iterator
Iterator type for traversing this container.
MatchContainer LookupMatches(std::string path)
Ptr< Object > GetRootNamespaceObject(uint32_t i)
AttributeChecker implementation for ObjectPtrContainerValue.
Iterator End(void) const
Get an iterator to the past-the-end Object.
bool TraceDisconnectWithoutContext(std::string name, const CallbackBase &cb)
Disconnect from a TraceSource a Callback previously connected without a context.
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
static void Bind(std::string name, const AttributeValue &value)
Iterate over the set of GlobalValues until a matching name is found and then set its value with Globa...
void Connect(std::string path, const CallbackBase &cb)
void Canonicalize(void)
Ensure the Config path starts and ends with a '/'.
void Connect(std::string path, const CallbackBase &cb)
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
MatchContainer::Iterator Begin(void) const
std::string m_path
The path used to perform the object matching.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hold objects of type Ptr<T>.
void Set(std::string path, const AttributeValue &value)
std::string GetResolvedPath(void) const
Get the current Config path.
std::size_t GetRootNamespaceObjectN(void)
ns3::GlobalValue declaration.
void Resolve(Ptr< Object > root)
Parse the stored Config path into an object reference, beginning at the indicated root object...
hold a set of objects which match a specific search string.
std::vector< Ptr< Object > > m_objects
The list of objects in this container.
void Connect(std::string name, const CallbackBase &cb)
void Reset(void)
Reset the initial value of every attribute as well as the value of every global to what they were bef...
std::vector< Ptr< Object > > Roots
Container type to hold the root Config path tokens.
MatchContainer LookupMatches(std::string path)
ns3::Object class declaration, which is the root of the Object hierarchy and Aggregation.
void DisconnectWithoutContext(std::string name, const CallbackBase &cb)
virtual void DoOne(Ptr< Object > object, std::string path)=0
Handle one found object.
bool Matches(std::size_t i) const
Test if a specific index matches the Config Path.
void DoArrayResolve(std::string path, const ObjectPtrContainerValue &vector)
Parse an index on the Config path.
AttributeChecker implementation for PointerValue.
void DisconnectWithoutContext(std::string path, const CallbackBase &cb)
void SetGlobal(std::string name, const AttributeValue &value)
std::vector< std::string > m_contexts
The context for each object.
Resolver(std::string path)
Construct from a base Config path.
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
std::size_t GetAttributeN(void) const
Get the number of attributes.
void DoResolve(std::string path, Ptr< Object > root)
Parse the next element in the Config path.
static Iterator End(void)
The End iterator.
static bool BindFailSafe(std::string name, const AttributeValue &value)
Iterate over the set of GlobalValues until a matching name is found and then set its value with Globa...
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
MatchContainer::Iterator End(void) const
void SetDefault(std::string name, const AttributeValue &value)
struct TypeId::AttributeInformation GetAttribute(std::size_t i) const
Get Attribute information by index.
void Disconnect(std::string path, const CallbackBase &cb)
virtual ~Resolver()
Destructor.
Declaration of class ns3::Names.
std::vector< Ptr< Object > >::const_iterator Iterator
Const iterator over the objects in this container.
Abstract class to parse Config paths into object references.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
void Set(std::string name, const AttributeValue &value)
A base class which provides memory management and object aggregation.
Container for a set of ns3::Object pointers.
static uint16_t GetRegisteredN(void)
Get the number of registered TypeIds.
void Disconnect(std::string path, const CallbackBase &cb)
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
ns3::PointerValue attribute value declarations and template implementations.
a unique identifier for an interface.
std::string m_path
The Config path.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
std::string GetPath(void) const