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