Salome HOME
updated copyright message
[modules/paravis.git] / src / Plugins / MEDReader / plugin / MEDLoaderForPV / MEDTimeReq.cxx
1 // Copyright (C) 2010-2023  CEA, EDF
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 // Author : Anthony Geay
20
21 #include "MEDTimeReq.hxx"
22
23 #include <sstream>
24
25 MEDTimeReq::~MEDTimeReq()
26 {
27 }
28
29 ///////////
30
31 MEDStdTimeReq::~MEDStdTimeReq()
32 {
33 }
34
35 MEDStdTimeReq::MEDStdTimeReq(int timeReq):_time_req(timeReq)
36 {
37 }
38
39 /*!
40  * Does nothing ! It is not a bug
41  */
42 void MEDStdTimeReq::setNumberOfTS(int /*nbOfTS*/) const
43 {
44 }
45
46 int MEDStdTimeReq::size() const
47 {
48   return 1;
49 }
50
51 int MEDStdTimeReq::getCurrent() const
52 {
53   return _time_req;
54 }
55
56 /*!
57  * Does nothing ! It is not a bug
58  */
59 void MEDStdTimeReq::initIterator() const
60 {
61 }
62
63 std::string MEDStdTimeReq::buildName(const std::string& name) const
64 {
65   return std::string(name);
66 }
67
68 /*!
69  * Does nothing ! It is not a bug
70  */
71 void MEDStdTimeReq::operator++() const
72 {
73 }
74
75 ///////////
76
77 MEDModeTimeReq::MEDModeTimeReq(const std::vector<bool>& v, const std::vector<double>& ts):_v(v),_ts(ts),_it(0),_sz(0)
78 {
79 }
80
81 MEDModeTimeReq::~MEDModeTimeReq()
82 {
83 }
84
85 int MEDModeTimeReq::size() const
86 {
87   int ret(0);
88   for(int i=0;i<_sz;i++)
89     {
90       if(_v[i])
91         ret++;
92     }
93   return ret;
94 }
95
96 int MEDModeTimeReq::getCurrent() const
97 {
98   return _it;
99 }
100
101 void MEDModeTimeReq::setNumberOfTS(int nbOfTS) const
102 {
103   _sz=nbOfTS;
104 }
105
106 void MEDModeTimeReq::initIterator() const
107 {
108   for(_it=0;_it<_sz;_it++)
109     if(_v[_it])
110       return;
111 }
112
113 std::string MEDModeTimeReq::buildName(const std::string& name) const
114 {
115   std::ostringstream oss,oss2,oss3;
116   oss << name << " [";
117   //
118   oss3 << _sz-1;
119   std::size_t len(oss3.str().length());
120   oss2.width(len);
121   oss2.fill('0'); oss2 << _it;
122   //
123   oss << oss2.str() << "]";
124   if(_it<(int)_ts.size())
125     oss << " - " << _ts[_it];
126   return oss.str();
127 }
128
129 void MEDModeTimeReq::operator++() const
130 {
131   _it++;
132   for(;_it<_sz;_it++)
133     if(_v[_it])
134       return;
135 }