MI - Fimex
SliceBuilder.h
Go to the documentation of this file.
1 /*
2  * Fimex, SliceBuilder.h
3  *
4  * (C) Copyright 2009, met.no
5  *
6  * Project Info: https://wiki.met.no/fimex/start
7  *
8  * This library is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or
11  * (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  * License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21  * USA.
22  *
23  * Created on: Mar 16, 2010
24  * Author: Heiko Klein
25  */
26 
27 #ifndef SLICEBUILDER_H_
28 #define SLICEBUILDER_H_
29 
30 #include <string>
31 #include <vector>
32 #include <map>
33 #include <set>
34 #include <boost/shared_ptr.hpp>
35 
36 namespace MetNoFimex
37 {
38 // forward decl
39 class CDM;
40 class CoordinateAxis;
47 {
48 public:
57  SliceBuilder(const CDM& cdm, const std::string& varName, bool setUnlimited = false);
64  SliceBuilder(const std::vector<std::string>& dimNames, const std::vector<size_t>& dimSize);
65  virtual ~SliceBuilder();
74  void getStartAndSize(const std::string & dimName, std::size_t& start, std::size_t& size) const;
83  void setStartAndSize(const std::string& dimName, size_t start, size_t size);
92  void setStartAndSize(const boost::shared_ptr<const CoordinateAxis>& axis, size_t start, size_t size);
99  void setAll(const std::string& dimName);
106  void setAll(const boost::shared_ptr<const CoordinateAxis>& axis);
110  const std::vector<size_t>& getDimensionStartPositions() const {return start_;}
115  const std::vector<size_t>& getDimensionSizes() const {return size_;}
129  const std::vector<size_t>& getMaxDimensionSizes() const {return maxSize_;}
130 protected:
131  size_t getDimPos(const std::string& dimName) const;
132 private:
133  void init(const std::vector<std::string>& dimNames, const std::vector<std::size_t>& dimSize, const std::vector<bool>& unlimited);
134  // position of the dimension
136  std::set<std::string> setDims_;
137  std::vector<size_t> maxSize_;
138  std::vector<bool> unlimited_;
139  std::vector<size_t> start_;
140  std::vector<size_t> size_;
141 
142 };
143 
145 
146 }
147 
148 
149 
150 #endif /* SLICEBUILDER_H_ */
void setAll(const std::string &dimName)
basic_string< char > string
void setStartAndSize(const std::string &dimName, size_t start, size_t size)
Definition: SliceBuilder.h:46
basic_ostream< char > ostream
size_t getDimPos(const std::string &dimName) const
Data structure of the Common Data Model.
Definition: CDM.h:54
SliceBuilder(const CDM &cdm, const std::string &varName, bool setUnlimited=false)
Definition: C_CDMReader.h:35
void getStartAndSize(const std::string &dimName, std::size_t &start, std::size_t &size) const
std::vector< std::string > getUnsetDimensionNames() const
std::vector< std::string > getDimensionNames() const
const std::vector< size_t > & getDimensionSizes() const
Definition: SliceBuilder.h:115
std::ostream & operator<<(std::ostream &out, CoordinateAxis ca)
const std::vector< size_t > & getMaxDimensionSizes() const
Definition: SliceBuilder.h:129
const std::vector< size_t > & getDimensionStartPositions() const
Definition: SliceBuilder.h:110