A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
global-value.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 GLOBAL_VALUE_H
21 #define GLOBAL_VALUE_H
22 
23 #include <string>
24 #include <vector>
25 #include "ptr.h"
26 #include "attribute.h"
27 
28 
29 namespace ns3 {
30 
48 {
49  typedef std::vector<GlobalValue *> Vector;
50 public:
51  typedef Vector::const_iterator Iterator;
52 
63  GlobalValue (std::string name, std::string help,
64  const AttributeValue &initialValue,
66 
70  std::string GetName (void) const;
74  std::string GetHelp (void) const;
78  void GetValue (AttributeValue &value) const;
86  bool SetValue (const AttributeValue &value);
87 
88  void ResetInitialValue (void);
89 
99  static void Bind (std::string name, const AttributeValue &value);
100 
109  static bool BindFailSafe (std::string name, const AttributeValue &value);
110 
114  static Iterator Begin (void);
118  static Iterator End (void);
119 
120 
129  static bool GetValueByNameFailSafe (std::string name, AttributeValue &value);
130 
140  static void GetValueByName (std::string name, AttributeValue &value);
141 
142 
143 private:
144  friend class GlobalValueTestCase;
145 
146  static Vector *GetVector (void);
147  void InitializeFromEnv (void);
148  std::string m_name;
149  std::string m_help;
150  Ptr<AttributeValue> m_initialValue;
151  Ptr<AttributeValue> m_currentValue;
152  Ptr<const AttributeChecker> m_checker;
153 };
154 
155 } // namespace ns3
156 
157 #endif /* GLOBAL_VALUE_H */
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
Hold a value for an Attribute.
Definition: attribute.h:51
hold a so-called 'global value'.
Definition: global-value.h:47
GlobalValue(std::string name, std::string help, const AttributeValue &initialValue, Ptr< const AttributeChecker > checker)
Definition: global-value.cc:36
std::string GetName(void) const
Definition: global-value.cc:99
static Iterator Begin(void)
static void Bind(std::string name, const AttributeValue &value)
static bool GetValueByNameFailSafe(std::string name, AttributeValue &value)
bool SetValue(const AttributeValue &value)
static Iterator End(void)
static bool BindFailSafe(std::string name, const AttributeValue &value)
std::string GetHelp(void) const
static void GetValueByName(std::string name, AttributeValue &value)
Ptr< const AttributeChecker > GetChecker(void) const
void GetValue(AttributeValue &value) const