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 * 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
16namespace 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 */
49class ConfigStore : public ObjectBase
50{
51 public:
52 /**
53 * @enum Mode for ConfigStore operation
54 * @brief store / load mode
55 */
56 enum Mode
57 {
60 NONE
61 };
62
63 /**
64 * @enum FileFormat for ConfigStore operation
65 * @brief file format
66 */
67 /// store format
69 {
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
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 */
129std::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 */
137std::ostream& operator<<(std::ostream& os, ConfigStore::FileFormat& format);
138
139} // namespace ns3
140
141#endif /* CONFIG_STORE_H */
Introspection did not find any typical Config paths.
std::string m_filename
store file name
void SetFilename(std::string filename)
Set the filename.
FileFormat m_fileFormat
store format
FileConfig * m_file
configuration file
static TypeId GetTypeId()
Get the type ID.
Mode
for ConfigStore operation
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
void SetMode(Mode mode)
Set the mode of operation.
bool m_saveDeprecated
save deprecated attributes
void ConfigureAttributes()
Configure the attribute values.
Mode m_mode
store mode
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
base class for ConfigStore classes using files
Definition file-config.h:23
Anchor the ns-3 type and attribute system.
a unique identifier for an interface.
Definition type-id.h:48
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:148