modis_database.h
Go to the documentation of this file.
1 #ifndef __MODISDATABASE_H__
2 #define __MODISDATABASE_H__
3 #include <iostream>
4 #include <string>
5 #include <vector>
6 #include <memory>
7 
8 #include <boost/algorithm/string.hpp>
9 #include <boost/filesystem.hpp>
10 #include <boost/foreach.hpp>
11 #include <boost/lexical_cast.hpp>
12 
13 #include <boost/multi_index_container.hpp>
14 #include <boost/multi_index/member.hpp>
15 #include <boost/multi_index/mem_fun.hpp>
16 #include <boost/multi_index/ordered_index.hpp>
17 
18 #include <boost/regex.hpp>
19 
20 void MSearch(const boost::filesystem::path& mpath, std::vector<std::string>& fnames);
21 
23 {
25  filen(""),
26  product(""),
27  resolution(0),
28  year(0),
29  day(0),
30  h(0),
31  v(0)
32  {}
33 
34  void printToCout()
35  {
36  std::cout << "File: " << filen << ", product: " << product << ", year: " << year << " day: " << day << ", H: " << h << ", V: " << v << std::endl;
37  }
38 
39  std::string filen;
40  std::string product;
41  unsigned int resolution;
42  unsigned int year;
43  unsigned int day;
44  unsigned int h;
45  unsigned int v;
46 };
47 
49 {
50  /*! A mult-index container with the following indexes:
51  1) a non-unique index by product;
52  2) a non-unique index by year;
53  3) a non unuque index by day;
54  */
55  typedef boost::multi_index_container
56  <
58  boost::multi_index::indexed_by
59  <
60  boost::multi_index::ordered_unique<BOOST_MULTI_INDEX_MEMBER(MODISRecord,std::string,filen)>,
61  boost::multi_index::ordered_non_unique<BOOST_MULTI_INDEX_MEMBER(MODISRecord,std::string,product)>,
62  boost::multi_index::ordered_non_unique<BOOST_MULTI_INDEX_MEMBER(MODISRecord,unsigned int,year)>,
63  boost::multi_index::ordered_non_unique<BOOST_MULTI_INDEX_MEMBER(MODISRecord,unsigned int,day)>
64  >
66 
68 
69 public:
70 
71  MODISDatabase(std::string rootpath);
72 
73  size_t size() const;
74 
75  void clear();
76 
77  // Dump contents to cout
78  void printAll();
79 
80  MODISRecord findByFile(const std::string& filename) const;
81 
82  std::vector<MODISRecord> findByProduct(const std::string& product) const;
83 
84  std::vector<MODISRecord> findByYear(unsigned int year) const;
85 
86  std::vector<MODISRecord> findByDay(unsigned int day) const;
87 };
88 
89 #endif
std::string product
void MSearch(const boost::filesystem::path &mpath, std::vector< std::string > &fnames)
unsigned int v
std::string filen
boost::multi_index_container< MODISRecord, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< BOOST_MULTI_INDEX_MEMBER(MODISRecord, std::string, filen)>, boost::multi_index::ordered_non_unique< BOOST_MULTI_INDEX_MEMBER(MODISRecord, std::string, product)>, boost::multi_index::ordered_non_unique< BOOST_MULTI_INDEX_MEMBER(MODISRecord, unsigned int, year)>, boost::multi_index::ordered_non_unique< BOOST_MULTI_INDEX_MEMBER(MODISRecord, unsigned int, day)> > > MODISDb
unsigned int resolution
void printToCout()
unsigned int year
unsigned int h
unsigned int day