mathieu@2671
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
mathieu@2671
|
2 |
/*
|
mathieu@2671
|
3 |
* Copyright (c) 2008 INRIA
|
mathieu@2671
|
4 |
*
|
mathieu@2671
|
5 |
* This program is free software; you can redistribute it and/or modify
|
mathieu@2671
|
6 |
* it under the terms of the GNU General Public License version 2 as
|
mathieu@2671
|
7 |
* published by the Free Software Foundation;
|
mathieu@2671
|
8 |
*
|
mathieu@2671
|
9 |
* This program is distributed in the hope that it will be useful,
|
mathieu@2671
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
mathieu@2671
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
mathieu@2671
|
12 |
* GNU General Public License for more details.
|
mathieu@2671
|
13 |
*
|
mathieu@2671
|
14 |
* You should have received a copy of the GNU General Public License
|
mathieu@2671
|
15 |
* along with this program; if not, write to the Free Software
|
mathieu@2671
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
mathieu@2671
|
17 |
*
|
mathieu@2671
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
mathieu@2671
|
19 |
*/
|
mathieu@2633
|
20 |
#ifndef ATTRIBUTE_LIST_H
|
mathieu@2633
|
21 |
#define ATTRIBUTE_LIST_H
|
mathieu@2633
|
22 |
|
mathieu@2633
|
23 |
#include <string>
|
mathieu@2633
|
24 |
#include <vector>
|
mathieu@2633
|
25 |
#include "attribute.h"
|
mathieu@2633
|
26 |
#include "type-id.h"
|
mathieu@2633
|
27 |
|
mathieu@2633
|
28 |
namespace ns3 {
|
mathieu@2633
|
29 |
|
mathieu@2633
|
30 |
/**
|
mathieu@2633
|
31 |
* \brief a container of attributes to be used during object's construction
|
mathieu@2633
|
32 |
* and in ns3::Object::Set.
|
mathieu@2633
|
33 |
*
|
mathieu@2633
|
34 |
*/
|
mathieu@2633
|
35 |
class AttributeList
|
mathieu@2633
|
36 |
{
|
mathieu@2633
|
37 |
public:
|
mathieu@2633
|
38 |
AttributeList ();
|
mathieu@2633
|
39 |
AttributeList (const AttributeList &o);
|
mathieu@2633
|
40 |
AttributeList &operator = (const AttributeList &o);
|
mathieu@2633
|
41 |
~AttributeList ();
|
mathieu@2633
|
42 |
/**
|
mathieu@2633
|
43 |
* \param name the full name of the attribute to set
|
mathieu@2633
|
44 |
* \param value the value to set
|
mathieu@2633
|
45 |
*
|
mathieu@2633
|
46 |
* This method checks that a attribute with the requested
|
mathieu@2633
|
47 |
* name exists and that the value specified is an acceptable
|
mathieu@2633
|
48 |
* value of that attribute. If any of these checks fails,
|
mathieu@2633
|
49 |
* the program terminates with a message.
|
mathieu@2633
|
50 |
*/
|
mathieu@2965
|
51 |
void Set (std::string name, const AttributeValue &value);
|
mathieu@2633
|
52 |
/**
|
mathieu@2633
|
53 |
* \param name the full name of the attribute to set
|
mathieu@2633
|
54 |
* \param value the value to set
|
mathieu@2633
|
55 |
* \returns true if the requested attribute exists and could be
|
mathieu@2633
|
56 |
* stored, false otherwise.
|
mathieu@2633
|
57 |
*/
|
mathieu@2965
|
58 |
bool SetFailSafe (std::string name, const AttributeValue &value);
|
mathieu@2633
|
59 |
/**
|
mathieu@2633
|
60 |
* \param tid the TypeId associated to this attribute
|
mathieu@2633
|
61 |
* \param name the name (not full!) of the attribute
|
mathieu@2633
|
62 |
* \param value the value to set
|
mathieu@2633
|
63 |
*
|
mathieu@2633
|
64 |
* This method checks that a attribute with the requested
|
mathieu@2633
|
65 |
* name exists and that the value specified is an acceptable
|
mathieu@2633
|
66 |
* value of that attribute. If any of these checks fails,
|
mathieu@2633
|
67 |
* the program terminates with a message.
|
mathieu@2633
|
68 |
*/
|
mathieu@2965
|
69 |
void SetWithTid (TypeId tid, std::string name, const AttributeValue &value);
|
mathieu@2633
|
70 |
|
mathieu@2633
|
71 |
/**
|
mathieu@2633
|
72 |
* Clear the content of this instance.
|
mathieu@2633
|
73 |
*/
|
mathieu@2633
|
74 |
void Reset (void);
|
mathieu@2633
|
75 |
|
mathieu@2633
|
76 |
/**
|
mathieu@2633
|
77 |
* \returns the global attribute container
|
mathieu@2633
|
78 |
*
|
mathieu@2633
|
79 |
* The global attribute container can be used to specify
|
mathieu@2633
|
80 |
* a set of attribute values without having to re-specify
|
mathieu@2633
|
81 |
* them for each object when it is created. This container
|
mathieu@2633
|
82 |
* is checked only during object construction and
|
mathieu@2633
|
83 |
* it is always checked last, after any per-object
|
mathieu@2633
|
84 |
* container is checked.
|
mathieu@2633
|
85 |
*/
|
mathieu@2633
|
86 |
static AttributeList *GetGlobal (void);
|
mathieu@2633
|
87 |
|
mathieu@2633
|
88 |
// XXX: untested.
|
mathieu@2633
|
89 |
std::string SerializeToString (void) const;
|
mathieu@2633
|
90 |
bool DeserializeFromString (std::string value);
|
mathieu@2633
|
91 |
private:
|
mathieu@2637
|
92 |
friend class ObjectBase;
|
mathieu@2633
|
93 |
struct Attr {
|
mathieu@2633
|
94 |
Ptr<const AttributeChecker> checker;
|
mathieu@2965
|
95 |
Ptr<const AttributeValue> value;
|
mathieu@2633
|
96 |
};
|
mathieu@2633
|
97 |
typedef std::vector<struct Attr> Attrs;
|
mathieu@2633
|
98 |
typedef Attrs::iterator Iterator;
|
mathieu@2633
|
99 |
typedef Attrs::const_iterator CIterator;
|
mathieu@2633
|
100 |
|
mathieu@2633
|
101 |
|
mathieu@2633
|
102 |
|
mathieu@2965
|
103 |
bool DoSet (struct TypeId::AttributeInfo *info, const AttributeValue ¶m);
|
mathieu@2965
|
104 |
void DoSetOne (Ptr<const AttributeChecker> checker, const AttributeValue ¶m);
|
mathieu@2633
|
105 |
std::string LookupAttributeFullNameByChecker (Ptr<const AttributeChecker> checker) const;
|
mathieu@2633
|
106 |
|
mathieu@2633
|
107 |
Attrs m_attributes;
|
mathieu@2633
|
108 |
};
|
mathieu@2633
|
109 |
|
mathieu@2633
|
110 |
} // namespace ns3
|
mathieu@2633
|
111 |
|
mathieu@2633
|
112 |
#endif /* ATTRIBUTE_LIST_H */
|