author | Tom Henderson <tomh@tomh.org> |
Thu, 10 Jan 2008 07:31:40 -0800 | |
changeset 2217 | 0b4567d545de |
parent 2114 | bfd8e5afb36d |
permissions | -rw-r--r-- |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
599
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
2 |
/* |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
3 |
* Copyright (c) 2007 INRIA |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
4 |
* |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
7 |
* published by the Free Software Foundation; |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
8 |
* |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
12 |
* GNU General Public License for more details. |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
13 |
* |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
17 |
* |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
19 |
*/ |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
20 |
#ifndef DEFAULT_VALUE_H |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
21 |
#define DEFAULT_VALUE_H |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
22 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
23 |
#include <string> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
24 |
#include <list> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
25 |
#include "callback.h" |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
26 |
|
538
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
27 |
/** |
2217 | 28 |
* \ingroup core |
538
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
29 |
* \defgroup config Simulation configuration |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
30 |
* |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
31 |
*/ |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
32 |
|
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
33 |
namespace ns3 { |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
34 |
|
1224
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
35 |
namespace DefaultValue |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
36 |
{ |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
37 |
|
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
38 |
/** |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
39 |
* \ingroup config |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
40 |
* \param name name of variable to bind |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
41 |
* \param value value to bind to the specified variable |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
42 |
* |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
43 |
* If the variable name does not match any existing |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
44 |
* variable or if the value is not compatible with |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
45 |
* the variable type, this function will abort |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
46 |
* at runtime and print an error message detailing |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
47 |
* which variable or value triggered the problem. |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
48 |
*/ |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
49 |
void Bind (std::string name, std::string value); |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
50 |
|
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
51 |
} |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
52 |
|
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
53 |
|
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
54 |
class DefaultValueBase |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
55 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
56 |
public: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
57 |
virtual ~DefaultValueBase (); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
58 |
std::string GetName (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
59 |
std::string GetHelp (void) const; |
965
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
60 |
|
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
61 |
/** |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
62 |
* \returns true if this value is dirty, false otherwise. |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
63 |
* |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
64 |
* A value becomes dirty when ParseValue is invoked |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
65 |
* and it successfully completes. Dirtyness indicates |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
66 |
* that the state of the value was changed by a user. |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
67 |
*/ |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
68 |
bool IsDirty (void) const; |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
69 |
/** |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
70 |
* Clear the dirty state. |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
71 |
*/ |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
72 |
void ClearDirtyFlag (void); |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
73 |
// parse a matching parameter |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
74 |
// return true in case of success, false otherwise. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
75 |
bool ParseValue (const std::string &value); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
76 |
std::string GetType (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
77 |
std::string GetDefaultValue (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
78 |
protected: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
79 |
DefaultValueBase (const std::string &name, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
80 |
const std::string &help); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
81 |
private: |
965
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
82 |
DefaultValueBase (); |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
83 |
private: |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
84 |
virtual bool DoParseValue (const std::string &value) = 0; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
85 |
virtual std::string DoGetType (void) const = 0; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
86 |
virtual std::string DoGetDefaultValue (void) const = 0; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
87 |
std::string m_name; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
88 |
std::string m_help; |
965
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
89 |
bool m_dirty; |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
90 |
}; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
91 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
92 |
class DefaultValueList |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
93 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
94 |
public: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
95 |
typedef std::list<DefaultValueBase *>::iterator Iterator; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
96 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
97 |
static Iterator Begin (void); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
98 |
static Iterator End (void); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
99 |
static void Remove (const std::string &name); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
100 |
static void Add (DefaultValueBase *defaultValue); |
1701
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
101 |
|
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
102 |
template <typename T> |
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
103 |
static const T* Get (const std::string &name) |
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
104 |
{ |
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
105 |
for (Iterator iter = Begin (); iter != End (); iter++) |
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
106 |
{ |
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
107 |
const DefaultValueBase *value = *iter; |
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
108 |
if (value->GetName () == name) |
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
109 |
{ |
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
110 |
return dynamic_cast<const T*> (value); |
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
111 |
} |
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
112 |
} |
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
113 |
return NULL; |
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
114 |
} |
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
115 |
|
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
116 |
private: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
117 |
typedef std::list<DefaultValueBase *> List; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
118 |
static List *GetList (void); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
119 |
}; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
120 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
121 |
/** |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
122 |
* \brief A Boolean variable for ns3::Bind |
538
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
123 |
* \ingroup config |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
124 |
* |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
125 |
* Every instance of this type is automatically |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
126 |
* registered in the variable pool which is used |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
127 |
* by ns3::Bind. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
128 |
*/ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
129 |
class BooleanDefaultValue : public DefaultValueBase |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
130 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
131 |
public: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
132 |
/** |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
133 |
* \param name name of variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
134 |
* \param help help text which explains the purpose |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
135 |
* and the semantics of this variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
136 |
* \param defaultValue the default value to assign |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
137 |
* to this variable. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
138 |
* |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
139 |
* Unless the user invokes ns3::Bind with the right arguments, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
140 |
* the GetValue method will return the default value. Otherwise, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
141 |
* it will return the user-specified value. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
142 |
*/ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
143 |
BooleanDefaultValue (std::string name, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
144 |
std::string help, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
145 |
bool defaultValue); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
146 |
/** |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
147 |
* \returns the default value for this variable or a |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
148 |
* user-provided overriden variable. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
149 |
*/ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
150 |
bool GetValue (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
151 |
private: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
152 |
virtual bool DoParseValue (const std::string &value); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
153 |
virtual std::string DoGetType (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
154 |
virtual std::string DoGetDefaultValue (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
155 |
bool m_defaultValue; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
156 |
bool m_value; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
157 |
}; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
158 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
159 |
/** |
967
19ad9623162c
a small typo
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
965
diff
changeset
|
160 |
* \brief A Numeric variable for ns3::Bind |
538
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
161 |
* \ingroup config |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
162 |
* |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
163 |
* Every instance of this type is automatically |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
164 |
* registered in the variable pool which is used |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
165 |
* by ns3::Bind. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
166 |
*/ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
167 |
template <typename T> |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
168 |
class NumericDefaultValue : public DefaultValueBase |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
169 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
170 |
public: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
171 |
/** |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
172 |
* \param name the name of the variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
173 |
* \param help help text which explains the purpose |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
174 |
* and the semantics of this variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
175 |
* \param defaultValue the default value assigned |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
176 |
* to this variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
177 |
* |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
178 |
* By default, the set of allowed values is the entire range |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
179 |
* of values which can be stored and retrieved from the underlying |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
180 |
* type. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
181 |
*/ |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
182 |
NumericDefaultValue (std::string name, |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
183 |
std::string help, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
184 |
T defaultValue); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
185 |
/** |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
186 |
* \param name the name of the variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
187 |
* \param help help text which explains the purpose |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
188 |
* and the semantics of this variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
189 |
* \param defaultValue the default value assigned to this |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
190 |
* variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
191 |
* \param minValue the minimum value which can be set |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
192 |
* in this variable |
612
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
193 |
*/ |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
194 |
NumericDefaultValue (std::string name, |
612
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
195 |
std::string help, |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
196 |
T defaultValue, |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
197 |
T minValue); |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
198 |
|
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
199 |
/** |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
200 |
* \param name the name of the variable |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
201 |
* \param help help text which explains the purpose |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
202 |
* and the semantics of this variable |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
203 |
* \param defaultValue the default value assigned to this |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
204 |
* variable |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
205 |
* \param minValue the minimum value which can be set |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
206 |
* in this variable |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
207 |
* \param maxValue the maximum value which can be set in this |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
208 |
* variable. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
209 |
*/ |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
210 |
NumericDefaultValue (std::string name, |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
211 |
std::string help, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
212 |
T defaultValue, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
213 |
T minValue, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
214 |
T maxValue); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
215 |
|
612
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
216 |
void SetValue (T v); |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
217 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
218 |
T GetValue (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
219 |
private: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
220 |
virtual bool DoParseValue (const std::string &value); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
221 |
virtual std::string DoGetType (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
222 |
virtual std::string DoGetDefaultValue (void) const; |
1822
056a2eb1e924
fix bug 100 DefaultValue::Bind for floats
Tom Henderson <tomh@tomh.org>
parents:
1701
diff
changeset
|
223 |
T RealMin (void) const; |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
224 |
T m_defaultValue; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
225 |
T m_minValue; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
226 |
T m_maxValue; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
227 |
T m_value; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
228 |
}; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
229 |
|
538
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
230 |
/** |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
231 |
* \brief Named enumeration defaults |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
232 |
* \ingroup config |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
233 |
* |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
234 |
* Every instance of this type is automatically |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
235 |
* registered in the variable pool which is used |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
236 |
* by ns3::Bind. |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
237 |
*/ |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
238 |
class StringEnumDefaultValue : public DefaultValueBase |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
239 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
240 |
public: |
624
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
241 |
/** |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
242 |
* \param name The name of the variable |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
243 |
* \param help The help string |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
244 |
*/ |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
245 |
StringEnumDefaultValue (const std::string &name, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
246 |
const std::string &help); |
624
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
247 |
/** |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
248 |
* \brief Add a default value to this enumeration of strings |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
249 |
* \param value The string to make the default for this |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
250 |
*/ |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
251 |
void AddDefaultValue (const std::string &value); |
624
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
252 |
/** |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
253 |
* \brief Add a possible value to accept for this default value |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
254 |
*/ |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
255 |
void AddPossibleValue (const std::string &value); |
624
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
256 |
/** |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
257 |
* \brief Get the value of this default value. |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
258 |
* \return The string that has been assigned to this default value, either by |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
259 |
* Bind() or by a command line setting |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
260 |
*/ |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
261 |
std::string GetValue (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
262 |
private: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
263 |
virtual bool DoParseValue (const std::string &value); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
264 |
virtual std::string DoGetType (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
265 |
virtual std::string DoGetDefaultValue (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
266 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
267 |
bool m_oneDefault; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
268 |
std::list<std::string> m_possibleValues; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
269 |
std::string m_defaultValue; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
270 |
std::string m_value; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
271 |
}; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
272 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
273 |
/** |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
274 |
* \brief An enum variable for ns3::Bind |
538
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
275 |
* \ingroup config |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
276 |
* |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
277 |
* Every instance of this type is automatically |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
278 |
* registered in the variable pool which is used |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
279 |
* by ns3::Bind. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
280 |
*/ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
281 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
282 |
class EnumDefaultValue : public DefaultValueBase |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
283 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
284 |
public: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
285 |
/** |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
286 |
* \param name the name of this variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
287 |
* \param help help text which explains the purpose |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
288 |
* and the semantics of this variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
289 |
* \param defaultValue the default value assigned to this |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
290 |
* variable unless it is overriden with ns3::Bind |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
291 |
* \param defaultValueString the string which represents |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
292 |
* the default value which should be used by ns3::Bind |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
293 |
* |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
294 |
* This method takes a variable number of arguments. The list of |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
295 |
* arguments is terminated by the pair of values 0 and (void *)0. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
296 |
* Each pair of extra argument is assumed to be of the form |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
297 |
* (enum value, string representing enum value). If ns3::Bind |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
298 |
* is invoked on this variable, it will check that the user-provided |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
299 |
* values are within the set of values specified in this constructor. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
300 |
* |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
301 |
* Typical useage of this method will look like this: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
302 |
* \code |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
303 |
* enum MyEnum { |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
304 |
* MY_ENUM_A, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
305 |
* MY_ENUM_B, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
306 |
* MY_ENUM_C, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
307 |
* }; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
308 |
* // set default value to be "B". |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
309 |
* static EnumDefaultValue<enum MyEnum> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
310 |
* g_myDefaultValue ("my", "my help", |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
311 |
* MY_ENUM_B, "B", |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
312 |
* MY_ENUM_A, "A", |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
313 |
* MY_ENUM_C, "C",); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
314 |
* 0, (void*)0); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
315 |
* \endcode |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
316 |
* Note that to ensure portability to 64 bit systems, make sure that |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
317 |
* the last element in the variable list of arguments is (void *)0. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
318 |
*/ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
319 |
EnumDefaultValue (const std::string &name, const std::string &help, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
320 |
T defaultValue, const char *defaultValueString, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
321 |
...); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
322 |
void AddPossibleValue (T value, const std::string &valueString); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
323 |
/** |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
324 |
* \returns the default value or any other value specified by the |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
325 |
* user with ns3::Bind |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
326 |
*/ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
327 |
T GetValue (void); |
683
12f6158f0bc8
add EnumDefaultValue::SetValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
624
diff
changeset
|
328 |
/** |
12f6158f0bc8
add EnumDefaultValue::SetValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
624
diff
changeset
|
329 |
* \param value the new default value. |
12f6158f0bc8
add EnumDefaultValue::SetValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
624
diff
changeset
|
330 |
*/ |
12f6158f0bc8
add EnumDefaultValue::SetValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
624
diff
changeset
|
331 |
void SetValue (T value); |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
332 |
private: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
333 |
virtual bool DoParseValue (const std::string &value); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
334 |
virtual std::string DoGetType (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
335 |
virtual std::string DoGetDefaultValue (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
336 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
337 |
typedef std::list<std::pair<T,std::string> > PossibleValues; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
338 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
339 |
T m_defaultValue; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
340 |
PossibleValues m_possibleValues; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
341 |
T m_value; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
342 |
}; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
343 |
|
538
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
344 |
/** |
1823
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
345 |
* \brief A string variable for ns3::Bind |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
346 |
* \ingroup config |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
347 |
* |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
348 |
* Every instance of this type is automatically |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
349 |
* registered in the variable pool which is used |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
350 |
* by ns3::Bind. |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
351 |
*/ |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
352 |
class StringDefaultValue : public DefaultValueBase |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
353 |
{ |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
354 |
public: |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
355 |
StringDefaultValue (const std::string &name, |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
356 |
const std::string &help, |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
357 |
const std::string defaultValue); |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
358 |
StringDefaultValue (const std::string &name, |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
359 |
const std::string &help, |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
360 |
const std::string defaultValue, |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
361 |
int maxSize); |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
362 |
StringDefaultValue (const std::string &name, |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
363 |
const std::string &help, |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
364 |
const std::string defaultValue, |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
365 |
int minSize, |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
366 |
int maxSize); |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
367 |
|
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
368 |
std::string GetValue (void) const; |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
369 |
private: |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
370 |
virtual bool DoParseValue (const std::string &value); |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
371 |
virtual std::string DoGetType (void) const; |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
372 |
virtual std::string DoGetDefaultValue (void) const; |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
373 |
|
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
374 |
std::string m_defaultValue; |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
375 |
std::string m_value; |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
376 |
int m_minSize; |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
377 |
int m_maxSize; |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
378 |
}; |
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
379 |
|
2bb2839641f9
implement StringDefaultValue; bug93 patch from Mathieu
Tom Henderson <tomh@tomh.org>
parents:
1822
diff
changeset
|
380 |
/** |
538
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
381 |
* \brief Class used to call a certain function during the configuration of the |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
382 |
* simulation |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
383 |
* \ingroup config |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
384 |
*/ |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
385 |
class CommandDefaultValue : public DefaultValueBase |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
386 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
387 |
public: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
388 |
CommandDefaultValue (const std::string &name, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
389 |
const std::string &help, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
390 |
Callback<void> cb); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
391 |
private: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
392 |
virtual bool DoParseValue (const std::string &value); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
393 |
virtual std::string DoGetType (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
394 |
virtual std::string DoGetDefaultValue (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
395 |
Callback<void> m_cb; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
396 |
}; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
397 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
398 |
}//namespace ns3 |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
399 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
400 |
#include "type-name.h" |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
401 |
#include "assert.h" |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
402 |
#include <sstream> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
403 |
#include <stdarg.h> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
404 |
#include <limits> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
405 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
406 |
namespace ns3 { |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
407 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
408 |
/************************************************************** |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
409 |
**************************************************************/ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
410 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
411 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
412 |
template <typename T> |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
413 |
NumericDefaultValue<T>::NumericDefaultValue (std::string name, |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
414 |
std::string help, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
415 |
T defaultValue) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
416 |
: DefaultValueBase (name, help), |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
417 |
m_defaultValue (defaultValue), |
1822
056a2eb1e924
fix bug 100 DefaultValue::Bind for floats
Tom Henderson <tomh@tomh.org>
parents:
1701
diff
changeset
|
418 |
m_minValue (RealMin ()), |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
419 |
m_maxValue (std::numeric_limits<T>::max ()), |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
420 |
m_value (defaultValue) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
421 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
422 |
DefaultValueList::Add (this); |
612
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
423 |
NS_ASSERT (m_minValue < m_maxValue); |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
424 |
} |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
425 |
template <typename T> |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
426 |
NumericDefaultValue<T>::NumericDefaultValue (std::string name, |
612
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
427 |
std::string help, |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
428 |
T defaultValue, |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
429 |
T minValue) |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
430 |
: DefaultValueBase (name, help), |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
431 |
m_defaultValue (defaultValue), |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
432 |
m_minValue (minValue), |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
433 |
m_maxValue (std::numeric_limits<T>::max ()), |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
434 |
m_value (defaultValue) |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
435 |
{ |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
436 |
DefaultValueList::Add (this); |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
437 |
NS_ASSERT (m_minValue < m_maxValue); |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
438 |
NS_ASSERT (m_defaultValue <= m_maxValue && |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
439 |
m_defaultValue >= m_minValue); |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
440 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
441 |
template <typename T> |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
442 |
NumericDefaultValue<T>::NumericDefaultValue (std::string name, |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
443 |
std::string help, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
444 |
T defaultValue, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
445 |
T minValue, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
446 |
T maxValue) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
447 |
: DefaultValueBase (name, help), |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
448 |
m_defaultValue (defaultValue), |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
449 |
m_minValue (minValue), |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
450 |
m_maxValue (maxValue), |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
451 |
m_value (defaultValue) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
452 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
453 |
DefaultValueList::Add (this); |
612
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
454 |
NS_ASSERT (m_minValue < m_maxValue); |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
455 |
NS_ASSERT (m_defaultValue <= m_maxValue && |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
456 |
m_defaultValue >= m_minValue); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
457 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
458 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
459 |
template <typename T> |
612
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
460 |
void |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
461 |
NumericDefaultValue<T>::SetValue (T v) |
612
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
462 |
{ |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
463 |
NS_ASSERT (v <= m_maxValue && |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
464 |
v >= m_minValue); |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
465 |
m_value = v; |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
466 |
} |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
467 |
|
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
468 |
template <typename T> |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
469 |
T |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
470 |
NumericDefaultValue<T>::GetValue (void) const |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
471 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
472 |
return m_value; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
473 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
474 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
475 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
476 |
bool |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
477 |
NumericDefaultValue<T>::DoParseValue (const std::string &value) |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
478 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
479 |
std::istringstream iss; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
480 |
iss.str (value); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
481 |
iss >> m_value; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
482 |
if (m_value > m_maxValue || |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
483 |
m_value < m_minValue) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
484 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
485 |
return false; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
486 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
487 |
return !iss.bad () && !iss.fail (); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
488 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
489 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
490 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
491 |
std::string |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
492 |
NumericDefaultValue<T>::DoGetType (void) const |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
493 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
494 |
std::ostringstream oss; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
495 |
oss << TypeNameGet<T> () << "(" |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
496 |
<< m_minValue << ":" |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
497 |
<< m_maxValue << ")"; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
498 |
return oss.str (); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
499 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
500 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
501 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
502 |
std::string |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
503 |
NumericDefaultValue<T>::DoGetDefaultValue (void) const |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
504 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
505 |
std::ostringstream oss; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
506 |
oss << m_defaultValue; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
507 |
return oss.str (); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
508 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
509 |
|
1822
056a2eb1e924
fix bug 100 DefaultValue::Bind for floats
Tom Henderson <tomh@tomh.org>
parents:
1701
diff
changeset
|
510 |
template <typename T> |
056a2eb1e924
fix bug 100 DefaultValue::Bind for floats
Tom Henderson <tomh@tomh.org>
parents:
1701
diff
changeset
|
511 |
T |
056a2eb1e924
fix bug 100 DefaultValue::Bind for floats
Tom Henderson <tomh@tomh.org>
parents:
1701
diff
changeset
|
512 |
NumericDefaultValue<T>::RealMin (void) const |
056a2eb1e924
fix bug 100 DefaultValue::Bind for floats
Tom Henderson <tomh@tomh.org>
parents:
1701
diff
changeset
|
513 |
{ |
056a2eb1e924
fix bug 100 DefaultValue::Bind for floats
Tom Henderson <tomh@tomh.org>
parents:
1701
diff
changeset
|
514 |
if (std::numeric_limits<T>::is_integer) |
056a2eb1e924
fix bug 100 DefaultValue::Bind for floats
Tom Henderson <tomh@tomh.org>
parents:
1701
diff
changeset
|
515 |
{ |
056a2eb1e924
fix bug 100 DefaultValue::Bind for floats
Tom Henderson <tomh@tomh.org>
parents:
1701
diff
changeset
|
516 |
return std::numeric_limits<T>::min (); |
056a2eb1e924
fix bug 100 DefaultValue::Bind for floats
Tom Henderson <tomh@tomh.org>
parents:
1701
diff
changeset
|
517 |
} |
056a2eb1e924
fix bug 100 DefaultValue::Bind for floats
Tom Henderson <tomh@tomh.org>
parents:
1701
diff
changeset
|
518 |
else |
056a2eb1e924
fix bug 100 DefaultValue::Bind for floats
Tom Henderson <tomh@tomh.org>
parents:
1701
diff
changeset
|
519 |
{ |
056a2eb1e924
fix bug 100 DefaultValue::Bind for floats
Tom Henderson <tomh@tomh.org>
parents:
1701
diff
changeset
|
520 |
return -std::numeric_limits<T>::max (); |
056a2eb1e924
fix bug 100 DefaultValue::Bind for floats
Tom Henderson <tomh@tomh.org>
parents:
1701
diff
changeset
|
521 |
} |
056a2eb1e924
fix bug 100 DefaultValue::Bind for floats
Tom Henderson <tomh@tomh.org>
parents:
1701
diff
changeset
|
522 |
} |
056a2eb1e924
fix bug 100 DefaultValue::Bind for floats
Tom Henderson <tomh@tomh.org>
parents:
1701
diff
changeset
|
523 |
|
056a2eb1e924
fix bug 100 DefaultValue::Bind for floats
Tom Henderson <tomh@tomh.org>
parents:
1701
diff
changeset
|
524 |
|
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
525 |
/************************************************************** |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
526 |
**************************************************************/ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
527 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
528 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
529 |
EnumDefaultValue<T>::EnumDefaultValue (const std::string &name, const std::string &help, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
530 |
T defaultValue, const char *defaultValueString, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
531 |
...) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
532 |
: DefaultValueBase (name, help), |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
533 |
m_defaultValue (defaultValue), |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
534 |
m_value (defaultValue) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
535 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
536 |
AddPossibleValue (defaultValue, defaultValueString); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
537 |
va_list list; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
538 |
va_start (list, defaultValueString); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
539 |
while (true) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
540 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
541 |
T v = (T) va_arg (list, int); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
542 |
const char *str = va_arg (list, const char *); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
543 |
if (v == 0 && str == 0) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
544 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
545 |
break; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
546 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
547 |
AddPossibleValue (v, str); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
548 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
549 |
DefaultValueList::Add (this); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
550 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
551 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
552 |
void |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
553 |
EnumDefaultValue<T>::AddPossibleValue (T value, const std::string &valueString) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
554 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
555 |
m_possibleValues.push_back (std::make_pair (value, valueString)); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
556 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
557 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
558 |
T |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
559 |
EnumDefaultValue<T>::GetValue (void) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
560 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
561 |
return m_value; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
562 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
563 |
template <typename T> |
683
12f6158f0bc8
add EnumDefaultValue::SetValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
624
diff
changeset
|
564 |
void |
12f6158f0bc8
add EnumDefaultValue::SetValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
624
diff
changeset
|
565 |
EnumDefaultValue<T>::SetValue (T value) |
12f6158f0bc8
add EnumDefaultValue::SetValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
624
diff
changeset
|
566 |
{ |
12f6158f0bc8
add EnumDefaultValue::SetValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
624
diff
changeset
|
567 |
m_value = value; |
12f6158f0bc8
add EnumDefaultValue::SetValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
624
diff
changeset
|
568 |
} |
12f6158f0bc8
add EnumDefaultValue::SetValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
624
diff
changeset
|
569 |
template <typename T> |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
570 |
bool |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
571 |
EnumDefaultValue<T>::DoParseValue (const std::string &value) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
572 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
573 |
for (typename PossibleValues::iterator i = m_possibleValues.begin (); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
574 |
i != m_possibleValues.end (); i++) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
575 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
576 |
if (value == i->second) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
577 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
578 |
m_value = i->first; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
579 |
return true; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
580 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
581 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
582 |
return false; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
583 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
584 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
585 |
std::string |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
586 |
EnumDefaultValue<T>::DoGetType (void) const |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
587 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
588 |
std::string retval; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
589 |
retval += "("; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
590 |
for (typename PossibleValues::const_iterator i = m_possibleValues.begin (); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
591 |
i != m_possibleValues.end (); i++) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
592 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
593 |
if (i != m_possibleValues.begin ()) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
594 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
595 |
retval += "|"; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
596 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
597 |
retval += i->second; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
598 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
599 |
retval += ")"; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
600 |
return retval; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
601 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
602 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
603 |
std::string |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
604 |
EnumDefaultValue<T>::DoGetDefaultValue (void) const |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
605 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
606 |
for (typename PossibleValues::const_iterator i = m_possibleValues.begin (); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
607 |
i != m_possibleValues.end (); i++) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
608 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
609 |
if (i->first == m_defaultValue) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
610 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
611 |
return i->second; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
612 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
613 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
614 |
// cannot happen theoretically. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
615 |
NS_ASSERT (false); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
616 |
return ""; // quiet compiler |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
617 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
618 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
619 |
}//namespace ns3 |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
620 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
621 |
#endif /* DEFAULT_VALUE_H */ |