A Discrete-Event Network Simulator
API
global-value.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 GLOBAL_VALUE_H
21 #define GLOBAL_VALUE_H
22 
23 #include <string>
24 #include <vector>
25 #include "ptr.h"
26 #include "attribute.h"
27 
34 namespace ns3 {
35 
36 /* Forward declaration */
37 namespace tests {
39 }
40 
74 {
76  typedef std::vector<GlobalValue *> Vector;
77 
78 public:
80  typedef Vector::const_iterator Iterator;
81 
93  GlobalValue (std::string name, std::string help,
94  const AttributeValue &initialValue,
96 
101  std::string GetName (void) const;
106  std::string GetHelp (void) const;
112  void GetValue (AttributeValue &value) const;
123  bool SetValue (const AttributeValue &value);
124 
126  void ResetInitialValue (void);
127 
137  static void Bind (std::string name, const AttributeValue &value);
138 
148  static bool BindFailSafe (std::string name, const AttributeValue &value);
149 
154  static Iterator Begin (void);
159  static Iterator End (void);
160 
161 
170  static bool GetValueByNameFailSafe (std::string name, AttributeValue &value);
171 
182  static void GetValueByName (std::string name, AttributeValue &value);
183 
184 private:
187 
193  static Vector * GetVector (void);
195  void InitializeFromEnv (void);
196 
198  std::string m_name;
200  std::string m_help;
207 };
208 
209 } // namespace ns3
210 
211 #endif /* GLOBAL_VALUE_H */
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
Hold a value for an Attribute.
Definition: attribute.h:69
Hold a so-called 'global value'.
Definition: global-value.h:74
Vector::const_iterator Iterator
Iterator type for the list of all global values.
Definition: global-value.h:80
static Iterator End(void)
The End iterator.
void InitializeFromEnv(void)
Initialize from the NS_GLOBAL_VALUE environment variable.
Definition: global-value.cc:68
Ptr< const AttributeChecker > GetChecker(void) const
Get the AttributeChecker.
std::string GetHelp(void) const
Get the help string.
void GetValue(AttributeValue &value) const
Get the value.
static void Bind(std::string name, const AttributeValue &value)
Iterate over the set of GlobalValues until a matching name is found and then set its value with Globa...
static bool GetValueByNameFailSafe(std::string name, AttributeValue &value)
Finds the GlobalValue with the given name and returns its value.
std::vector< GlobalValue * > Vector
Container type for holding all the GlobalValues.
Definition: global-value.h:76
static Vector * GetVector(void)
Get the static vector of all GlobalValues.
void ResetInitialValue(void)
Reset to the initial value.
std::string m_help
The help string.
Definition: global-value.h:200
Ptr< const AttributeChecker > m_checker
The AttributeChecker for this GlobalValue.
Definition: global-value.h:206
Ptr< AttributeValue > m_currentValue
The current value.
Definition: global-value.h:204
std::string GetName(void) const
Get the name.
bool SetValue(const AttributeValue &value)
Set the value of this GlobalValue.
static void GetValueByName(std::string name, AttributeValue &value)
Finds the GlobalValue with the given name and returns its value.
static bool BindFailSafe(std::string name, const AttributeValue &value)
Iterate over the set of GlobalValues until a matching name is found and then set its value with Globa...
static Iterator Begin(void)
The Begin iterator.
Ptr< AttributeValue > m_initialValue
The initial value.
Definition: global-value.h:202
GlobalValue(std::string name, std::string help, const AttributeValue &initialValue, Ptr< const AttributeChecker > checker)
Constructor.
Definition: global-value.cc:43
std::string m_name
The name of this GlobalValue.
Definition: global-value.h:198
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
Test for the ability to get at a GlobalValue.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Ptr smart pointer declaration and implementation.