bioformats  5.1.2
Medium.h
1 /*
2  * #%L
3  * OME-XML C++ library for working with OME-XML metadata structures.
4  * %%
5  * Copyright © 2006 - 2015 Open Microscopy Environment:
6  * - Massachusetts Institute of Technology
7  * - National Institutes of Health
8  * - University of Dundee
9  * - Board of Regents of the University of Wisconsin-Madison
10  * - Glencoe Software, Inc.
11  * %%
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions are met:
14  *
15  * 1. Redistributions of source code must retain the above copyright notice,
16  * this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright notice,
18  * this list of conditions and the following disclaimer in the documentation
19  * and/or other materials provided with the distribution.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  * The views and conclusions contained in the software and documentation are
34  * those of the authors and should not be interpreted as representing official
35  * policies, either expressed or implied, of any organization.
36  * #L%
37  */
38 
39 /*─────────────────────────────────────────────────────────────────────────────
40  *
41  * THIS IS AUTOMATICALLY GENERATED CODE. DO NOT MODIFY.
42  *
43  *─────────────────────────────────────────────────────────────────────────────
44  */
45 
46 #ifndef OME_XML_MODEL_ENUMS_MEDIUM_H
47 #define OME_XML_MODEL_ENUMS_MEDIUM_H
48 
49 #include <ostream>
50 #include <map>
51 #include <string>
52 
53 #include <ome/common/log.h>
54 
55 #include <ome/xml/model/enums/EnumerationException.h>
56 
57 
58 namespace ome
59 {
60  namespace xml
61  {
62  namespace model
63  {
64  namespace enums
65  {
66 
70  class Medium
71  {
72  public:
75  {
77  AIR,
79  OIL,
86  };
87 
94 
109  Medium (const std::string& name, bool strict = true);
110 
116  Medium (const Medium& original);
117 
122  inline Medium&
123  operator= (const Medium& rhs)
124  {
125  this->value = rhs.value;
126  this->name = rhs.name;
127  return *this;
128  }
129 
135  inline
136  operator enum_value () const
137  {
138  return this->value;
139  }
140 
146  inline
147  operator const std::string& () const
148  {
149  return *this->name;
150  }
151 
153  typedef std::map<std::string, Medium::enum_value> string_map_type;
155  typedef std::map<Medium::enum_value, std::string> value_map_type;
156 
162  static const string_map_type&
163  strings();
164 
170  static const value_map_type&
171  values();
172 
173  private:
177  const std::string *name;
178 
180  static const string_map_type string_map;
182  static const string_map_type lowercase_string_map;
184  static const value_map_type value_map;
185  };
186 
194  inline bool
195  operator== (const Medium& lhs,
196  const Medium& rhs)
197  {
198  return static_cast<Medium::enum_value>(lhs) == static_cast<Medium::enum_value>(rhs);
199  }
200 
208  inline bool
209  operator== (const Medium& lhs,
210  const Medium::enum_value& rhs)
211  {
212  return static_cast<Medium::enum_value>(lhs) == rhs;
213  }
214 
222  inline bool
224  const Medium& rhs)
225  {
226  return lhs == static_cast<Medium::enum_value>(rhs);
227  }
228 
236  inline bool
237  operator== (const Medium& lhs,
238  const std::string& rhs)
239  {
240  return static_cast<const std::string&>(lhs) == rhs;
241  }
242 
250  inline bool
251  operator== (const std::string& lhs,
252  const Medium& rhs)
253  {
254  return lhs == static_cast<const std::string&>(rhs);
255  }
256 
264  inline bool
265  operator!= (const Medium& lhs,
266  const Medium& rhs)
267  {
268  return static_cast<Medium::enum_value>(lhs) != static_cast<Medium::enum_value>(rhs);
269  }
270 
278  inline bool
279  operator!= (const Medium& lhs,
280  const Medium::enum_value& rhs)
281  {
282  return static_cast<Medium::enum_value>(lhs) != rhs;
283  }
284 
292  inline bool
294  const Medium& rhs)
295  {
296  return lhs != static_cast<Medium::enum_value>(rhs);
297  }
298 
306  inline bool
307  operator!= (const Medium& lhs,
308  const std::string& rhs)
309  {
310  return static_cast<const std::string&>(lhs) != rhs;
311  }
312 
320  inline bool
321  operator!= (const std::string& lhs,
322  const Medium& rhs)
323  {
324  return lhs != static_cast<const std::string&>(rhs);
325  }
326 
334  template<class charT, class traits>
335  inline std::basic_ostream<charT,traits>&
336  operator<< (std::basic_ostream<charT,traits>& os,
337  const Medium& enumeration)
338  {
339  return os << static_cast<const std::string&>(enumeration);
340  }
341 
349  template<class charT, class traits>
350  inline std::basic_istream<charT,traits>&
351  operator>> (std::basic_istream<charT,traits>& is,
352  Medium& enumeration)
353  {
354  std::string value;
355  is >> value;
356  if (is)
357  {
358  try
359  {
360  enumeration = Medium(value, false);
361  }
362  catch (const EnumerationException& e)
363  {
364  is.setstate(std::ios::failbit);
365  }
366  }
367 
368  return is;
369  }
370 
371  }
372  }
373  }
374 }
375 
376 #endif // OME_XML_MODEL_ENUMS_MEDIUM_H
377 
378 /*
379  * Local Variables:
380  * mode:C++
381  * End:
382  */
std::basic_istream< charT, traits > & operator>>(std::basic_istream< charT, traits > &is, AcquisitionMode &enumeration)
Set AcquisitionMode from input stream.
Definition: AcquisitionMode.h:381
bool operator!=(const AcquisitionMode &lhs, const AcquisitionMode &rhs)
Compare two AcquisitionMode objects for non-equality.
Definition: AcquisitionMode.h:295
static const string_map_type lowercase_string_map
Mapping of lowercase enumeration name to value.
Definition: Medium.h:182
EnumerationException is thrown when an enumeration is invalid or not found.
Definition: EnumerationException.h:74
std::map< Medium::enum_value, std::string > value_map_type
Value map type.
Definition: Medium.h:155
enum_value
Enumeration values.
Definition: Medium.h:74
enum_value value
Enumeration value.
Definition: Medium.h:175
static const value_map_type value_map
Mapping of enumeration value to name.
Definition: Medium.h:184
Oil.
Definition: Medium.h:79
static const value_map_type & values()
Get a map of valid enum values and string names.
Definition: Medium.cpp:74
Medium(enum_value value)
Construct a Medium enumeration by an enumeration value.
Definition: Medium.cpp:129
Medium & operator=(const Medium &rhs)
Assignment operator.
Definition: Medium.h:123
Open Microscopy Environment C++ implementation.
Definition: CoreMetadata.cpp:40
Glycerol.
Definition: Medium.h:83
bool operator==(const AcquisitionMode &lhs, const AcquisitionMode &rhs)
Compare two AcquisitionMode objects for equality.
Definition: AcquisitionMode.h:225
const std::string * name
Enumeration name.
Definition: Medium.h:177
Water.
Definition: Medium.h:81
static const string_map_type & strings()
Get a map of valid string names and enum values.
Definition: Medium.cpp:68
static const string_map_type string_map
Mapping of enumeration name to value.
Definition: Medium.h:180
std::map< std::string, Medium::enum_value > string_map_type
String map type.
Definition: Medium.h:153
Other.
Definition: Medium.h:85
Boost.Log compatibility.
Medium enumeration.
Definition: Medium.h:70
Air.
Definition: Medium.h:77
Xerces-C modern C++ wrapper.
Definition: Base.h:53