A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
config-store.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@cutebugs.net>
18 */
19
20#ifndef CONFIG_STORE_H
21#define CONFIG_STORE_H
22
23#include "file-config.h"
24
25#include "ns3/object-base.h"
26
27namespace ns3
28{
29
30/**
31 * \defgroup configstore Configuration Store/Load
32 *
33 * \brief Store and load simulation attribute configuration
34 *
35 * ns-3 Objects and their attribute values (default, and per-instance values)
36 * are stored in a specialized internal database. The config-store module
37 * permits these values to be imported and exported to formats of
38 * different types (e.g. XML files, raw text files, or a GTK-based UI).
39 *
40 * While it is possible to generate a sample config file and lightly
41 * edit it to change a couple of values, there are cases where this
42 * process will not work because the same value on the same object
43 * can appear multiple times in the same automatically-generated
44 * configuration file under different configuration paths.
45 *
46 * As such, the best way to use this class is to use it to generate
47 * an initial configuration file, extract from that configuration
48 * file only the strictly necessary elements, and move these minimal
49 * elements to a new configuration file which can then safely
50 * be edited. Another option is to use the ns3::GtkConfigStore class
51 * which will allow you to edit the parameters and will generate
52 * configuration files where all the instances of the same parameter
53 * are changed.
54 */
55
56/**
57 * \ingroup configstore
58 *
59 */
60class ConfigStore : public ObjectBase
61{
62 public:
63 /**
64 * \enum Mode for ConfigStore operation
65 * \brief store / load mode
66 */
67 enum Mode
68 {
71 NONE
72 };
73
74 /**
75 * \enum FileFormat for ConfigStore operation
76 * \brief file format
77 */
78 /// store format
80 {
83 };
84
85 /**
86 * \brief Get the type ID.
87 * \return the object TypeId
88 */
89 static TypeId GetTypeId();
90 TypeId GetInstanceTypeId() const override;
91
93 ~ConfigStore() override;
94
95 /**
96 * Set the mode of operation
97 * \param mode mode of operation
98 */
99 void SetMode(Mode mode);
100 /**
101 * Set the file format
102 * \param format the file format
103 */
104 void SetFileFormat(FileFormat format);
105 /**
106 * Set the filename
107 * \param filename the file name
108 */
109 void SetFilename(std::string filename);
110 /**
111 * Set if to save deprecated attributes
112 * \param saveDeprecated the deprecated attributes save policy
113 */
114 void SetSaveDeprecated(bool saveDeprecated);
115
116 /**
117 * Configure the default values
118 */
119 void ConfigureDefaults();
120 /**
121 * Configure the attribute values
122 */
123 void ConfigureAttributes();
124
125 private:
126 Mode m_mode; ///< store mode
127 FileFormat m_fileFormat; ///< store format
128 bool m_saveDeprecated; ///< save deprecated attributes
129 std::string m_filename; ///< store file name
130 FileConfig* m_file; ///< configuration file
131};
132
133/**
134 * \brief Stream insertion operator.
135 *
136 * \param [in] os The reference to the output stream.
137 * \param [in] mode The configStore mode.
138 * \returns The reference to the output stream.
139 */
140std::ostream& operator<<(std::ostream& os, ConfigStore::Mode& mode);
141/**
142 * \brief Stream insertion operator.
143 *
144 * \param [in] os The reference to the output stream.
145 * \param [in] format The configStore file format.
146 * \returns The reference to the output stream.
147 */
148std::ostream& operator<<(std::ostream& os, ConfigStore::FileFormat& format);
149
150} // namespace ns3
151
152#endif /* CONFIG_STORE_H */
Introspection did not find any typical Config paths.
Definition: config-store.h:61
std::string m_filename
store file name
Definition: config-store.h:129
void SetFilename(std::string filename)
Set the filename.
FileFormat m_fileFormat
store format
Definition: config-store.h:127
FileConfig * m_file
configuration file
Definition: config-store.h:130
static TypeId GetTypeId()
Get the type ID.
Definition: config-store.cc:50
Mode
for ConfigStore operation
Definition: config-store.h:68
void ConfigureDefaults()
Configure the default values.
void SetFileFormat(FileFormat format)
Set the file format.
~ConfigStore() override
void SetSaveDeprecated(bool saveDeprecated)
Set if to save deprecated attributes.
FileFormat
store format
Definition: config-store.h:80
void SetMode(Mode mode)
Set the mode of operation.
bool m_saveDeprecated
save deprecated attributes
Definition: config-store.h:128
void ConfigureAttributes()
Configure the attribute values.
Mode m_mode
store mode
Definition: config-store.h:126
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: config-store.cc:86
base class for ConfigStore classes using files
Definition: file-config.h:34
Anchor the ns-3 type and attribute system.
Definition: object-base.h:173
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159