A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
attribute.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
4  *
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;
8  *
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.
13  *
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
17  *
18  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #ifndef ATTRIBUTE_H
21 #define ATTRIBUTE_H
22 
23 #include <string>
24 #include <stdint.h>
25 #include "ptr.h"
26 #include "simple-ref-count.h"
27 
28 namespace ns3 {
29 
30 class AttributeAccessor;
31 class AttributeChecker;
32 class Attribute;
33 class ObjectBase;
34 
51 class AttributeValue : public SimpleRefCount<AttributeValue>
52 {
53 public:
54  AttributeValue ();
55  virtual ~AttributeValue ();
56 
60  virtual Ptr<AttributeValue> Copy (void) const = 0;
70  virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const = 0;
84  virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker) = 0;
85 };
86 
97 class AttributeAccessor : public SimpleRefCount<AttributeAccessor>
98 {
99 public:
101  virtual ~AttributeAccessor ();
102 
111  virtual bool Set (ObjectBase * object, const AttributeValue &value) const = 0;
121  virtual bool Get (const ObjectBase * object, AttributeValue &attribute) const = 0;
122 
127  virtual bool HasGetter (void) const = 0;
132  virtual bool HasSetter (void) const = 0;
133 };
134 
149 class AttributeChecker : public SimpleRefCount<AttributeChecker>
150 {
151 public:
152  AttributeChecker ();
153  virtual ~AttributeChecker ();
154 
155  Ptr<AttributeValue> CreateValidValue (const AttributeValue &value) const;
162  virtual bool Check (const AttributeValue &value) const = 0;
171  virtual std::string GetValueTypeName (void) const = 0;
179  virtual bool HasUnderlyingTypeInformation (void) const = 0;
184  virtual std::string GetUnderlyingTypeInformation (void) const = 0;
192  virtual Ptr<AttributeValue> Create (void) const = 0;
193 
194  virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const = 0;
195 
196 
197 };
198 
205 {
206 public:
208 private:
209  virtual Ptr<AttributeValue> Copy (void) const;
210  virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
211  virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
212 };
213 
214 } // namespace ns3
215 
216 #endif /* ATTRIBUTE_H */
Represent the type of an attribute.
Definition: attribute.h:149
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
Hold a value for an Attribute.
Definition: attribute.h:51
virtual bool Get(const ObjectBase *object, AttributeValue &attribute) const =0
virtual bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker)
Definition: attribute.cc:98
virtual bool HasGetter(void) const =0
implement the ns-3 type and attribute system
Definition: object-base.h:55
virtual bool HasUnderlyingTypeInformation(void) const =0
virtual bool HasSetter(void) const =0
virtual std::string SerializeToString(Ptr< const AttributeChecker > checker) const =0
A class for an empty attribute value.
Definition: attribute.h:204
virtual std::string GetValueTypeName(void) const =0
virtual std::string SerializeToString(Ptr< const AttributeChecker > checker) const
Definition: attribute.cc:92
allow setting and getting the value of an attribute.
Definition: attribute.h:97
virtual Ptr< AttributeValue > Copy(void) const =0
virtual bool Set(ObjectBase *object, const AttributeValue &value) const =0
virtual Ptr< AttributeValue > Create(void) const =0
virtual bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker)=0
virtual bool Check(const AttributeValue &value) const =0
virtual std::string GetUnderlyingTypeInformation(void) const =0
A template-based reference counting class.
virtual Ptr< AttributeValue > Copy(void) const
Definition: attribute.cc:86