A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
attribute.h
Go to the documentation of this file.
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 
56 class AttributeValue : public SimpleRefCount<AttributeValue>
57 {
58 public:
59  AttributeValue ();
60  virtual ~AttributeValue ();
61 
65  virtual Ptr<AttributeValue> Copy (void) const = 0;
75  virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const = 0;
89  virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker) = 0;
90 };
91 
102 class AttributeAccessor : public SimpleRefCount<AttributeAccessor>
103 {
104 public:
106  virtual ~AttributeAccessor ();
107 
116  virtual bool Set (ObjectBase * object, const AttributeValue &value) const = 0;
126  virtual bool Get (const ObjectBase * object, AttributeValue &attribute) const = 0;
127 
132  virtual bool HasGetter (void) const = 0;
137  virtual bool HasSetter (void) const = 0;
138 };
139 
154 class AttributeChecker : public SimpleRefCount<AttributeChecker>
155 {
156 public:
157  AttributeChecker ();
158  virtual ~AttributeChecker ();
159 
174  virtual bool Check (const AttributeValue &value) const = 0;
183  virtual std::string GetValueTypeName (void) const = 0;
191  virtual bool HasUnderlyingTypeInformation (void) const = 0;
196  virtual std::string GetUnderlyingTypeInformation (void) const = 0;
204  virtual Ptr<AttributeValue> Create (void) const = 0;
212  virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const = 0;
213 
214 
215 };
216 
223 {
224 public:
226 private:
227  virtual Ptr<AttributeValue> Copy (void) const;
228  virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
229  virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
230 };
231 
232 } // namespace ns3
233 
234 #endif /* ATTRIBUTE_H */