1 // Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library 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 GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef SIMANIO_CONFIGURATION_H
21 #define SIMANIO_CONFIGURATION_H
23 #include "SimanIO_Activity.hxx"
29 * \brief Class for storage and store CFG file information.
32 class SimanIO_Configuration {
33 std::map<int, SimanIO_Activity> myActivities; ///< map of Id of activity t othe activity instance
35 // fileds that are used for file parsing
36 char* myBuffer; // container for one configuration file line
37 std::ifstream* myF; // opened configuration file
38 bool myReuseLine; // if true instead of the next line reading from the file, it must be the current buffer reused
41 * Creates the configuration with no initial data inside (for filling).
43 SimanIO_Configuration();
46 * Fills the configuration, by the input file content (for retrieving).
47 * \param theConfFileName name of the file to be parsed and data retrieved.
48 * \returns true if file was correctly parsed.
50 bool Parse(const char* theConfFileName);
53 * Creates ne wactivity section.
54 * \param theActivity activity data
55 * \param theId identifier of the activity (>0), or zero if identifier must be generated
56 * \returns integer identifier of activity
58 int AddActivity(const SimanIO_Activity& theActivity, const int theId = 0);
61 * Creates or returns existing activity with the given Id.
62 * \param theId identifier of the activity
63 * \return reference to activity, already stored in the configuration
65 SimanIO_Activity& GetOrCreateActivity(const int theId);
68 * Iterator for actifities.
70 class ActivitiesIterator {
71 std::map<int, SimanIO_Activity>::iterator myIter; // activities iterator
72 std::map<int, SimanIO_Activity>::iterator myEnd; // end if activities identifier
74 ///! Initializes iterator of the activities of the certain configuration.
75 ActivitiesIterator(SimanIO_Configuration& theConf);
76 ///! Iterates to the next activity of the Configuration.
78 ///! Returns tru if the current activity exists.
80 ///! Returns the current activity identifier.
81 const int ActivityId();
82 ///! Returns the current activity.
83 SimanIO_Activity& Activity();
87 //! Stores in the buffer the next line from the CFG file
89 //! Parses the activity section
90 bool ParseActivity(char* aName);
91 //! Parses the document section
92 bool ParseDocument(char* aName, SimanIO_Activity& theActivity);
93 //! Parses the file section
94 bool ParseFile(SimanIO_Document& theDocument);