ome-files  0.5.0
Modulo.h
1 /*
2  * #%L
3  * OME-FILES C++ library for image IO.
4  * Copyright © 2006 - 2015 Open Microscopy Environment:
5  * - Massachusetts Institute of Technology
6  * - National Institutes of Health
7  * - University of Dundee
8  * - Board of Regents of the University of Wisconsin-Madison
9  * - Glencoe Software, Inc.
10  * %%
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions are met:
13  *
14  * 1. Redistributions of source code must retain the above copyright notice,
15  * this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright notice,
17  * this list of conditions and the following disclaimer in the documentation
18  * and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  * The views and conclusions contained in the software and documentation are
33  * those of the authors and should not be interpreted as representing official
34  * policies, either expressed or implied, of any organization.
35  * #L%
36  */
37 
38 #ifndef OME_FILES_MODULO_H
39 #define OME_FILES_MODULO_H
40 
41 #include <cstdint>
42 #include <string>
43 #include <vector>
44 #include <sstream>
45 
46 namespace ome
47 {
48  namespace files
49  {
50 
56  class Modulo {
57  public:
59  typedef std::vector<std::string>::size_type size_type;
60 
62  std::string parentDimension;
64  double start;
66  double step;
68  double end;
70  std::string parentType;
72  std::string type;
74  std::string typeDescription;
76  std::string unit;
78  std::vector<std::string> labels;
79 
85  Modulo(std::string dimension);
86 
96  size_type
97  size() const;
98 
109  std::string
110  toXMLAnnotation() const;
111  };
112 
120  template<class charT, class traits>
121  inline std::basic_ostream<charT,traits>&
122  operator<< (std::basic_ostream<charT,traits>& os,
123  const Modulo& modulo)
124  {
125  os << "parentDimension = " << modulo.parentDimension << '\n'
126  << "start = " << modulo.start << '\n'
127  << "step = " << modulo.step << '\n'
128  << "end = " << modulo.end << '\n'
129  << "parentType = " << modulo.parentType << '\n'
130  << "type = " << modulo.type << '\n'
131  << "typeDescription = " << modulo.typeDescription << '\n'
132  << "unit = " << modulo.unit << '\n'
133  << "labels = ";
134  for (std::vector<std::string>::const_iterator i = modulo.labels.begin();
135  i != modulo.labels.end();
136  ++i)
137  {
138  os << *i;
139  if (i + 1 != modulo.labels.end())
140  os << ", ";
141  }
142  os << '\n';
143 
144  return os;
145  }
146 
147  }
148 }
149 
150 #endif // OME_FILES_MODULO_H
151 
152 /*
153  * Local Variables:
154  * mode:C++
155  * End:
156  */
double end
End value.
Definition: Modulo.h:68
Modulo(std::string dimension)
Constructor.
Definition: Modulo.cpp:49
double step
Step size.
Definition: Modulo.h:66
std::string toXMLAnnotation() const
Convert to XML string.
Definition: Modulo.cpp:76
std::string parentDimension
Parent dimension being subdivided.
Definition: Modulo.h:62
Open Microscopy Environment C++.
std::vector< std::string > labels
Labels along the subdimension.
Definition: Modulo.h:78
double start
Start value.
Definition: Modulo.h:64
std::vector< std::string >::size_type size_type
Size of the subdimension.
Definition: Modulo.h:59
size_type size() const
Get the size of this subdimension.
Definition: Modulo.cpp:63
std::string parentType
Type of the parent dimension.
Definition: Modulo.h:70
A subdimension of Z, C, or T.
Definition: Modulo.h:56
std::string typeDescription
Type description of the subdimension.
Definition: Modulo.h:74
std::string type
Type of the subdimension.
Definition: Modulo.h:72
std::string unit
Unit of the subdimension.
Definition: Modulo.h:76