BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ModelView::RealLimits Class Reference

Limits for double. More...

Public Member Functions

 RealLimits ()
 
bool hasLowerAndUpperLimits () const
 if has lower and upper limit More...
 
bool hasLowerLimit () const
 if has lower limit More...
 
bool hasUpperLimit () const
 if has upper limit More...
 
bool isInRange (double value) const
 returns true if proposed value is in limits range More...
 
bool isLimited () const
 
bool isLimitless () const
 
bool isLowerLimited () const
 
bool isNonnegative () const
 
bool isPositive () const
 
bool isUpperLimited () const
 
double lowerLimit () const
 Returns lower limit. More...
 
bool operator!= (const RealLimits &other) const
 
bool operator< (const RealLimits &other) const
 
bool operator== (const RealLimits &other) const
 
double upperLimit () const
 Returns upper limit. More...
 

Static Public Member Functions

static RealLimits limited (double left_bound_value, double right_bound_value)
 Creates an object bounded from the left and right. More...
 
static RealLimits limitless ()
 Creates an object withoud bounds (default) More...
 
static RealLimits lowerLimited (double bound_value)
 Creates an object bounded from the left. More...
 
static RealLimits nonnegative ()
 Creates an object which can have only positive values with 0. included. More...
 
static RealLimits positive ()
 Creates an object which can have only positive values (>0., zero is not included) More...
 
static RealLimits upperLimited (double bound_value)
 Creates an object bounded from the right. More...
 

Protected Member Functions

 RealLimits (bool has_lower_limit, bool has_upper_limit, double lower_limit, double upper_limit)
 

Protected Attributes

bool m_has_lower_limit
 
bool m_has_upper_limit
 parameter has lower bound More...
 
double m_lower_limit
 parameter has upper bound More...
 
double m_upper_limit
 minimum allowed value More...
 

Detailed Description

Limits for double.

Definition at line 25 of file reallimits.h.

Constructor & Destructor Documentation

◆ RealLimits() [1/2]

RealLimits::RealLimits ( )

Definition at line 27 of file reallimits.cpp.

28  : m_has_lower_limit(false), m_has_upper_limit(false), m_lower_limit(lmin), m_upper_limit(lmax)
29 {
30 }
double m_lower_limit
parameter has upper bound
Definition: reallimits.h:81
bool m_has_upper_limit
parameter has lower bound
Definition: reallimits.h:80
double m_upper_limit
minimum allowed value
Definition: reallimits.h:82

Referenced by limited(), limitless(), lowerLimited(), and upperLimited().

◆ RealLimits() [2/2]

RealLimits::RealLimits ( bool  has_lower_limit,
bool  has_upper_limit,
double  lower_limit,
double  upper_limit 
)
protected

Definition at line 32 of file reallimits.cpp.

34  : m_has_lower_limit(has_lower_limit)
35  , m_has_upper_limit(has_upper_limit)
36  , m_lower_limit(lower_limit)
37  , m_upper_limit(upper_limit)
38 {
39 }

Member Function Documentation

◆ hasLowerAndUpperLimits()

bool RealLimits::hasLowerAndUpperLimits ( ) const

if has lower and upper limit

Definition at line 91 of file reallimits.cpp.

92 {
94 }

References m_has_lower_limit, and m_has_upper_limit.

Referenced by TEST_F().

◆ hasLowerLimit()

bool RealLimits::hasLowerLimit ( ) const

if has lower limit

Definition at line 71 of file reallimits.cpp.

72 {
73  return m_has_lower_limit;
74 }

References m_has_lower_limit.

Referenced by isInRange(), isLimited(), isLimitless(), isLowerLimited(), isNonnegative(), isPositive(), isUpperLimited(), and TEST_F().

◆ hasUpperLimit()

bool RealLimits::hasUpperLimit ( ) const

if has upper limit

Definition at line 81 of file reallimits.cpp.

82 {
83  return m_has_upper_limit;
84 }

References m_has_upper_limit.

Referenced by isInRange(), isLimited(), isLimitless(), isLowerLimited(), isNonnegative(), isPositive(), isUpperLimited(), and TEST_F().

◆ isInRange()

bool RealLimits::isInRange ( double  value) const

