Salome HOME
Improve build procedure
[tools/simanio.git] / src / SimanIO_Activity.cxx
1 // Copyright (C) 2013  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.
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_Activity.hxx"
21
22 SimanIO_Activity::SimanIO_Activity()
23 {
24 }
25
26 void SimanIO_Activity::SetName(const char* theName)
27 {
28   myName = theName;
29 }
30
31 const char* SimanIO_Activity::Name() const
32 {
33   return myName.c_str();
34 }
35
36 void SimanIO_Activity::SetModule(const char* theModuleName)
37 {
38   myModule = theModuleName;
39 }
40
41 const char* SimanIO_Activity::Module() const
42 {
43   return myModule.c_str();
44 }
45
46 void SimanIO_Activity::AddDocument(const int theID, const SimanIO_Document& theDoc)
47 {
48   myDocs[theID] = theDoc;
49 }
50
51 SimanIO_Document& SimanIO_Activity::Document(const int theId)
52 {
53   return myDocs[theId];
54 }
55
56 const int SimanIO_Activity::DocumentMaxID() const
57 {
58   if (myDocs.empty()) return -1;
59   return myDocs.rbegin()->first; // documents in map are ordered by ID, so, the last one has the bigger ID
60 }
61
62 SimanIO_Document& SimanIO_Activity::GetOrCreateDocument(const int theId)
63 {
64   if (myDocs.find(theId) == myDocs.end()) {
65     myDocs[theId] = SimanIO_Document();
66   }
67   return myDocs[theId];
68 }
69
70 //////////////////////////// Iterator methods /////////////////////////
71 SimanIO_Activity::DocumentsIterator::DocumentsIterator(/*const*/ SimanIO_Activity& theActivity)
72 {
73   myIter = theActivity.myDocs.begin();
74   myEnd = theActivity.myDocs.end();
75 }
76
77 void SimanIO_Activity::DocumentsIterator::Next()
78 {
79   myIter++;
80 }
81
82 bool SimanIO_Activity::DocumentsIterator::More()
83 {
84   return myIter != myEnd; 
85 }
86
87 /*const*/ SimanIO_Document& SimanIO_Activity::DocumentsIterator::Document()
88 {
89   return myIter->second;
90 }
91
92 const int SimanIO_Activity::DocumentsIterator::DocId()
93 {
94   return myIter->first;
95 }