1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
3 * Copyright (c) 2008 INRIA
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20 #ifndef ATTRIBUTE_LIST_H
21 #define ATTRIBUTE_LIST_H
25 #include "attribute.h"
33 * \brief a container of attributes to be used during object's construction
34 * and in ns3::Object::Set.
41 AttributeList (const AttributeList &o);
42 AttributeList &operator = (const AttributeList &o);
45 * \param name the full name of the attribute to set
46 * \param value the value to set
48 * This method checks that a attribute with the requested
49 * name exists and that the value specified is an acceptable
50 * value of that attribute. If any of these checks fails,
51 * the program terminates with a message.
53 void Set (std::string name, const AttributeValue &value);
55 * \param name the full name of the attribute to set
56 * \param value the value to set
57 * \returns true if the requested attribute exists and could be
58 * stored, false otherwise.
60 bool SetFailSafe (std::string name, const AttributeValue &value);
62 * \param tid the TypeId associated to this attribute
63 * \param name the name (not full!) of the attribute
64 * \param value the value to set
66 * This method checks that a attribute with the requested
67 * name exists and that the value specified is an acceptable
68 * value of that attribute. If any of these checks fails,
69 * the program terminates with a message.
71 void SetWithTid (TypeId tid, std::string name, const AttributeValue &value);
74 * Clear the content of this instance.
79 * \returns the global attribute container
81 * The global attribute container can be used to specify
82 * a set of attribute values without having to re-specify
83 * them for each object when it is created. This container
84 * is checked only during object construction and
85 * it is always checked last, after any per-object
86 * container is checked.
88 static AttributeList *GetGlobal (void);
90 std::string SerializeToString (void) const;
91 bool DeserializeFromString (std::string value);
93 friend class ObjectBase;
95 Ptr<const AttributeChecker> checker;
96 Ptr<const AttributeValue> value;
98 typedef std::vector<struct Attr> Attrs;
99 typedef Attrs::iterator Iterator;
100 typedef Attrs::const_iterator CIterator;
104 bool DoSet (struct TypeId::AttributeInfo *info, const AttributeValue ¶m);
105 void DoSetOne (Ptr<const AttributeChecker> checker, const AttributeValue ¶m);
106 std::string LookupAttributeFullNameByChecker (Ptr<const AttributeChecker> checker) const;
111 class UnsafeAttributeList
114 UnsafeAttributeList ();
115 UnsafeAttributeList (const UnsafeAttributeList &o);
116 UnsafeAttributeList &operator = (const UnsafeAttributeList &o);
117 ~UnsafeAttributeList ();
119 void Set (std::string name, const AttributeValue ¶m);
121 AttributeList GetSafe (std::string name) const;
123 std::vector<std::pair<std::string,Ptr<AttributeValue> > > m_attributes;
128 #endif /* ATTRIBUTE_LIST_H */