returns true if proposed value is in limits range

Definition at line 96 of file reallimits.cpp.

97 {
98  if (hasLowerLimit() && value < m_lower_limit)
99  return false;
100  if (hasUpperLimit() && value >= m_upper_limit)
101  return false;
102  return true;
103 }
bool hasUpperLimit() const
if has upper limit
Definition: reallimits.cpp:81
bool hasLowerLimit() const
if has lower limit
Definition: reallimits.cpp:71

References hasLowerLimit(), hasUpperLimit(), m_lower_limit, and m_upper_limit.

Referenced by TEST_F().

Here is the call graph for this function:

◆ isLimited()

bool RealLimits::isLimited ( ) const

Definition at line 151 of file reallimits.cpp.

152 {
153  return hasLowerLimit() && hasUpperLimit();
154 }

References hasLowerLimit(), and hasUpperLimit().

Referenced by TEST_F(), and ModelView::JsonUtils::ToString().

Here is the call graph for this function:

◆ isLimitless()

bool RealLimits::isLimitless ( ) const

Definition at line 125 of file reallimits.cpp.

126 {
127  return !hasLowerLimit() && !hasUpperLimit();
128 }

References hasLowerLimit(), and hasUpperLimit().

Referenced by ModelView::JsonUtils::ToString().

Here is the call graph for this function:

◆ isLowerLimited()

bool RealLimits::isLowerLimited ( ) const

Definition at line 141 of file reallimits.cpp.

142 {
143  return !isPositive() && !isNonnegative() && hasLowerLimit() && !hasUpperLimit();
144 }
bool isPositive() const
Definition: reallimits.cpp:130
bool isNonnegative() const
Definition: reallimits.cpp:136

References hasLowerLimit(), hasUpperLimit(), isNonnegative(), and isPositive().

Referenced by TEST_F(), and ModelView::JsonUtils::ToString().

Here is the call graph for this function:

◆ isNonnegative()

bool RealLimits::isNonnegative ( ) const

Definition at line 136 of file reallimits.cpp.

137 {
138  return hasLowerLimit() && !hasUpperLimit() && lowerLimit() == 0.0;
139 }
double lowerLimit() const
Returns lower limit.
Definition: reallimits.cpp:76

References hasLowerLimit(), hasUpperLimit(), and lowerLimit().

Referenced by isLowerLimited(), TEST_F(), and ModelView::JsonUtils::ToString().

Here is the call graph for this function:

◆ isPositive()

bool RealLimits::isPositive ( ) const

Definition at line 130 of file reallimits.cpp.

131 {
132  // intenional 'unsafe' double comparison
133  return hasLowerLimit() && !hasUpperLimit() && lowerLimit() == poszero;
134 }

References hasLowerLimit(), hasUpperLimit(), and lowerLimit().

Referenced by isLowerLimited(), TEST_F(), and ModelView::JsonUtils::ToString().

Here is the call graph for this function:

◆ isUpperLimited()

bool RealLimits::isUpperLimited ( ) const

Definition at line 146 of file reallimits.cpp.

147 {
148  return !hasLowerLimit() && hasUpperLimit();
149 }

References hasLowerLimit(), and hasUpperLimit().

Referenced by TEST_F(), and ModelView::JsonUtils::ToString().

Here is the call graph for this function:

◆ limited()

RealLimits RealLimits::limited ( double  left_bound_value,
double  right_bound_value 
)
static

Creates an object bounded from the left and right.

Definition at line 61 of file reallimits.cpp.

62 {
63  return RealLimits(true, true, left_bound_value, right_bound_value);
64 }

References RealLimits().

Referenced by ModelView::PenItem::PenItem(), ModelView::JsonUtils::CreateLimits(), and TEST_F().

Here is the call graph for this function:

◆ limitless()

RealLimits RealLimits::limitless ( )
static

Creates an object withoud bounds (default)

Definition at line 66 of file reallimits.cpp.

67 {
68  return RealLimits();
69 }

References RealLimits().

Referenced by gui2::SLDMaterialItem::SLDMaterialItem(), ModelView::CompoundItem::addProperty(), and TEST_F().

Here is the call graph for this function:

◆ lowerLimit()

double RealLimits::lowerLimit ( ) const

