00001 #ifndef CCTBX_ELTBX_WAVELENGTHS_H
00002 #define CCTBX_ELTBX_WAVELENGTHS_H
00003
00004 #include <scitbx/constants.h>
00005 #include <string>
00006
00007 namespace cctbx { namespace eltbx { namespace wavelengths {
00008
00009 namespace detail
00010 {
00011 struct raw
00012 {
00013 const char* label;
00014 float value;
00015 };
00016 }
00017
00019 class characteristic
00020 {
00021 public:
00023 characteristic() : raw_(0) {}
00024
00026
00030 characteristic(std::string const& label);
00031
00033
00035 bool
00036 is_valid() const { return raw_->value != 0; }
00037
00039
00041 const char*
00042 label() const
00043 {
00044 return raw_->label;
00045 }
00046
00048
00050 float
00051 as_angstrom() const
00052 {
00053 return raw_->value;
00054 }
00055
00057
00059 float
00060 as_kev() const
00061 {
00062 if (raw_->value == 0.) return 0.;
00063 return scitbx::constants::factor_kev_angstrom / raw_->value;
00064 }
00065
00067
00069 float
00070 as_ev() const { return as_kev() * 1000; }
00071
00072 private:
00073 const detail::raw* raw_;
00074 friend class characteristic_iterator;
00075 };
00076
00078 class characteristic_iterator
00079 {
00080 public:
00082 characteristic_iterator();
00083
00085
00087 characteristic
00088 next();
00089
00090 private:
00091 characteristic current_;
00092 };
00093
00094 }}}
00095
00096 #endif // CCTBX_ELTBX_WAVELENGTHS_H