ome-xml  5.6.0
NamingConvention.h
1 /*
2  * #%L
3  * OME-XML C++ library for working with OME-XML metadata structures.
4  * %%
5  * Copyright © 2006 - 2016 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_NAMINGCONVENTION_H
47 #define OME_XML_MODEL_ENUMS_NAMINGCONVENTION_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 // All values in the NamingConvention enumeration.
58 #define OME_XML_MODEL_ENUMS_NAMINGCONVENTION_VALUES (LETTER)(NUMBER)
59 
60 namespace ome
61 {
62  namespace xml
63  {
64  namespace model
65  {
66  namespace enums
67  {
68 
73  {
74  public:
77  {
111  };
112 
119 
134  NamingConvention (const std::string& name, bool strict = true);
135 
141  NamingConvention (const NamingConvention& original);
142 
149  inline NamingConvention&
151  {
152  this->value = rhs.value;
153  this->name = rhs.name;
154  return *this;
155  }
156 
162  inline
163  operator enum_value () const
164  {
165  return this->value;
166  }
167 
173  inline
174  operator const std::string& () const
175  {
176  return *this->name;
177  }
178 
180  typedef std::map<std::string, NamingConvention::enum_value> string_map_type;
182  typedef std::map<NamingConvention::enum_value, std::string> value_map_type;
183 
189  static const string_map_type&
190  strings();
191 
197  static const value_map_type&
198  values();
199 
200  private:
206  static const string_map_type&
208 
212  const std::string *name;
213  };
214 
222  inline bool
224  const NamingConvention& rhs)
225  {
226  return static_cast<NamingConvention::enum_value>(lhs) == static_cast<NamingConvention::enum_value>(rhs);
227  }
228 
236  inline bool
238  const NamingConvention::enum_value& rhs)
239  {
240  return static_cast<NamingConvention::enum_value>(lhs) == rhs;
241  }
242 
250  inline bool
252  const NamingConvention& rhs)
253  {
254  return lhs == static_cast<NamingConvention::enum_value>(rhs);
255  }
256 
264  inline bool
266  const std::string& rhs)
267  {
268  return static_cast<const std::string&>(lhs) == rhs;
269  }
270 
278  inline bool
279  operator== (const std::string& lhs,
280  const NamingConvention& rhs)
281  {
282  return lhs == static_cast<const std::string&>(rhs);
283  }
284 
292  inline bool
294  const NamingConvention& rhs)
295  {
296  return static_cast<NamingConvention::enum_value>(lhs) != static_cast<NamingConvention::enum_value>(rhs);
297  }
298 
306  inline bool
308  const NamingConvention::enum_value& rhs)
309  {
310  return static_cast<NamingConvention::enum_value>(lhs) != rhs;
311  }
312 
320  inline bool
322  const NamingConvention& rhs)
323  {
324  return lhs != static_cast<NamingConvention::enum_value>(rhs);
325  }
326 
334  inline bool
336  const std::string& rhs)
337  {
338  return static_cast<const std::string&>(lhs) != rhs;
339  }
340 
348  inline bool
349  operator!= (const std::string& lhs,
350  const NamingConvention& rhs)
351  {
352  return lhs != static_cast<const std::string&>(rhs);
353  }
354 
362  template<class charT, class traits>
363  inline std::basic_ostream<charT,traits>&
364  operator<< (std::basic_ostream<charT,traits>& os,
365  const NamingConvention& enumeration)
366  {
367  return os << static_cast<const std::string&>(enumeration);
368  }
369 
377  template<class charT, class traits>
378  inline std::basic_istream<charT,traits>&
379  operator>> (std::basic_istream<charT,traits>& is,
380  NamingConvention& enumeration)
381  {
382  std::string value;
383  is >> value;
384  if (is)
385  {
386  try
387  {
388  enumeration = NamingConvention(value, false);
389  }
390  catch (const EnumerationException&)
391  {
392  is.setstate(std::ios::failbit);
393  }
394  }
395 
396  return is;
397  }
398 
399  }
400  }
401  }
402 }
403 
404 #endif // OME_XML_MODEL_ENUMS_NAMINGCONVENTION_H
405 
406 /*
407  * Local Variables:
408  * mode:C++
409  * End:
410  */
std::basic_istream< charT, traits > & operator>>(std::basic_istream< charT, traits > &is, AcquisitionMode &enumeration)
Set AcquisitionMode from input stream.
Definition: AcquisitionMode.h:392
bool operator!=(const AcquisitionMode &lhs, const AcquisitionMode &rhs)
Compare two AcquisitionMode objects for non-equality.
Definition: AcquisitionMode.h:306
NamingConvention & operator=(const NamingConvention &rhs)
Assignment operator.
Definition: NamingConvention.h:150
const std::string * name
Enumeration name.
Definition: NamingConvention.h:212
EnumerationException is thrown when an enumeration is invalid or not found.
Definition: EnumerationException.h:74
enum_value value
Enumeration value.
Definition: NamingConvention.h:210
std::map< std::string, NamingConvention::enum_value > string_map_type
String map type.
Definition: NamingConvention.h:180
NamingConvention enumeration.
Definition: NamingConvention.h:72
Open Microscopy Environment C++ implementation.
static const value_map_type & values()
Get a map of valid enum values and string names.
Definition: NamingConvention.cpp:142
std::map< NamingConvention::enum_value, std::string > value_map_type
Value map type.
Definition: NamingConvention.h:182
bool operator==(const AcquisitionMode &lhs, const AcquisitionMode &rhs)
Compare two AcquisitionMode objects for equality.
Definition: AcquisitionMode.h:236
While the label type &#39;number&#39; has a clear meaning the &#39;letter&#39; type is more complex.
Definition: NamingConvention.h:104
1, 2, 3, ...
Definition: NamingConvention.h:110
NamingConvention(enum_value value)
Construct a NamingConvention enumeration by an enumeration value.
Definition: NamingConvention.cpp:67
enum_value
Enumeration values.
Definition: NamingConvention.h:76
static const string_map_type & lowercase_strings()
Get a map of valid lowercased string names and enum values.
Definition: NamingConvention.cpp:154
static const string_map_type & strings()
Get a map of valid string names and enum values.
Definition: NamingConvention.cpp:130