src/contrib/config-store.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue, 02 Sep 2008 10:12:14 -0700
changeset 3576 f6abfdf47163
parent 3076 6d7f78ceeccc
child 4273 fb4423206618
permissions -rw-r--r--
bug 303: return value should not be const
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2958
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
#ifndef CONFIG_STORE_H
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
#define CONFIG_STORE_H
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
#include "ns3/object-base.h"
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
namespace ns3 {
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
2962
39f72ca0ba8e improve doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2958
diff changeset
     8
/**
39f72ca0ba8e improve doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2958
diff changeset
     9
 * \brief Store and load simulation attribute configuration
39f72ca0ba8e improve doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2958
diff changeset
    10
 *
3076
6d7f78ceeccc improve doxygen doc.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3063
diff changeset
    11
 * While it is possible to generate a sample config file and lightly
6d7f78ceeccc improve doxygen doc.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3063
diff changeset
    12
 * edit it to change a couple of values, there are cases where this
6d7f78ceeccc improve doxygen doc.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3063
diff changeset
    13
 * process will not work because the same value on the same object
6d7f78ceeccc improve doxygen doc.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3063
diff changeset
    14
 * can appear multiple times in the same automatically-generated 
6d7f78ceeccc improve doxygen doc.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3063
diff changeset
    15
 * configuration file under different configuration paths.
6d7f78ceeccc improve doxygen doc.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3063
diff changeset
    16
 *
6d7f78ceeccc improve doxygen doc.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3063
diff changeset
    17
 * As such, the best way to use this class is to use it to generate
6d7f78ceeccc improve doxygen doc.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3063
diff changeset
    18
 * an initial configuration file, extract from that configuration
6d7f78ceeccc improve doxygen doc.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3063
diff changeset
    19
 * file only the strictly necessary elements, and move these minimal
6d7f78ceeccc improve doxygen doc.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3063
diff changeset
    20
 * elements to a new configuration file which can then safely
6d7f78ceeccc improve doxygen doc.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3063
diff changeset
    21
 * be edited. Another option is to use the ns3::GtkConfigStore class
6d7f78ceeccc improve doxygen doc.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3063
diff changeset
    22
 * which will allow you to edit the parameters and will generate 
6d7f78ceeccc improve doxygen doc.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3063
diff changeset
    23
 * configuration files where all the instances of the same parameter
6d7f78ceeccc improve doxygen doc.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3063
diff changeset
    24
 * are changed.
2962
39f72ca0ba8e improve doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2958
diff changeset
    25
 */
2958
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
class ConfigStore : public ObjectBase
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
{
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
public:
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
  static TypeId GetTypeId (void);
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
  virtual TypeId GetInstanceTypeId (void) const;
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
  ConfigStore ();
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
2962
39f72ca0ba8e improve doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2958
diff changeset
    34
  /**
39f72ca0ba8e improve doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2958
diff changeset
    35
   * Depending on which attribute was set:
39f72ca0ba8e improve doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2958
diff changeset
    36
   *  - Store simulation configuration in file and exit
39f72ca0ba8e improve doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2958
diff changeset
    37
   *  - Load simulation configuration from file and proceed.
39f72ca0ba8e improve doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2958
diff changeset
    38
   */
2958
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
  void Configure (void);
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    41
private:
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    42
  void LoadFrom (std::string filename);
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
  void StoreTo (std::string filename);
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    45
  std::string m_loadFilename;
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
  std::string m_storeFilename;
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
};
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    49
}  // namespace ns3
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
f6ec069d17da ConfigStore allows you to dump and read from a file a simulation configuration
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
#endif /* CONFIG_STORE_H */