1 #ifndef SIMANIO_CONFIGURATION_H
2 #define SIMANIO_CONFIGURATION_H
4 #include <SimanIO_Activity.hxx>
9 * \brief Class for storage and store CFG file information.
12 class SimanIO_Configuration {
13 std::map<int, SimanIO_Activity> myActivities; ///< map of Id of activity t othe activity instance
15 // fileds that are used for file parsing
16 char* myBuffer; // container for one configuration file line
17 std::ifstream* myF; // opened configuration file
18 bool myReuseLine; // if true instead of the next line reading from the file, it must be the current buffer reused
21 * Creates the configuration with no initial data inside (for filling).
23 SimanIO_Configuration();
26 * Fills the configuration, by the input file content (for retrieving).
27 * \param theConfFileName name of the file to be parsed and data retrieved.
28 * \returns true if file was correctly parsed.
30 bool Parse(const char* theConfFileName);
33 * Creates ne wactivity section.
34 * \param theActivity activity data
35 * \param theId identifier of the activity (>0), or zero if identifier must be generated
36 * \returns integer identifier of activity
38 int AddActivity(const SimanIO_Activity& theActivity, const int theId = 0);
41 * Creates or returns existing activity with the given Id.
42 * \param theId identifier of the activity
43 * \return reference to activity, already stored in the configuration
45 SimanIO_Activity& GetOrCreateActivity(const int theId);
48 * Iterator for actifities.
50 class ActivitiesIterator {
51 std::map<int, SimanIO_Activity>::iterator myIter; // activities iterator
52 std::map<int, SimanIO_Activity>::iterator myEnd; // end if activities identifier
54 ///! Initializes iterator of the activities of the certain configuration.
55 ActivitiesIterator(SimanIO_Configuration& theConf);
56 ///! Iterates to the next activity of the Configuration.
58 ///! Returns tru if the current activity exists.
60 ///! Returns the current activity identifier.
61 const int ActivityId();
62 ///! Returns the current activity.
63 SimanIO_Activity& Activity();
67 //! Stores in the buffer the next line from the CFG file
69 //! Parses the activity section
70 bool ParseActivity(char* aName);
71 //! Parses the document section
72 bool ParseDocument(char* aName, SimanIO_Activity& theActivity);
73 //! Parses the file section
74 bool ParseFile(SimanIO_Document& theDocument);