LSST Applications g063fba187b+cac8b7c890,g0f08755f38+6aee506743,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+b4475c5878,g1dcb35cd9c+8f9bc1652e,g20f6ffc8e0+6aee506743,g217e2c1bcf+73dee94bd0,g28da252d5a+1f19c529b9,g2bbee38e9b+3f2625acfc,g2bc492864f+3f2625acfc,g3156d2b45e+6e55a43351,g32e5bea42b+1bb94961c2,g347aa1857d+3f2625acfc,g35bb328faa+a8ce1bb630,g3a166c0a6a+3f2625acfc,g3e281a1b8c+c5dd892a6c,g3e8969e208+a8ce1bb630,g414038480c+5927e1bc1e,g41af890bb2+8a9e676b2a,g7af13505b9+809c143d88,g80478fca09+6ef8b1810f,g82479be7b0+f568feb641,g858d7b2824+6aee506743,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,ga5288a1d22+2903d499ea,gb58c049af0+d64f4d3760,gc28159a63d+3f2625acfc,gcab2d0539d+b12535109e,gcf0d15dbbd+46a3f46ba9,gda6a2b7d83+46a3f46ba9,gdaeeff99f8+1711a396fd,ge79ae78c31+3f2625acfc,gef2f8181fd+0a71e47438,gf0baf85859+c1f95f4921,gfa517265be+6aee506743,gfa999e8aa5+17cd334064,w.2024.51
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | List of all members
lsst::sphgeom::TriState Class Reference

TriState represents a boolean value with additional unknown state. More...

#include <TriState.h>

Public Member Functions

 TriState ()
 Construct value in unknown state.
 
 TriState (bool value)
 Construct value in a known state.
 
TriStateoperator= (TriState const &other)=default
 
bool operator== (TriState const &other) const
 Compare this tri-state value with other tri-state value.
 
bool operator!= (TriState const &other) const
 
bool operator== (bool value) const
 Compare this tri-state value with a boolean.
 
bool operator!= (bool value) const
 
TriState operator| (TriState const &other) const
 Compute the logical OR of two TriState values.
 
TriState operator& (TriState const &other) const
 Compute the logical AND of two TriState values.
 
TriState operator~ () const
 Compute the logical NOT of a TriState value.
 
bool known () const
 Check whether the state is known.
 

Detailed Description

TriState represents a boolean value with additional unknown state.

Instances of this class can be compared to booleans true and false, when the state is unknown, comparisons will return false.

Definition at line 46 of file TriState.h.

Constructor & Destructor Documentation

◆ TriState() [1/2]

lsst::sphgeom::TriState::TriState ( )
inline

Construct value in unknown state.

Definition at line 49 of file TriState.h.

49{}

◆ TriState() [2/2]

lsst::sphgeom::TriState::TriState ( bool value)
inlineexplicit

Construct value in a known state.

Definition at line 52 of file TriState.h.

52: _known(true), _value(value) {}

Member Function Documentation

◆ known()

bool lsst::sphgeom::TriState::known ( ) const
inline

Check whether the state is known.

Returns
True is returned when state is known.

Definition at line 123 of file TriState.h.

123{ return _known; }

◆ operator!=() [1/2]

bool lsst::sphgeom::TriState::operator!= ( bool value) const
inline

Definition at line 79 of file TriState.h.

79 {
80 return not this->operator==(value);
81 }
bool operator==(TriState const &other) const
Compare this tri-state value with other tri-state value.
Definition TriState.h:60

◆ operator!=() [2/2]

bool lsst::sphgeom::TriState::operator!= ( TriState const & other) const
inline

Definition at line 68 of file TriState.h.

68 {
69 return not this->operator==(other);
70 }

◆ operator&()

TriState lsst::sphgeom::TriState::operator& ( TriState const & other) const
inline

Compute the logical AND of two TriState values.

Parameters
otherOther TriState value.
Returns
False if either operand is known to be false, true if both operands are known to be true, and unknown otherwise.

Definition at line 101 of file TriState.h.

101 {
102 if (*this == false || other == false) {
103 return TriState(false);
104 } else if (*this == true && other == true) {
105 return TriState(true);
106 } else {
107 return TriState();
108 }
109 }
TriState()
Construct value in unknown state.
Definition TriState.h:49

◆ operator=()

TriState & lsst::sphgeom::TriState::operator= ( TriState const & other)
default

◆ operator==() [1/2]

bool lsst::sphgeom::TriState::operator== ( bool value) const
inline

Compare this tri-state value with a boolean.

Parameters
valueBoolean value to compare to.
Returns
True if the state is known to be equal to the given boolean.

Definition at line 75 of file TriState.h.

75 {
76 return _known && _value == value;
77 }

◆ operator==() [2/2]

bool lsst::sphgeom::TriState::operator== ( TriState const & other) const
inline

Compare this tri-state value with other tri-state value.

Parameters
otherTri-state value to compare to.
Returns
True is returned when both states are unknown or when both states are known and values are equal, false returned otherwise.

Definition at line 60 of file TriState.h.

60 {
61 if (not _known) {
62 return not other._known;
63 } else {
64 return other._known && _value == other._value;
65 }
66 }

◆ operator|()

TriState lsst::sphgeom::TriState::operator| ( TriState const & other) const
inline

Compute the logical OR of two TriState values.

Parameters
otherOther TriState value.
Returns
True if either operand is known to be true, false if both operands are known to be false, and unknown otherwise.

Definition at line 87 of file TriState.h.

87 {
88 if (*this == true || other == true) {
89 return TriState(true);
90 } else if (*this == false && other == false) {
91 return TriState(false);
92 } else {
93 return TriState();
94 }
95 }

◆ operator~()

TriState lsst::sphgeom::TriState::operator~ ( ) const
inline

Compute the logical NOT of a TriState value.

Returns
True if the current state is known to be false, false if the current state is known to be true, and unknown otherwise.

Definition at line 114 of file TriState.h.

114 {
115 if (known()) {
116 return TriState(!_value);
117 }
118 return TriState();
119 }
bool known() const
Check whether the state is known.
Definition TriState.h:123

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