mathieu@2671: /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ mathieu@2671: /* mathieu@2671: * Copyright (c) 2008 INRIA mathieu@2671: * mathieu@2671: * This program is free software; you can redistribute it and/or modify mathieu@2671: * it under the terms of the GNU General Public License version 2 as mathieu@2671: * published by the Free Software Foundation; mathieu@2671: * mathieu@2671: * This program is distributed in the hope that it will be useful, mathieu@2671: * but WITHOUT ANY WARRANTY; without even the implied warranty of mathieu@2671: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the mathieu@2671: * GNU General Public License for more details. mathieu@2671: * mathieu@2671: * You should have received a copy of the GNU General Public License mathieu@2671: * along with this program; if not, write to the Free Software mathieu@2671: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA mathieu@2671: * mathieu@2671: * Author: Mathieu Lacage mathieu@2671: */ mathieu@2633: #ifndef ATTRIBUTE_LIST_H mathieu@2633: #define ATTRIBUTE_LIST_H mathieu@2633: mathieu@2633: #include mathieu@2633: #include mathieu@2633: #include "attribute.h" mathieu@2633: #include "type-id.h" mathieu@2633: mathieu@2633: namespace ns3 { mathieu@2633: mathieu@2633: /** tomh@3182: * \ingroup attribute tomh@3182: * mathieu@2633: * \brief a container of attributes to be used during object's construction mathieu@2633: * and in ns3::Object::Set. mathieu@2633: * mathieu@2633: */ mathieu@2633: class AttributeList mathieu@2633: { mathieu@2633: public: mathieu@2633: AttributeList (); mathieu@2633: AttributeList (const AttributeList &o); mathieu@2633: AttributeList &operator = (const AttributeList &o); mathieu@2633: ~AttributeList (); mathieu@2633: /** mathieu@2633: * \param name the full name of the attribute to set mathieu@2633: * \param value the value to set mathieu@2633: * mathieu@2633: * This method checks that a attribute with the requested mathieu@2633: * name exists and that the value specified is an acceptable mathieu@2633: * value of that attribute. If any of these checks fails, mathieu@2633: * the program terminates with a message. mathieu@2633: */ mathieu@2965: void Set (std::string name, const AttributeValue &value); mathieu@2633: /** mathieu@2633: * \param name the full name of the attribute to set mathieu@2633: * \param value the value to set mathieu@2633: * \returns true if the requested attribute exists and could be mathieu@2633: * stored, false otherwise. mathieu@2633: */ mathieu@2965: bool SetFailSafe (std::string name, const AttributeValue &value); mathieu@2633: /** mathieu@2633: * \param tid the TypeId associated to this attribute mathieu@2633: * \param name the name (not full!) of the attribute mathieu@2633: * \param value the value to set mathieu@2633: * mathieu@2633: * This method checks that a attribute with the requested mathieu@2633: * name exists and that the value specified is an acceptable mathieu@2633: * value of that attribute. If any of these checks fails, mathieu@2633: * the program terminates with a message. mathieu@2633: */ mathieu@2965: void SetWithTid (TypeId tid, std::string name, const AttributeValue &value); mathieu@2633: mathieu@2633: /** mathieu@2633: * Clear the content of this instance. mathieu@2633: */ mathieu@2633: void Reset (void); mathieu@2633: mathieu@2633: /** mathieu@2633: * \returns the global attribute container mathieu@2633: * mathieu@2633: * The global attribute container can be used to specify mathieu@2633: * a set of attribute values without having to re-specify mathieu@2633: * them for each object when it is created. This container mathieu@2633: * is checked only during object construction and mathieu@2633: * it is always checked last, after any per-object mathieu@2633: * container is checked. mathieu@2633: */ mathieu@2633: static AttributeList *GetGlobal (void); mathieu@2633: mathieu@2633: // XXX: untested. mathieu@2633: std::string SerializeToString (void) const; mathieu@2633: bool DeserializeFromString (std::string value); mathieu@2633: private: mathieu@2637: friend class ObjectBase; mathieu@2633: struct Attr { mathieu@2633: Ptr checker; mathieu@2965: Ptr value; mathieu@2633: }; mathieu@2633: typedef std::vector Attrs; mathieu@2633: typedef Attrs::iterator Iterator; mathieu@2633: typedef Attrs::const_iterator CIterator; mathieu@2633: mathieu@2633: mathieu@2633: mathieu@2965: bool DoSet (struct TypeId::AttributeInfo *info, const AttributeValue ¶m); mathieu@2965: void DoSetOne (Ptr checker, const AttributeValue ¶m); mathieu@2633: std::string LookupAttributeFullNameByChecker (Ptr checker) const; mathieu@2633: mathieu@2633: Attrs m_attributes; mathieu@2633: }; mathieu@2633: mathieu@2633: } // namespace ns3 mathieu@2633: mathieu@2633: #endif /* ATTRIBUTE_LIST_H */