44 const std::vector<std::string>& contexts,
99 for (
auto tmp =
Begin(); tmp !=
End(); ++tmp)
103 object->SetAttribute(name, value);
112 for (
auto tmp =
Begin(); tmp !=
End(); ++tmp)
115 ok |=
object->SetAttributeFailSafe(name, value);
139 ok |=
object->TraceConnect(name, ctx, cb);
158 for (
auto tmp =
Begin(); tmp !=
End(); ++tmp)
161 ok |=
object->TraceConnectWithoutContext(name, cb);
175 object->TraceDisconnect(name, ctx, cb);
183 for (
auto tmp =
Begin(); tmp !=
End(); ++tmp)
186 object->TraceDisconnectWithoutContext(name, cb);
209 bool Matches(std::size_t i)
const;
240 std::string::size_type tmp;
242 if (tmp != std::string::npos)
244 std::string left =
m_element.substr(0, tmp - 0);
261 std::string::size_type leftBracket =
m_element.find(
'[');
262 std::string::size_type rightBracket =
m_element.find(
']');
263 std::string::size_type dash =
m_element.find(
'-');
264 if (leftBracket == 0 && rightBracket ==
m_element.size() - 1 && dash > leftBracket &&
267 std::string lowerBound =
m_element.substr(leftBracket + 1, dash - (leftBracket + 1));
268 std::string upperBound =
m_element.substr(dash + 1, rightBracket - (dash + 1));
297 std::istringstream iss;
300 return !iss.bad() && !iss.fail();
391 std::string::size_type tmp =
m_path.find(
'/');
397 tmp =
m_path.find_last_of(
'/');
398 if (tmp != (
m_path.size() - 1))
418 std::string fullPath =
"/";
421 fullPath += *i +
"/";
440 std::string::size_type next = path.find(
'/', 1);
442 if (next == std::string::npos)
458 std::string item = path.substr(1, next - 1);
459 std::string pathLeft = path.substr(next, path.size() - next);
470 std::string::size_type offset = path.find(
"/Names");
489 NS_LOG_DEBUG(
"Name system resolved item = " << item <<
" to " << namedObject);
507 std::string::size_type dollarPos = item.find(
'$');
511 std::string tidString = item.substr(1, item.size() - 1);
528 TypeId nextTid = root->GetInstanceTypeId();
529 bool foundMatch =
false;
539 if (info.
name != item && item !=
"*")
544 const auto pChecker =
546 if (pChecker !=
nullptr)
551 root->GetAttribute(info.
name, pValue);
555 NS_LOG_ERROR(
"Requested object name=\"" << item <<
"\" exists on path=\""
567 const auto vectorChecker =
569 if (vectorChecker !=
nullptr)
575 root->GetAttribute(info.
name, vector);
585 }
while (nextTid != tid);
602 std::string::size_type next = path.find(
'/', 1);
603 if (next == std::string::npos)
607 std::string item = path.substr(1, next - 1);
608 std::string pathLeft = path.substr(next, path.size() - next);
612 for (it = container.Begin(); it != container.End(); ++it)
614 if (matcher.
Matches((*it).first))
616 std::ostringstream oss;
667 void ParsePath(std::string path, std::string* root, std::string* leaf)
const;
670 typedef std::vector<Ptr<Object>>
Roots;
682 std::string::size_type slash = path.find_last_of(
'/');
684 *root = path.substr(0, slash);
685 *leaf = path.substr(slash + 1, path.size() - (slash + 1));
698 container.Set(leaf, value);
710 return container.SetFailSafe(leaf, value);
721 return container.ConnectWithoutContextFailSafe(leaf, cb);
732 if (container.GetN() == 0)
734 std::size_t lastFwdSlash = root.rfind(
'/');
736 << leaf <<
", the Requested object name = " << root.substr(lastFwdSlash + 1)
737 <<
" does not exits on path " << root.substr(0, lastFwdSlash));
739 container.DisconnectWithoutContext(leaf, cb);
751 return container.ConnectFailSafe(leaf, cb);
763 if (container.GetN() == 0)
765 std::size_t lastFwdSlash = root.rfind(
'/');
767 << leaf <<
", the Requested object name = " << root.substr(lastFwdSlash + 1)
768 <<
" does not exits on path " << root.substr(0, lastFwdSlash));
770 container.Disconnect(leaf, cb);
778 class LookupMatchesResolver :
public Resolver
781 LookupMatchesResolver(std::string path)
786 void DoOne(
Ptr<Object> object, std::string path)
override
788 m_objects.push_back(
object);
789 m_contexts.push_back(path);
792 std::vector<Ptr<Object>> m_objects;
793 std::vector<std::string> m_contexts;
794 } resolver = LookupMatchesResolver(path);
798 resolver.Resolve(*i);
806 resolver.Resolve(
nullptr);
808 return MatchContainer(resolver.m_objects, resolver.m_contexts, path);
864 (*i)->ResetInitialValue();
896 std::string::size_type pos = fullName.rfind(
"::");
897 if (pos == std::string::npos)
901 std::string tidName = fullName.substr(0, pos);
902 std::string paramName = fullName.substr(pos + 2, fullName.size() - (pos + 2));
914 if (tmp.
name == paramName)
Hold a value for an Attribute.
Base class for Callback class.
Helper to test if an array entry matches a config path specification.
ArrayMatcher(std::string element)
Construct from a Config path specification.
bool StringToUint32(std::string str, uint32_t *value) const
Convert a string to an uint32_t.
bool Matches(std::size_t i) const
Test if a specific index matches the Config Path.
std::string m_element
The Config path element.
Config system implementation class.
void UnregisterRootNamespaceObject(Ptr< Object > obj)
void DisconnectWithoutContext(std::string path, const CallbackBase &cb)
Roots m_roots
The list of Config path roots.
Ptr< Object > GetRootNamespaceObject(std::size_t i) const
bool ConnectFailSafe(std::string path, const CallbackBase &cb)
std::size_t GetRootNamespaceObjectN() const
bool SetFailSafe(std::string path, const AttributeValue &value)
void Set(std::string path, const AttributeValue &value)
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.
void Disconnect(std::string path, const CallbackBase &cb)
std::vector< Ptr< Object > > Roots
Container type to hold the root Config path tokens.
bool ConnectWithoutContextFailSafe(std::string path, const CallbackBase &cb)
void RegisterRootNamespaceObject(Ptr< Object > obj)
MatchContainer LookupMatches(std::string path)
hold a set of objects which match a specific search string.
bool SetFailSafe(std::string name, const AttributeValue &value)
void Connect(std::string name, const CallbackBase &cb)
void DisconnectWithoutContext(std::string name, const CallbackBase &cb)
void Set(std::string name, const AttributeValue &value)
Ptr< Object > Get(std::size_t i) const
void Disconnect(std::string name, const CallbackBase &cb)
std::string GetMatchedPath(uint32_t i) const
MatchContainer::Iterator End() const
bool ConnectFailSafe(std::string name, const CallbackBase &cb)
std::string GetPath() const
bool ConnectWithoutContextFailSafe(std::string name, const CallbackBase &cb)
std::string m_path
The path used to perform the object matching.
void ConnectWithoutContext(std::string name, const CallbackBase &cb)
std::vector< Ptr< Object > >::const_iterator Iterator
Const iterator over the objects in this container.
std::vector< Ptr< Object > > m_objects
The list of objects in this container.
MatchContainer::Iterator Begin() const
std::vector< std::string > m_contexts
The context for each object.
Abstract class to parse Config paths into object references.
std::vector< std::string > m_workStack
Current list of path tokens.
std::string GetResolvedPath() const
Get the current Config path.
Resolver(std::string path)
Construct from a base Config path.
void Resolve(Ptr< Object > root)
Parse the stored Config path into an object reference, beginning at the indicated root object.
void DoResolveOne(Ptr< Object > object)
Handle one object found on the path.
virtual void DoOne(Ptr< Object > object, std::string path)=0
Handle one found object.
void DoResolve(std::string path, Ptr< Object > root)
Parse the next element in the Config path.
std::string m_path
The Config path.
void Canonicalize()
Ensure the Config path starts and ends with a '/'.
virtual ~Resolver()
Destructor.
void DoArrayResolve(std::string path, const ObjectPtrContainerValue &vector)
Parse an index on the Config path.
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...
static Iterator Begin()
The Begin 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...
static Iterator End()
The End iterator.
static Ptr< T > Find(std::string path)
Given a name path string, look to see if there's an object in the system with that associated to it.
A base class which provides memory management and object aggregation.
AttributeChecker implementation for ObjectPtrContainerValue.
Container for a set of ns3::Object pointers.
std::map< std::size_t, Ptr< Object > >::const_iterator Iterator
Iterator type for traversing this container.
AttributeChecker implementation for PointerValue.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
static ConfigImpl * Get()
a unique identifier for an interface.
bool SetAttributeInitialValue(std::size_t i, Ptr< const AttributeValue > initialValue)
Set the initial value of an Attribute.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
static uint16_t GetRegisteredN()
Get the number of registered TypeIds.
std::size_t GetAttributeN() const
Get the number of attributes.
TypeId GetParent() const
Get the parent of this TypeId.
static TypeId GetRegistered(uint16_t i)
Get a TypeId by index.
TypeId::AttributeInformation GetAttribute(std::size_t i) const
Get Attribute information by index.
static bool LookupByNameFailSafe(std::string name, TypeId *tid)
Get a TypeId by name.
bool LookupAttributeByName(std::string name, AttributeInformation *info, bool permissive=false) const
Find an Attribute by name, retrieving the associated AttributeInformation.
Declaration of the various ns3::Config functions and classes.
ns3::GlobalValue declaration.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
void Reset()
Reset the initial value of every attribute as well as the value of every global to what they were bef...
void SetGlobal(std::string name, const AttributeValue &value)
bool SetFailSafe(std::string path, const AttributeValue &value)
void SetDefault(std::string name, const AttributeValue &value)
void Disconnect(std::string path, const CallbackBase &cb)
void Connect(std::string path, const CallbackBase &cb)
MatchContainer LookupMatches(std::string path)
void DisconnectWithoutContext(std::string path, const CallbackBase &cb)
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
bool ConnectFailSafe(std::string path, const CallbackBase &cb)
void UnregisterRootNamespaceObject(Ptr< Object > obj)
Ptr< Object > GetRootNamespaceObject(uint32_t i)
bool SetGlobalFailSafe(std::string name, const AttributeValue &value)
void Set(std::string path, const AttributeValue &value)
void RegisterRootNamespaceObject(Ptr< Object > obj)
std::size_t GetRootNamespaceObjectN()
bool SetDefaultFailSafe(std::string fullName, const AttributeValue &value)
bool ConnectWithoutContextFailSafe(std::string path, const CallbackBase &cb)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Declaration of class ns3::Names.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
U * PeekPointer(const Ptr< U > &p)
ns3::ObjectPtrContainerValue attribute value declarations and template implementations.
ns3::Object class declaration, which is the root of the Object hierarchy and Aggregation.
ns3::PointerValue attribute value declarations and template implementations.
ns3::Singleton declaration and template implementation.