My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
Frequency.h
Go to the documentation of this file.
1 #ifndef GCP_UTIL_FREQUENCY_H
2 #define GCP_UTIL_FREQUENCY_H
3 
11 #include <iostream>
12 
13 #include "gcp/util/common/ConformableQuantity.h"
14 #include "gcp/util/common/Speed.h"
15 
16 namespace gcp {
17  namespace util {
18 
19  class Wavelength;
20 
21  class Frequency : public ConformableQuantity {
22  public:
23 
24  // A few useful conversions
25 
26  static const double HzPerGHz_;
27  static const double HzPerMHz_;
28  static Speed lightSpeed_;
29 
30  class MegaHz {};
31  class GigaHz {};
32  class Hertz {};
33 
37  Frequency();
38  Frequency(const Hertz& units, double Hz);
39  Frequency(const MegaHz& units, double MHz);
40  Frequency(const GigaHz& units, double GHz);
41  Frequency(Wavelength& wavelength);
42 
46  virtual ~Frequency();
47 
48  // Set the frequency, in GHz
49 
50  void setGHz(double GHz);
51 
52  // Set the frequency, in MHz
53 
54  void setMHz(double MHz);
55 
56  // Set the frequency, in MHz
57 
58  void setHz(double Hz);
59 
60  // Return the frequency, in GHz
61 
62  inline double GHz() {
63  return Hz_ / HzPerGHz_;
64  }
65 
66  // Return the frequency, in MHz
67 
68  inline double MHz() {
69  return Hz_ / HzPerMHz_;
70  }
71 
72  inline unsigned short yigUnits() {
73  return (unsigned short)MHz();
74  }
75 
76  // Return the frequency, in Hz
77 
78  inline double Hz() const {
79  return Hz_;
80  }
81 
85  friend std::ostream& operator<<(std::ostream& os, Frequency& frequency);
86 
87  Frequency operator-(Frequency& frequency);
88 
89  void initialize();
90 
91  protected:
92 
93  // The actual frequency, in Hz
94 
95  double Hz_;
96 
97  }; // End class Frequency
98 
99  } // End namespace util
100 } // End namespace gcp
101 
102 
103 
104 
105 #endif // End #ifndef GCP_UTIL_FREQUENCY_H
virtual ~Frequency()
Definition: Frequency.cc:61
Definition: Wavelength.h:19
friend std::ostream & operator<<(std::ostream &os, Frequency &frequency)
Definition: ConformableQuantity.h:16
Definition: Speed.h:16
Definition: Frequency.h:32
Definition: Frequency.h:30
Definition: Frequency.h:31
Frequency operator-(Frequency &frequency)
Definition: Frequency.cc:102
Frequency()
Definition: Frequency.cc:21
Definition: Frequency.h:21