A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
29 
30 namespace ns3 {
31 
49 {
50  typedef std::vector<GlobalValue *> Vector;
51 public:
52  typedef Vector::const_iterator Iterator;
53 
64  GlobalValue (std::string name, std::string help,
65  const AttributeValue &initialValue,
67 
71  std::string GetName (void) const;
75  std::string GetHelp (void) const;
79  void GetValue (AttributeValue &value) const;
87  bool SetValue (const AttributeValue &value);
88 
89  void ResetInitialValue (void);
90 
100  static void Bind (std::string name, const AttributeValue &value);
101 
110  static bool BindFailSafe (std::string name, const AttributeValue &value);
111 
115  static Iterator Begin (void);
119  static Iterator End (void);
120 
121 
130  static bool GetValueByNameFailSafe (std::string name, AttributeValue &value);
131 
141  static void GetValueByName (std::string name, AttributeValue &value);
142 
143 
144 private:
145  friend class ::GlobalValueTestCase;
146 
147  static Vector *GetVector (void);
148  void InitializeFromEnv (void);
149  std::string m_name;
150  std::string m_help;
154 };
155 
156 } // namespace ns3
157 
158 #endif /* GLOBAL_VALUE_H */
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
std::string m_help
Definition: global-value.h:150
Hold a value for an Attribute.
Definition: attribute.h:56
Vector::const_iterator Iterator
Definition: global-value.h:52
Ptr< AttributeValue > m_initialValue
Definition: global-value.h:151
hold a so-called 'global value'.
Definition: global-value.h:48
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
void ResetInitialValue(void)
static Vector * GetVector(void)
static Iterator Begin(void)
Ptr< const AttributeChecker > m_checker
Definition: global-value.h:153
std::vector< GlobalValue * > Vector
Definition: global-value.h:50
static void Bind(std::string name, const AttributeValue &value)
static bool GetValueByNameFailSafe(std::string name, AttributeValue &value)
finds the GlobalValue with the given name and returns its value
bool SetValue(const AttributeValue &value)
std::string m_name
Definition: global-value.h:149
Ptr< AttributeValue > m_currentValue
Definition: global-value.h:152
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)
finds the GlobalValue with the given name and returns its value.
Ptr< const AttributeChecker > GetChecker(void) const
void InitializeFromEnv(void)
Definition: global-value.cc:61
void GetValue(AttributeValue &value) const