Salome HOME
7174e0c78a92b39ed30e67178f67abfd5cbda12a
[tools/simanio.git] / src / SimanIO_Document.cxx
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 #include "SimanIO_Document.hxx"
21
22 SimanIO_Document::SimanIO_Document()
23 {
24 }
25
26 void SimanIO_Document::SetName(const char* theName)
27 {
28   myName = theName;
29 }
30
31 const char* SimanIO_Document::Name() const
32 {
33   return myName.c_str();
34 }
35
36 void SimanIO_Document::AddFile(const bool isResult, const char* theURL,
37                                const AutomaticProcessing theProc, const FileState theState)
38 {
39   SimanIO_File aFile = {theURL, isResult, theProc, theState};
40   AddFile(aFile);
41 }
42
43 void SimanIO_Document::AddFile(const SimanIO_File& theFile)
44 {
45   myFiles.push_back(theFile);
46 }
47
48 const SimanIO_File& SimanIO_Document::File(const int theId) const
49 {
50   DocumentFiles::const_iterator aFIter = myFiles.begin();
51   for(; aFIter != myFiles.end(); aFIter++) {
52     if (aFIter->id == theId)
53       return *aFIter;
54   }
55   static SimanIO_File anEmpty;
56   return anEmpty;
57 }
58
59 //////////////////////////// Iterator methods /////////////////////////
60 SimanIO_Document::FilesIterator::FilesIterator(/*const*/ SimanIO_Document& theDocument)
61 {
62   myIter = theDocument.myFiles.begin();
63   myEnd = theDocument.myFiles.end();
64 }
65
66 void SimanIO_Document::FilesIterator::Next()
67 {
68   myIter++;
69 }
70
71 bool SimanIO_Document::FilesIterator::More()
72 {
73   return myIter != myEnd; 
74 }
75 const bool SimanIO_Document::FilesIterator::IsResult()
76 {
77   return myIter->result;
78 }
79
80 const char* SimanIO_Document::FilesIterator::URL()
81 {
82   return myIter->url.c_str();
83 }
84
85 void SimanIO_Document::FilesIterator::SetURL(const char* theURL)
86 {
87   myIter->url = theURL;
88   //myIter->url(theURL);
89   //std::string test = "abc";
90   //myIter->url(test);
91 }
92
93 const AutomaticProcessing SimanIO_Document::FilesIterator::GetProcessing()
94 {
95   return myIter->proc;
96 }
97
98 const FileState SimanIO_Document::FilesIterator::GetState()
99 {
100   return myIter->state;
101 }
102
103 const int SimanIO_Document::FilesIterator::Id()
104 {
105   return myIter->id;
106 }