Salome HOME
Check-in operation without any modifications is possible
[tools/simanio.git] / src / SimanIO_Activity.hxx
1 #ifndef SIMANIO_ACTIVITY_H
2 #define SIMANIO_ACTIVITY_H
3
4 #include <SimanIO_Document.hxx>
5
6 #include <map>
7
8 /**
9  * \brief Class for storage and store CFG file activity information.
10  */
11 class SimanIO_Activity {
12   std::string myName;   ///< name of the activity
13   std::string myModule; ///< module of the activity
14   typedef std::map<int, SimanIO_Document> ActivityDocuments;
15   ActivityDocuments myDocs; ///< documents of the activity, referenced by document ID
16 public:
17   /**
18    * Creates the empty, default activity.
19    */
20   SimanIO_Activity();
21   
22   /**
23    * Defines the activity name.
24    * \param theName name of the activity (enclosed by "" in CFG file).
25    */
26   void SetName(const char* theName);
27   
28   /**
29    * Returns the name of the activity.
30    */
31   const char* Name() const;
32
33   /**
34    * Defines the activity module.
35    * \param theModuleName name of the module in SALOME
36    */
37   void SetModule(const char* theModuleName);
38
39   /**
40    * Returns the module of the activity.
41    */
42   const char* Module() const;
43
44   /**
45    * Appends the documents to this activity.
46    * \param theID identifier of the document, unique for whole configuration file.
47    * \param theDoc document with all fields filled
48    */
49   void AddDocument(const int theID, const SimanIO_Document& theDoc);
50
51   /**
52    * Returns the document by its Id, crashes if there is no such document.
53    * \returns reference to the document.
54    */
55   SimanIO_Document& Document(const int theId);
56
57   /**
58    * Returns id of one of the documents of this activity: maximal ID.
59    * \returns -1 if activity has no documents
60    */
61   const int DocumentMaxID() const;
62   
63   /**
64    * Creates or returns existing document with the given Id.
65    * \param theId identifier of the document
66    * \return reference to document, already stored in the activity
67    */
68   SimanIO_Document& GetOrCreateDocument(const int theId);
69
70   //! Iterator for activity documents browsing
71   class DocumentsIterator {
72     ActivityDocuments::iterator myIter; ///< iterator by the documents of the activity
73     ActivityDocuments::const_iterator myEnd;  ///< end iteration indicator
74     public:
75     ///! Launches the iterator
76     DocumentsIterator(/*const*/ SimanIO_Activity& theActivity);
77     ///! Iterates to the next document of the Activity.
78     void Next();
79     ///! Returns tru if the current document exists.
80     bool More();
81     ///! Returns the current document Id.
82     const int DocId();
83     ///! Returns the current document.
84     /*const*/ SimanIO_Document& Document();
85   };
86 };
87
88 #endif