Salome HOME
Copyrights update 2015.
[tools/simanio.git] / src / SimanIO_Document.hxx
1 // Copyright (C) 2013-2015  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_DOCUMENT_H
21 #define SIMANIO_DOCUMENT_H
22
23 #include "SimanIO.hxx"
24
25 #include <string>
26 #include <list>
27
28 ///! Kinds of automatic actions, accessible for SIMAN file
29 enum AutomaticProcessing {
30   FILE_DOWNLOAD,
31   FILE_IMPORT
32 };
33
34 ///! Possible states of the SIMAN file
35 enum FileState {
36   FILE_ACTUAL,
37   FILE_OUTDATED
38 };
39 ///! Action document data
40 struct SimanIO_File {
41   std::string url;          ///< document url in SIMAN
42   bool result;              ///< if true, document is result, the source otherwise
43   AutomaticProcessing proc; ///< processing kind
44   FileState state;          ///< state of the document
45   int id;                   ///< identifier of the file
46 };
47
48 /**
49  * \brief Class for storage and store CFG file document information.
50  */
51 class SIMANIO_EXPORT SimanIO_Document {
52   std::string myName;   ///< name of the document
53   typedef std::list<SimanIO_File> DocumentFiles;
54   DocumentFiles myFiles; ///< files of the document
55 public:
56   /**
57    * Creates the empty, default document.
58    */
59   SimanIO_Document();
60   
61   /**
62    * Defines the document name.
63    * \param theName name of the document
64    */
65   void SetName(const char* theName);
66   
67   /**
68    * Returns the name of the document.
69    */
70   const char* Name() const;
71
72   /**
73    * Appends the file to this document.
74    * \param isResult if it is true, the document is resulting document, if false - the input document for the activity
75    * \param theURL path to the file
76    * \param theProc automatic processing kind
77    * \param theState file state
78    */
79   void AddFile(const bool isResult, const char* theURL,
80                    const AutomaticProcessing theProc, const FileState theState);
81
82   /**
83    * Appends the file to this document.
84    * \param theFile file with all fields filled
85    */
86   void AddFile(const SimanIO_File& theFile);
87   
88   /**
89    * Returns stored file or empty file.
90    * \param theId identifier of the file
91    * \returns reference to the file, located in the document
92    */
93   const SimanIO_File& File(const int theId) const;
94
95   //! Iterator for activity documents browsing
96   class SIMANIO_EXPORT FilesIterator {
97     DocumentFiles::iterator myIter; ///< iterator by the file of the document
98     DocumentFiles::const_iterator myEnd;  ///< end iteration indicator
99     public:
100     ///! Launches the iterator
101     FilesIterator(/*const*/ SimanIO_Document& theDocument);
102     ///! Iterates to the next file of the document.
103     void Next();
104     ///! Returns tru if the current file exists.
105     bool More();
106     ///! Returns true if the current file is resulting document.
107     const bool IsResult();
108     ///! Returns the current file URL.
109     const char* URL();
110     ///! Set the new URL of the file.
111     void SetURL(const char* theURL);
112     ///! Returns the processing kind
113     const AutomaticProcessing GetProcessing();
114     ///! Returns the file state
115     const FileState GetState();
116     ///! Returns the file Id
117     const int Id();
118   };
119 };
120
121 #endif