A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
attribute-construction-list.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Mathieu Lacage
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Mathieu Lacage <mathieu.lacage@gmail.com>
7 */
9
10#include "log.h"
11
12/**
13 * \file
14 * \ingroup object
15 * ns3::AttributeConstructionList implementation.
16 */
17
18namespace ns3
19{
20
21NS_LOG_COMPONENT_DEFINE("AttributeConstructionList");
22
27
28void
32{
33 // get rid of any previous value stored in this
34 // vector of values.
35 NS_LOG_FUNCTION(this << name << checker << value);
36
37 for (auto k = m_list.begin(); k != m_list.end(); k++)
38 {
39 if (k->checker == checker)
40 {
41 m_list.erase(k);
42 break;
43 }
44 }
45 // store the new value.
46 Item attr;
47 attr.checker = checker;
48 attr.value = value;
49 attr.name = name;
50 m_list.push_back(attr);
51}
52
55{
56 NS_LOG_FUNCTION(this << checker);
57 for (auto k = m_list.begin(); k != m_list.end(); k++)
58 {
59 NS_LOG_DEBUG("Found " << k->name << " " << k->checker << " " << k->value);
60 if (k->checker == checker)
61 {
62 return k->value;
63 }
64 }
65 return nullptr;
66}
67
70{
71 NS_LOG_FUNCTION(this);
72 return m_list.begin();
73}
74
77{
78 NS_LOG_FUNCTION(this);
79 return m_list.end();
80}
81
82} // namespace ns3
ns3::AttributeConstructionList declaration.
Ptr< AttributeValue > Find(Ptr< const AttributeChecker > checker) const
Find an Attribute in the list from its AttributeChecker.
void Add(std::string name, Ptr< const AttributeChecker > checker, Ptr< AttributeValue > value)
Add an Attribute to the list.
std::list< Item > m_list
The list of Items.
std::list< Item >::const_iterator CIterator
Iterator type.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Debug message logging.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::string name
The name of the Attribute.
Ptr< const AttributeChecker > checker
Checker used to validate serialized values.
Ptr< AttributeValue > value
The value of the Attribute.