Salome HOME
Improve build procedure
[tools/simanio.git] / src / SimanIO_Activity.hxx
1 // Copyright (C) 2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef SIMANIO_ACTIVITY_H
21 #define SIMANIO_ACTIVITY_H
22
23 #include "SimanIO_Document.hxx"
24
25 #include <string>
26 #include <map>
27
28 /**
29  * \brief Class for storage and store CFG file activity information.
30  */
31 class SimanIO_Activity {
32   std::string myName;   ///< name of the activity
33   std::string myModule; ///< module of the activity
34   typedef std::map<int, SimanIO_Document> ActivityDocuments;
35   ActivityDocuments myDocs; ///< documents of the activity, referenced by document ID
36 public:
37   /**
38    * Creates the empty, default activity.
39    */
40   SimanIO_Activity();
41   
42   /**
43    * Defines the activity name.
44    * \param theName name of the activity (enclosed by "" in CFG file).
45    */
46   void SetName(const char* theName);
47   
48   /**
49    * Returns the name of the activity.
50    */
51   const char* Name() const;
52
53   /**
54    * Defines the activity module.
55    * \param theModuleName name of the module in SALOME
56    */
57   void SetModule(const char* theModuleName);
58
59   /**
60    * Returns the module of the activity.
61    */
62   const char* Module() const;
63
64   /**
65    * Appends the documents to this activity.
66    * \param theID identifier of the document, unique for whole configuration file.
67    * \param theDoc document with all fields filled
68    */
69   void AddDocument(const int theID, const SimanIO_Document& theDoc);
70
71   /**
72    * Returns the document by its Id, crashes if there is no such document.
73    * \returns reference to the document.
74    */
75   SimanIO_Document& Document(const int theId);
76
77   /**
78    * Returns id of one of the documents of this activity: maximal ID.
79    * \returns -1 if activity has no documents
80    */
81   const int DocumentMaxID() const;
82   
83   /**
84    * Creates or returns existing document with the given Id.
85    * \param theId identifier of the document
86    * \return reference to document, already stored in the activity
87    */
88   SimanIO_Document& GetOrCreateDocument(const int theId);
89
90   //! Iterator for activity documents browsing
91   class DocumentsIterator {
92     ActivityDocuments::iterator myIter; ///< iterator by the documents of the activity
93     ActivityDocuments::const_iterator myEnd;  ///< end iteration indicator
94     public:
95     ///! Launches the iterator
96     DocumentsIterator(/*const*/ SimanIO_Activity& theActivity);
97     ///! Iterates to the next document of the Activity.
98     void Next();
99     ///! Returns tru if the current document exists.
100     bool More();
101     ///! Returns the current document Id.
102     const int DocId();
103     ///! Returns the current document.
104     /*const*/ SimanIO_Document& Document();
105   };
106 };
107
108 #endif