author | Gustavo J. A. M. Carneiro <gjc@inescporto.pt> |
Mon, 08 Oct 2007 17:49:18 +0100 | |
changeset 1701 | 5e9bd24a8716 |
parent 1224 | 7cbc1d661b89 |
child 1822 | 056a2eb1e924 |
child 1962 | 600b310a3218 |
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 |
/** |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
28 |
* \defgroup config Simulation configuration |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
29 |
* |
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 |
|
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
32 |
namespace ns3 { |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
33 |
|
1224
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
34 |
namespace DefaultValue |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
35 |
{ |
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 |
* \ingroup config |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
39 |
* \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
|
40 |
* \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
|
41 |
* |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
42 |
* 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
|
43 |
* 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
|
44 |
* 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
|
45 |
* 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
|
46 |
* 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
|
47 |
*/ |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
967
diff
changeset
|
48 |
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
|
49 |
|
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 |
|
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
53 |
class DefaultValueBase |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
54 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
55 |
public: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
56 |
virtual ~DefaultValueBase (); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
57 |
std::string GetName (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
58 |
std::string GetHelp (void) const; |
965
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
59 |
|
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 |
* \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
|
62 |
* |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
63 |
* 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
|
64 |
* and it successfully completes. Dirtyness indicates |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
65 |
* 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
|
66 |
*/ |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
67 |
bool IsDirty (void) const; |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
68 |
/** |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
69 |
* Clear the dirty state. |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
70 |
*/ |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
71 |
void ClearDirtyFlag (void); |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
72 |
// parse a matching parameter |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
73 |
// return true in case of success, false otherwise. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
74 |
bool ParseValue (const std::string &value); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
75 |
std::string GetType (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
76 |
std::string GetDefaultValue (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
77 |
protected: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
78 |
DefaultValueBase (const std::string &name, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
79 |
const std::string &help); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
80 |
private: |
965
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
81 |
DefaultValueBase (); |
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
82 |
private: |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
83 |
virtual bool DoParseValue (const std::string &value) = 0; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
84 |
virtual std::string DoGetType (void) const = 0; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
85 |
virtual std::string DoGetDefaultValue (void) const = 0; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
86 |
std::string m_name; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
87 |
std::string m_help; |
965
afb54e2e7d59
add dirtyness tracking to DefaultValueBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
959
diff
changeset
|
88 |
bool m_dirty; |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
89 |
}; |
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 |
class DefaultValueList |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
92 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
93 |
public: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
94 |
typedef std::list<DefaultValueBase *>::iterator Iterator; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
95 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
96 |
static Iterator Begin (void); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
97 |
static Iterator End (void); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
98 |
static void Remove (const std::string &name); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
99 |
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
|
100 |
|
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
101 |
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
|
102 |
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
|
103 |
{ |
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
104 |
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
|
105 |
{ |
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
106 |
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
|
107 |
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
|
108 |
{ |
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
109 |
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
|
110 |
} |
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 |
return NULL; |
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
113 |
} |
5e9bd24a8716
Bug 82 (Add convenience API to retrieve default values)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1224
diff
changeset
|
114 |
|
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
115 |
private: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
116 |
typedef std::list<DefaultValueBase *> List; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
117 |
static List *GetList (void); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
118 |
}; |
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 |
* \brief A Boolean variable for ns3::Bind |
538
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
122 |
* \ingroup config |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
123 |
* |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
124 |
* Every instance of this type is automatically |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
125 |
* registered in the variable pool which is used |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
126 |
* by ns3::Bind. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
127 |
*/ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
128 |
class BooleanDefaultValue : public DefaultValueBase |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
129 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
130 |
public: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
131 |
/** |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
132 |
* \param name name of variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
133 |
* \param help help text which explains the purpose |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
134 |
* and the semantics of this variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
135 |
* \param defaultValue the default value to assign |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
136 |
* to this variable. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
137 |
* |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
138 |
* 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
|
139 |
* 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
|
140 |
* it will return the user-specified value. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
141 |
*/ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
142 |
BooleanDefaultValue (std::string name, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
143 |
std::string help, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
144 |
bool defaultValue); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
145 |
/** |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
146 |
* \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
|
147 |
* user-provided overriden variable. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
148 |
*/ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
149 |
bool GetValue (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
150 |
private: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
151 |
virtual bool DoParseValue (const std::string &value); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
152 |
virtual std::string DoGetType (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
153 |
virtual std::string DoGetDefaultValue (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
154 |
bool m_defaultValue; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
155 |
bool m_value; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
156 |
}; |
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 |
/** |
967
19ad9623162c
a small typo
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
965
diff
changeset
|
159 |
* \brief A Numeric variable for ns3::Bind |
538
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
160 |
* \ingroup config |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
161 |
* |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
162 |
* Every instance of this type is automatically |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
163 |
* registered in the variable pool which is used |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
164 |
* by ns3::Bind. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
165 |
*/ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
166 |
template <typename T> |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
167 |
class NumericDefaultValue : public DefaultValueBase |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
168 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
169 |
public: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
170 |
/** |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
171 |
* \param name the name of the variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
172 |
* \param help help text which explains the purpose |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
173 |
* and the semantics of this variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
174 |
* \param defaultValue the default value assigned |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
175 |
* to this variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
176 |
* |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
177 |
* 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
|
178 |
* 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
|
179 |
* type. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
180 |
*/ |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
181 |
NumericDefaultValue (std::string name, |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
182 |
std::string help, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
183 |
T defaultValue); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
184 |
/** |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
185 |
* \param name the name of the variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
186 |
* \param help help text which explains the purpose |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
187 |
* and the semantics of this variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
188 |
* \param defaultValue the default value assigned to this |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
189 |
* variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
190 |
* \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
|
191 |
* in this variable |
612
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
192 |
*/ |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
193 |
NumericDefaultValue (std::string name, |
612
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
194 |
std::string help, |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
195 |
T defaultValue, |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
196 |
T minValue); |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
197 |
|
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 |
* \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
|
200 |
* \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
|
201 |
* and the semantics of this variable |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
202 |
* \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
|
203 |
* variable |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
204 |
* \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
|
205 |
* in this variable |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
206 |
* \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
|
207 |
* variable. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
208 |
*/ |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
209 |
NumericDefaultValue (std::string name, |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
210 |
std::string help, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
211 |
T defaultValue, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
212 |
T minValue, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
213 |
T maxValue); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
214 |
|
612
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
215 |
void SetValue (T v); |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
216 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
217 |
T GetValue (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
218 |
private: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
219 |
virtual bool DoParseValue (const std::string &value); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
220 |
virtual std::string DoGetType (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
221 |
virtual std::string DoGetDefaultValue (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
222 |
T m_defaultValue; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
223 |
T m_minValue; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
224 |
T m_maxValue; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
225 |
T m_value; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
226 |
}; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
227 |
|
538
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
228 |
/** |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
229 |
* \brief Named enumeration defaults |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
230 |
* \ingroup config |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
231 |
* |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
232 |
* Every instance of this type is automatically |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
233 |
* registered in the variable pool which is used |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
234 |
* by ns3::Bind. |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
235 |
*/ |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
236 |
class StringEnumDefaultValue : public DefaultValueBase |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
237 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
238 |
public: |
624
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
239 |
/** |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
240 |
* \param name The name of the variable |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
241 |
* \param help The help string |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
242 |
*/ |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
243 |
StringEnumDefaultValue (const std::string &name, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
244 |
const std::string &help); |
624
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
245 |
/** |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
246 |
* \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
|
247 |
* \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
|
248 |
*/ |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
249 |
void AddDefaultValue (const std::string &value); |
624
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
250 |
/** |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
251 |
* \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
|
252 |
*/ |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
253 |
void AddPossibleValue (const std::string &value); |
624
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
254 |
/** |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
255 |
* \brief Get the value of this default value. |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
256 |
* \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
|
257 |
* Bind() or by a command line setting |
11cc5c692eb4
datarate, packet, defaultvalue, object dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
612
diff
changeset
|
258 |
*/ |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
259 |
std::string GetValue (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
260 |
private: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
261 |
virtual bool DoParseValue (const std::string &value); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
262 |
virtual std::string DoGetType (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
263 |
virtual std::string DoGetDefaultValue (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
264 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
265 |
bool m_oneDefault; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
266 |
std::list<std::string> m_possibleValues; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
267 |
std::string m_defaultValue; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
268 |
std::string m_value; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
269 |
}; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
270 |
|
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 |
* \brief An enum variable for ns3::Bind |
538
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
273 |
* \ingroup config |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
274 |
* |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
275 |
* Every instance of this type is automatically |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
276 |
* registered in the variable pool which is used |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
277 |
* by ns3::Bind. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
278 |
*/ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
279 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
280 |
class EnumDefaultValue : public DefaultValueBase |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
281 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
282 |
public: |
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 |
* \param name the name of this variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
285 |
* \param help help text which explains the purpose |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
286 |
* and the semantics of this variable |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
287 |
* \param defaultValue the default value assigned to this |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
288 |
* variable unless it is overriden with ns3::Bind |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
289 |
* \param defaultValueString the string which represents |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
290 |
* 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
|
291 |
* |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
292 |
* 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
|
293 |
* 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
|
294 |
* 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
|
295 |
* (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
|
296 |
* 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
|
297 |
* 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
|
298 |
* |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
299 |
* 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
|
300 |
* \code |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
301 |
* enum MyEnum { |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
302 |
* MY_ENUM_A, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
303 |
* MY_ENUM_B, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
304 |
* MY_ENUM_C, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
305 |
* }; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
306 |
* // set default value to be "B". |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
307 |
* static EnumDefaultValue<enum MyEnum> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
308 |
* g_myDefaultValue ("my", "my help", |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
309 |
* MY_ENUM_B, "B", |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
310 |
* MY_ENUM_A, "A", |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
311 |
* MY_ENUM_C, "C",); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
312 |
* 0, (void*)0); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
313 |
* \endcode |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
314 |
* 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
|
315 |
* 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
|
316 |
*/ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
317 |
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
|
318 |
T defaultValue, const char *defaultValueString, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
319 |
...); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
320 |
void AddPossibleValue (T value, const std::string &valueString); |
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 |
* \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
|
323 |
* user with ns3::Bind |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
324 |
*/ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
325 |
T GetValue (void); |
683
12f6158f0bc8
add EnumDefaultValue::SetValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
624
diff
changeset
|
326 |
/** |
12f6158f0bc8
add EnumDefaultValue::SetValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
624
diff
changeset
|
327 |
* \param value the new default value. |
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 |
void SetValue (T value); |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
330 |
private: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
331 |
virtual bool DoParseValue (const std::string &value); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
332 |
virtual std::string DoGetType (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
333 |
virtual std::string DoGetDefaultValue (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
334 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
335 |
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
|
336 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
337 |
T m_defaultValue; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
338 |
PossibleValues m_possibleValues; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
339 |
T m_value; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
340 |
}; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
341 |
|
538
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
342 |
/** |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
343 |
* \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
|
344 |
* simulation |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
345 |
* \ingroup config |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
346 |
*/ |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
347 |
class CommandDefaultValue : public DefaultValueBase |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
348 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
349 |
public: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
350 |
CommandDefaultValue (const std::string &name, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
351 |
const std::string &help, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
352 |
Callback<void> cb); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
353 |
private: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
354 |
virtual bool DoParseValue (const std::string &value); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
355 |
virtual std::string DoGetType (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
356 |
virtual std::string DoGetDefaultValue (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
357 |
Callback<void> m_cb; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
358 |
}; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
359 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
360 |
}//namespace ns3 |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
361 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
362 |
#include "type-name.h" |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
363 |
#include "assert.h" |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
364 |
#include <sstream> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
365 |
#include <stdarg.h> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
366 |
#include <limits> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
367 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
368 |
namespace ns3 { |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
369 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
370 |
/************************************************************** |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
371 |
**************************************************************/ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
372 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
373 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
374 |
template <typename T> |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
375 |
NumericDefaultValue<T>::NumericDefaultValue (std::string name, |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
376 |
std::string help, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
377 |
T defaultValue) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
378 |
: DefaultValueBase (name, help), |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
379 |
m_defaultValue (defaultValue), |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
380 |
m_minValue (std::numeric_limits<T>::min ()), |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
381 |
m_maxValue (std::numeric_limits<T>::max ()), |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
382 |
m_value (defaultValue) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
383 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
384 |
DefaultValueList::Add (this); |
612
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
385 |
NS_ASSERT (m_minValue < m_maxValue); |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
386 |
} |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
387 |
template <typename T> |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
388 |
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
|
389 |
std::string help, |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
390 |
T defaultValue, |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
391 |
T minValue) |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
392 |
: DefaultValueBase (name, help), |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
393 |
m_defaultValue (defaultValue), |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
394 |
m_minValue (minValue), |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
395 |
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
|
396 |
m_value (defaultValue) |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
397 |
{ |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
398 |
DefaultValueList::Add (this); |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
399 |
NS_ASSERT (m_minValue < m_maxValue); |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
400 |
NS_ASSERT (m_defaultValue <= m_maxValue && |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
401 |
m_defaultValue >= m_minValue); |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
402 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
403 |
template <typename T> |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
404 |
NumericDefaultValue<T>::NumericDefaultValue (std::string name, |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
405 |
std::string help, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
406 |
T defaultValue, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
407 |
T minValue, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
408 |
T maxValue) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
409 |
: DefaultValueBase (name, help), |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
410 |
m_defaultValue (defaultValue), |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
411 |
m_minValue (minValue), |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
412 |
m_maxValue (maxValue), |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
413 |
m_value (defaultValue) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
414 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
415 |
DefaultValueList::Add (this); |
612
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
416 |
NS_ASSERT (m_minValue < m_maxValue); |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
417 |
NS_ASSERT (m_defaultValue <= m_maxValue && |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
418 |
m_defaultValue >= m_minValue); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
419 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
420 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
421 |
template <typename T> |
612
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
422 |
void |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
423 |
NumericDefaultValue<T>::SetValue (T v) |
612
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 |
NS_ASSERT (v <= m_maxValue && |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
426 |
v >= m_minValue); |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
427 |
m_value = v; |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
428 |
} |
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
429 |
|
ffba29d7bdb2
add a few features to IntegerDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
430 |
template <typename T> |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
431 |
T |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
432 |
NumericDefaultValue<T>::GetValue (void) const |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
433 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
434 |
return m_value; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
435 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
436 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
437 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
438 |
bool |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
439 |
NumericDefaultValue<T>::DoParseValue (const std::string &value) |
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 |
std::istringstream iss; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
442 |
iss.str (value); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
443 |
iss >> m_value; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
444 |
if (m_value > m_maxValue || |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
445 |
m_value < m_minValue) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
446 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
447 |
return false; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
448 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
449 |
return !iss.bad () && !iss.fail (); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
450 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
451 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
452 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
453 |
std::string |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
454 |
NumericDefaultValue<T>::DoGetType (void) const |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
455 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
456 |
std::ostringstream oss; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
457 |
oss << TypeNameGet<T> () << "(" |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
458 |
<< m_minValue << ":" |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
459 |
<< m_maxValue << ")"; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
460 |
return oss.str (); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
461 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
462 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
463 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
464 |
std::string |
959
bc215f926abd
IntegerDefaultValue -> NumericDefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
683
diff
changeset
|
465 |
NumericDefaultValue<T>::DoGetDefaultValue (void) const |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
466 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
467 |
std::ostringstream oss; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
468 |
oss << m_defaultValue; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
469 |
return oss.str (); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
470 |
} |
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 |
/************************************************************** |
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 |
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
|
477 |
T defaultValue, const char *defaultValueString, |
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 |
: DefaultValueBase (name, help), |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
480 |
m_defaultValue (defaultValue), |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
481 |
m_value (defaultValue) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
482 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
483 |
AddPossibleValue (defaultValue, defaultValueString); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
484 |
va_list list; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
485 |
va_start (list, defaultValueString); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
486 |
while (true) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
487 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
488 |
T v = (T) va_arg (list, int); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
489 |
const char *str = va_arg (list, const char *); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
490 |
if (v == 0 && str == 0) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
491 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
492 |
break; |
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 |
AddPossibleValue (v, str); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
495 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
496 |
DefaultValueList::Add (this); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
497 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
498 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
499 |
void |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
500 |
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
|
501 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
502 |
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
|
503 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
504 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
505 |
T |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
506 |
EnumDefaultValue<T>::GetValue (void) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
507 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
508 |
return m_value; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
509 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
510 |
template <typename T> |
683
12f6158f0bc8
add EnumDefaultValue::SetValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
624
diff
changeset
|
511 |
void |
12f6158f0bc8
add EnumDefaultValue::SetValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
624
diff
changeset
|
512 |
EnumDefaultValue<T>::SetValue (T value) |
12f6158f0bc8
add EnumDefaultValue::SetValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
624
diff
changeset
|
513 |
{ |
12f6158f0bc8
add EnumDefaultValue::SetValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
624
diff
changeset
|
514 |
m_value = value; |
12f6158f0bc8
add EnumDefaultValue::SetValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
624
diff
changeset
|
515 |
} |
12f6158f0bc8
add EnumDefaultValue::SetValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
624
diff
changeset
|
516 |
template <typename T> |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
517 |
bool |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
518 |
EnumDefaultValue<T>::DoParseValue (const std::string &value) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
519 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
520 |
for (typename PossibleValues::iterator i = m_possibleValues.begin (); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
521 |
i != m_possibleValues.end (); i++) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
522 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
523 |
if (value == i->second) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
524 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
525 |
m_value = i->first; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
526 |
return true; |
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 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
529 |
return false; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
530 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
531 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
532 |
std::string |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
533 |
EnumDefaultValue<T>::DoGetType (void) const |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
534 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
535 |
std::string retval; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
536 |
retval += "("; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
537 |
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
|
538 |
i != m_possibleValues.end (); i++) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
539 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
540 |
if (i != m_possibleValues.begin ()) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
541 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
542 |
retval += "|"; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
543 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
544 |
retval += i->second; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
545 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
546 |
retval += ")"; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
547 |
return retval; |
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 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
550 |
std::string |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
551 |
EnumDefaultValue<T>::DoGetDefaultValue (void) const |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
552 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
553 |
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
|
554 |
i != m_possibleValues.end (); i++) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
555 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
556 |
if (i->first == m_defaultValue) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
557 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
558 |
return i->second; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
559 |
} |
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 |
// cannot happen theoretically. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
562 |
NS_ASSERT (false); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
563 |
return ""; // quiet compiler |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
564 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
565 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
566 |
}//namespace ns3 |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
567 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
568 |
#endif /* DEFAULT_VALUE_H */ |