DISPLACE  1.0
A spatial model of fisheries to help sustainable fishing and maritime spatial planning
historicaldatacollector.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // DISPLACE: DYNAMIC INDIVIDUAL VESSEL-BASED SPATIAL PLANNING
3 // AND EFFORT DISPLACEMENT
4 // Copyright (c) 2012-2019 Francois Bastardie <fba@aqua.dtu.dk>
5 
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // --------------------------------------------------------------------------
20 
21 /* --------------------------------------------------------------------------
22  * DISPLACE: DYNAMIC INDIVIDUAL VESSEL-BASED SPATIAL PLANNING
23  * AND EFFORT DISPLACEMENT
24  * Copyright (c) 2012, 2013, 2014 Francois Bastardie <fba@aqua.dtu.dk>
25  *
26  * This program is free software; you can redistribute it and/or modify
27  * it under the terms of the GNU General Public License as published by
28  * the Free Software Foundation; either version 2 of the License, or
29  * (at your option) any later version.
30  *
31  * This program is distributed in the hope that it will be useful,
32  * but WITHOUT ANY WARRANTY; without even the implied warranty of
33  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34  * GNU General Public License for more details.
35  *
36  * You should have received a copy of the GNU General Public License along
37  * with this program; if not, write to the Free Software Foundation, Inc.,
38  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
39  * --------------------------------------------------------------------------
40  */
41 #ifndef HISTORICALDATACOLLECTOR_H
42 #define HISTORICALDATACOLLECTOR_H
43 
44 #include <QMap>
45 #include <QLinkedList>
46 #include <memory>
47 
48 template <typename T>
50 public:
51  typedef T Value;
52  typedef QMap<int, Value> Container;
53 
55  }
56 
57  void insertValue (int tstep, const Value &data) {
58  mData.insert(tstep, data);
59  }
60 
61  const Value &getValue(int tstep) const {
62  typename Container::const_iterator it = mData.lowerBound(tstep+1);
63  --it;
64  return it.value();
65  }
66 
67  int getUniqueValuesCount() const {
68  return mData.size();
69  }
70 
71  typename Container::const_iterator getFirst() const {
72  return mData.begin();
73  }
74  bool atEnd(typename Container::const_iterator it) const {
75  return it == mData.end();
76  }
77 
78  void clear() { mData.clear(); }
79 
80 protected:
82 };
83 
84 #endif // HISTORICALDATACOLLECTOR_H
void clear()
Definition: historicaldatacollector.h:78
Container::const_iterator getFirst() const
Definition: historicaldatacollector.h:71
const Value & getValue(int tstep) const
Definition: historicaldatacollector.h:61
Container mData
Definition: historicaldatacollector.h:81
int tstep
Definition: main.cpp:205
bool atEnd(typename Container::const_iterator it) const
Definition: historicaldatacollector.h:74
Definition: historicaldatacollector.h:49
Definition: fishfarmsstats.h:8
int getUniqueValuesCount() const
Definition: historicaldatacollector.h:67
HistoricalDataCollector()
Definition: historicaldatacollector.h:54
void insertValue(int tstep, const Value &data)
Definition: historicaldatacollector.h:57
T Value
Definition: historicaldatacollector.h:51
QMap< int, Value > Container
Definition: historicaldatacollector.h:52