Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JOscParameter.hh
Go to the documentation of this file.
1#ifndef __JOSCPROB__JOSCPARAMETER__
2#define __JOSCPROB__JOSCPARAMETER__
3
4#include "JLang/JException.hh"
5#include "JLang/JParameter.hh"
6
7#include "JTools/JGrid.hh"
8
9
10/**
11 * \author bjung, mdejong
12 */
13
14namespace JOSCPROB {}
15namespace JPP { using namespace JOSCPROB; }
16
17namespace JOSCPROB {
18
20
21 using JTOOLS::JGrid;
22
23
24 /**
25 * Abstract base class for oscillation parameter.
26 */
27 template<class T>
29 public JParameter<T>
30 {
32
35
36
37 /**
38 * Default constructor.
39 */
43
44
45 /**
46 * Constructor.
47 *
48 * \param value oscillation parameter value
49 */
50 explicit JOscParameter(argument_type value) :
51 JParameter_t(value)
52 {}
53
54
55 /**
56 * Assignment operator.
57 *
58 * \param value oscillation parameter value
59 * \return oscillation parameter
60 */
62 {
63 setValue(value);
64
65 return *this;
66 }
67
68
69 /**
70 * Set parameter.
71 *
72 * \param value oscillation parameter value
73 */
74 void setValue(const value_type& value)
75 {
76 using namespace JPP;
77
79
80 if (!this->is_valid()) {
81 THROW(JValueOutOfRange, "JOscParameter<T>::setValue(): Given oscillation parameter is invalid " << value);
82 }
83 }
84
85
86 /**
87 * Check validity of oscillation parameter.
88 *
89 * \return true if valid; else false
90 */
91 virtual bool is_valid() const = 0;
92
93
94 /**
95 * Stream input.
96 *
97 * \param in input stream
98 * \param parameter oscillation parameter
99 * \return input stream
100 */
101 friend inline std::istream& operator>>(std::istream& in, JOscParameter<T>& parameter)
102 {
103 using namespace JPP;
104
105 in >> static_cast<JParameter_t&>(parameter);
106
107 if (!parameter.is_valid()) {
108 THROW(JValueOutOfRange, "JOscParameter<T>::operator>>(): Given oscillation parameter is invalid " << parameter);
109 }
110
111 return in;
112 }
113 };
114
115
116 /**
117 * Get size of given oscillation parameter grid.
118 *
119 * \param grid oscillation parameteter grid
120 * \return size of oscillation parameter
121 */
122 inline size_t getSize(const JOscParameter<JGrid<double> >& grid)
123 {
124 return (grid.isDefined() ? grid.getValue().getSize() : 0);
125 }
126}
127
128#endif
Exceptions.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Parameter class.
Definition JParameter.hh:36
JClass< T >::argument_type argument_type
Definition JParameter.hh:39
void setValue(const value_type &value)
Set value.
Definition JParameter.hh:93
JClass< T >::value_type value_type
Definition JParameter.hh:40
Exception for accessing a value in a collection that is outside of its range.
size_t getSize(const JOscParameter< JGrid< double > > &grid)
Get size of given oscillation parameter grid.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Abstract base class for oscillation parameter.
void setValue(const value_type &value)
Set parameter.
virtual bool is_valid() const =0
Check validity of oscillation parameter.
JParameter_t::argument_type argument_type
JOscParameter(argument_type value)
Constructor.
JOscParameter()
Default constructor.
JParameter_t::value_type value_type
friend std::istream & operator>>(std::istream &in, JOscParameter< T > &parameter)
Stream input.
JOscParameter< T > & operator=(const value_type &value)
Assignment operator.
JParameter< T > JParameter_t
Simple data structure for an abstract collection of equidistant abscissa values.
Definition JGrid.hh:40