A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
config-store.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mathieu Lacage <mathieu.lacage@cutebugs.net>
7
*/
8
9
#ifndef CONFIG_STORE_H
10
#define CONFIG_STORE_H
11
12
#include "
file-config.h
"
13
14
#include "ns3/object-base.h"
15
16
namespace
ns3
17
{
18
19
/**
20
* \defgroup configstore Configuration Store/Load
21
*
22
* \brief Store and load simulation attribute configuration
23
*
24
* ns-3 Objects and their attribute values (default, and per-instance values)
25
* are stored in a specialized internal database. The config-store module
26
* permits these values to be imported and exported to formats of
27
* different types (e.g. XML files, raw text files, or a GTK-based UI).
28
*
29
* While it is possible to generate a sample config file and lightly
30
* edit it to change a couple of values, there are cases where this
31
* process will not work because the same value on the same object
32
* can appear multiple times in the same automatically-generated
33
* configuration file under different configuration paths.
34
*
35
* As such, the best way to use this class is to use it to generate
36
* an initial configuration file, extract from that configuration
37
* file only the strictly necessary elements, and move these minimal
38
* elements to a new configuration file which can then safely
39
* be edited. Another option is to use the ns3::GtkConfigStore class
40
* which will allow you to edit the parameters and will generate
41
* configuration files where all the instances of the same parameter
42
* are changed.
43
*/
44
45
/**
46
* \ingroup configstore
47
*
48
*/
49
class
ConfigStore
:
public
ObjectBase
50
{
51
public
:
52
/**
53
* \enum Mode for ConfigStore operation
54
* \brief store / load mode
55
*/
56
enum
Mode
57
{
58
LOAD
,
59
SAVE
,
60
NONE
61
};
62
63
/**
64
* \enum FileFormat for ConfigStore operation
65
* \brief file format
66
*/
67
/// store format
68
enum
FileFormat
69
{
70
XML
,
71
RAW_TEXT
72
};
73
74
/**
75
* \brief Get the type ID.
76
* \return the object TypeId
77
*/
78
static
TypeId
GetTypeId
();
79
TypeId
GetInstanceTypeId
()
const override
;
80
81
ConfigStore
();
82
~ConfigStore
()
override
;
83
84
/**
85
* Set the mode of operation
86
* \param mode mode of operation
87
*/
88
void
SetMode
(Mode mode);
89
/**
90
* Set the file format
91
* \param format the file format
92
*/
93
void
SetFileFormat
(FileFormat format);
94
/**
95
* Set the filename
96
* \param filename the file name
97
*/
98
void
SetFilename
(std::string filename);
99
/**
100
* Set if to save deprecated attributes
101
* \param saveDeprecated the deprecated attributes save policy
102
*/
103
void
SetSaveDeprecated
(
bool
saveDeprecated);
104
105
/**
106
* Configure the default values
107
*/
108
void
ConfigureDefaults
();
109
/**
110
* Configure the attribute values
111
*/
112
void
ConfigureAttributes
();
113
114
private
:
115
Mode
m_mode
;
///< store mode
116
FileFormat
m_fileFormat
;
///< store format
117
bool
m_saveDeprecated
;
///< save deprecated attributes
118
std::string
m_filename
;
///< store file name
119
FileConfig
*
m_file
;
///< configuration file
120
};
121
122
/**
123
* \brief Stream insertion operator.
124
*
125
* \param [in] os The reference to the output stream.
126
* \param [in] mode The configStore mode.
127
* \returns The reference to the output stream.
128
*/
129
std::ostream&
operator<<
(std::ostream& os,
ConfigStore::Mode
& mode);
130
/**
131
* \brief Stream insertion operator.
132
*
133
* \param [in] os The reference to the output stream.
134
* \param [in] format The configStore file format.
135
* \returns The reference to the output stream.
136
*/
137
std::ostream&
operator<<
(std::ostream& os,
ConfigStore::FileFormat
& format);
138
139
}
// namespace ns3
140
141
#endif
/* CONFIG_STORE_H */
ns3::ConfigStore
Definition
config-store.h:50
ns3::ConfigStore::m_filename
std::string m_filename
store file name
Definition
config-store.h:118
ns3::ConfigStore::SetFilename
void SetFilename(std::string filename)
Set the filename.
Definition
config-store.cc:162
ns3::ConfigStore::m_fileFormat
FileFormat m_fileFormat
store format
Definition
config-store.h:116
ns3::ConfigStore::m_file
FileConfig * m_file
configuration file
Definition
config-store.h:119
ns3::ConfigStore::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
config-store.cc:39
ns3::ConfigStore::Mode
Mode
for ConfigStore operation
Definition
config-store.h:57
ns3::ConfigStore::NONE
@ NONE
Definition
config-store.h:60
ns3::ConfigStore::LOAD
@ LOAD
Definition
config-store.h:58
ns3::ConfigStore::SAVE
@ SAVE
Definition
config-store.h:59
ns3::ConfigStore::ConfigureDefaults
void ConfigureDefaults()
Configure the default values.
Definition
config-store.cc:183
ns3::ConfigStore::SetFileFormat
void SetFileFormat(FileFormat format)
Set the file format.
Definition
config-store.cc:155
ns3::ConfigStore::~ConfigStore
~ConfigStore() override
Definition
config-store.cc:140
ns3::ConfigStore::SetSaveDeprecated
void SetSaveDeprecated(bool saveDeprecated)
Set if to save deprecated attributes.
Definition
config-store.cc:169
ns3::ConfigStore::ConfigStore
ConfigStore()
Definition
config-store.cc:84
ns3::ConfigStore::FileFormat
FileFormat
store format
Definition
config-store.h:69
ns3::ConfigStore::RAW_TEXT
@ RAW_TEXT
Definition
config-store.h:71
ns3::ConfigStore::XML
@ XML
Definition
config-store.h:70
ns3::ConfigStore::SetMode
void SetMode(Mode mode)
Set the mode of operation.
Definition
config-store.cc:148
ns3::ConfigStore::m_saveDeprecated
bool m_saveDeprecated
save deprecated attributes
Definition
config-store.h:117
ns3::ConfigStore::ConfigureAttributes
void ConfigureAttributes()
Configure the attribute values.
Definition
config-store.cc:176
ns3::ConfigStore::m_mode
Mode m_mode
store mode
Definition
config-store.h:115
ns3::ConfigStore::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
config-store.cc:79
ns3::FileConfig
base class for ConfigStore classes using files
Definition
file-config.h:23
ns3::ObjectBase
Anchor the ns-3 type and attribute system.
Definition
object-base.h:162
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
file-config.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition
angles.cc:148
src
config-store
model
config-store.h
Generated on Fri Nov 8 2024 13:58:59 for ns-3 by
1.11.0