mathieu@2633
|
1 |
#ifndef ATTRIBUTE_LIST_H
|
mathieu@2633
|
2 |
#define ATTRIBUTE_LIST_H
|
mathieu@2633
|
3 |
|
mathieu@2633
|
4 |
#include <string>
|
mathieu@2633
|
5 |
#include <vector>
|
mathieu@2633
|
6 |
#include "attribute.h"
|
mathieu@2633
|
7 |
#include "type-id.h"
|
mathieu@2633
|
8 |
|
mathieu@2633
|
9 |
namespace ns3 {
|
mathieu@2633
|
10 |
|
mathieu@2633
|
11 |
/**
|
mathieu@2633
|
12 |
* \brief a container of attributes to be used during object's construction
|
mathieu@2633
|
13 |
* and in ns3::Object::Set.
|
mathieu@2633
|
14 |
*
|
mathieu@2633
|
15 |
*/
|
mathieu@2633
|
16 |
class AttributeList
|
mathieu@2633
|
17 |
{
|
mathieu@2633
|
18 |
public:
|
mathieu@2633
|
19 |
AttributeList ();
|
mathieu@2633
|
20 |
AttributeList (const AttributeList &o);
|
mathieu@2633
|
21 |
AttributeList &operator = (const AttributeList &o);
|
mathieu@2633
|
22 |
~AttributeList ();
|
mathieu@2633
|
23 |
/**
|
mathieu@2633
|
24 |
* \param name the full name of the attribute to set
|
mathieu@2633
|
25 |
* \param value the value to set
|
mathieu@2633
|
26 |
*
|
mathieu@2633
|
27 |
* This method checks that a attribute with the requested
|
mathieu@2633
|
28 |
* name exists and that the value specified is an acceptable
|
mathieu@2633
|
29 |
* value of that attribute. If any of these checks fails,
|
mathieu@2633
|
30 |
* the program terminates with a message.
|
mathieu@2633
|
31 |
*/
|
mathieu@2633
|
32 |
void Set (std::string name, Attribute value);
|
mathieu@2633
|
33 |
/**
|
mathieu@2633
|
34 |
* \param name the full name of the attribute to set
|
mathieu@2633
|
35 |
* \param value the value to set
|
mathieu@2633
|
36 |
* \returns true if the requested attribute exists and could be
|
mathieu@2633
|
37 |
* stored, false otherwise.
|
mathieu@2633
|
38 |
*/
|
mathieu@2633
|
39 |
bool SetFailSafe (std::string name, Attribute value);
|
mathieu@2633
|
40 |
/**
|
mathieu@2633
|
41 |
* \param tid the TypeId associated to this attribute
|
mathieu@2633
|
42 |
* \param name the name (not full!) of the attribute
|
mathieu@2633
|
43 |
* \param value the value to set
|
mathieu@2633
|
44 |
*
|
mathieu@2633
|
45 |
* This method checks that a attribute with the requested
|
mathieu@2633
|
46 |
* name exists and that the value specified is an acceptable
|
mathieu@2633
|
47 |
* value of that attribute. If any of these checks fails,
|
mathieu@2633
|
48 |
* the program terminates with a message.
|
mathieu@2633
|
49 |
*/
|
mathieu@2633
|
50 |
void SetWithTid (TypeId tid, std::string name, Attribute value);
|
mathieu@2633
|
51 |
|
mathieu@2633
|
52 |
/**
|
mathieu@2633
|
53 |
* Clear the content of this instance.
|
mathieu@2633
|
54 |
*/
|
mathieu@2633
|
55 |
void Reset (void);
|
mathieu@2633
|
56 |
|
mathieu@2633
|
57 |
/**
|
mathieu@2633
|
58 |
* \returns the global attribute container
|
mathieu@2633
|
59 |
*
|
mathieu@2633
|
60 |
* The global attribute container can be used to specify
|
mathieu@2633
|
61 |
* a set of attribute values without having to re-specify
|
mathieu@2633
|
62 |
* them for each object when it is created. This container
|
mathieu@2633
|
63 |
* is checked only during object construction and
|
mathieu@2633
|
64 |
* it is always checked last, after any per-object
|
mathieu@2633
|
65 |
* container is checked.
|
mathieu@2633
|
66 |
*/
|
mathieu@2633
|
67 |
static AttributeList *GetGlobal (void);
|
mathieu@2633
|
68 |
|
mathieu@2633
|
69 |
// XXX: untested.
|
mathieu@2633
|
70 |
std::string SerializeToString (void) const;
|
mathieu@2633
|
71 |
bool DeserializeFromString (std::string value);
|
mathieu@2633
|
72 |
private:
|
mathieu@2633
|
73 |
friend class Object;
|
mathieu@2633
|
74 |
struct Attr {
|
mathieu@2633
|
75 |
Ptr<const AttributeChecker> checker;
|
mathieu@2633
|
76 |
Attribute value;
|
mathieu@2633
|
77 |
};
|
mathieu@2633
|
78 |
typedef std::vector<struct Attr> Attrs;
|
mathieu@2633
|
79 |
typedef Attrs::iterator Iterator;
|
mathieu@2633
|
80 |
typedef Attrs::const_iterator CIterator;
|
mathieu@2633
|
81 |
|
mathieu@2633
|
82 |
|
mathieu@2633
|
83 |
|
mathieu@2633
|
84 |
bool DoSet (struct TypeId::AttributeInfo *info, Attribute param);
|
mathieu@2633
|
85 |
void DoSetOne (Ptr<const AttributeChecker> checker, Attribute param);
|
mathieu@2633
|
86 |
std::string LookupAttributeFullNameByChecker (Ptr<const AttributeChecker> checker) const;
|
mathieu@2633
|
87 |
|
mathieu@2633
|
88 |
Attrs m_attributes;
|
mathieu@2633
|
89 |
};
|
mathieu@2633
|
90 |
|
mathieu@2633
|
91 |
} // namespace ns3
|
mathieu@2633
|
92 |
|
mathieu@2633
|
93 |
#endif /* ATTRIBUTE_LIST_H */
|