Returns lower limit.

Definition at line 76 of file reallimits.cpp.

77 {
78  return m_lower_limit;
79 }

References m_lower_limit.

Referenced by isNonnegative(), isPositive(), and TEST_F().

◆ lowerLimited()

RealLimits RealLimits::lowerLimited ( double  bound_value)
static

Creates an object bounded from the left.

Definition at line 41 of file reallimits.cpp.

42 {
43  return RealLimits(true, false, bound_value, lmax);
44 }

References RealLimits().

Referenced by ModelView::JsonUtils::CreateLimits(), nonnegative(), positive(), and TEST_F().

Here is the call graph for this function:

◆ nonnegative()

RealLimits RealLimits::nonnegative ( )
static

Creates an object which can have only positive values with 0. included.

Definition at line 51 of file reallimits.cpp.

52 {
53  return lowerLimited(0.);
54 }
static RealLimits lowerLimited(double bound_value)
Creates an object bounded from the left.
Definition: reallimits.cpp:41

References lowerLimited().

Referenced by ModelView::JsonUtils::CreateLimits(), and TEST_F().

Here is the call graph for this function:

◆ operator!=()

bool RealLimits::operator!= ( const RealLimits other) const

Definition at line 115 of file reallimits.cpp.

116 {
117  return !(*this == other);
118 }

◆ operator<()

bool RealLimits::operator< ( const RealLimits other) const

Definition at line 120 of file reallimits.cpp.

121 {
122  return m_lower_limit < other.m_lower_limit && m_upper_limit < other.m_upper_limit;
123 }

References m_lower_limit, and m_upper_limit.

◆ operator==()

bool RealLimits::operator== ( const RealLimits other) const

Definition at line 105 of file reallimits.cpp.

106 {
107  // Intenional 'unsafe' double comparison to have RealLimits::positive and
108  // RealLimits::nonnegative different.
109  // FIXME Is there better solution? Can we drop either positive or non-negative?
110  return (m_has_lower_limit == other.m_has_lower_limit)
112  && m_upper_limit == other.m_upper_limit;
113 }

References m_has_lower_limit, m_has_upper_limit, m_lower_limit, and m_upper_limit.

◆ positive()

RealLimits RealLimits::positive ( )
static

Creates an object which can have only positive values (>0., zero is not included)

Definition at line 46 of file reallimits.cpp.

47 {
48  return lowerLimited(poszero);
49 }

References lowerLimited().

Referenced by ModelView::JsonUtils::CreateLimits(), and TEST_F().

Here is the call graph for this function:

◆ upperLimit()

double RealLimits::upperLimit ( ) const

Returns upper limit.

Definition at line 86 of file reallimits.cpp.

87 {
88  return m_upper_limit;
89 }

References m_upper_limit.

Referenced by TEST_F().

◆ upperLimited()

RealLimits RealLimits::upperLimited ( double  bound_value)
static

Creates an object bounded from the right.

Definition at line 56 of file reallimits.cpp.

57 {
58  return RealLimits(false, true, lmin, bound_value);
59 }

References RealLimits().

Referenced by ModelView::JsonUtils::CreateLimits(), and TEST_F().

Here is the call graph for this function:

Member Data Documentation

◆ m_has_lower_limit

bool ModelView::RealLimits::m_has_lower_limit
protected

Definition at line 79 of file reallimits.h.

Referenced by hasLowerAndUpperLimits(), hasLowerLimit(), and operator==().

◆ m_has_upper_limit

bool ModelView::RealLimits::m_has_upper_limit
protected

parameter has lower bound

Definition at line 80 of file reallimits.h.

Referenced by hasLowerAndUpperLimits(), hasUpperLimit(), and operator==().

◆ m_lower_limit

double ModelView::RealLimits::m_lower_limit
protected

parameter has upper bound

Definition at line 81 of file reallimits.h.

Referenced by isInRange(), lowerLimit(), operator<(), and operator==().

◆ m_upper_limit

double ModelView::RealLimits::m_upper_limit
protected

minimum allowed value

Definition at line 82 of file reallimits.h.

Referenced by isInRange(), operator<(), operator==(), and upperLimit().


The documentation for this class was generated from the following files: