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