DHART
Loading...
Searching...
No Matches
HF::GraphGenerator::optional_real3 Struct Reference

A simple wrapper for real3 that is able to determine whether or not it's defined. More...

#include <graph_generator.h>

+ Collaboration diagram for HF::GraphGenerator::optional_real3:

Public Member Functions

 optional_real3 ()
 Construct an invalid optional_real3. More...
 
 optional_real3 (real_t x, real_t y, real_t z)
 Construct an valid optreal3 from x,y,z parameters. More...
 
 optional_real3 (const real3 &in_real3)
 Construct an optreal3 from x,y,z parameters. More...
 
real3operator* ()
 Get a reference to the point held by this optional_real3. More...
 
 operator bool () const
 Check if this optional_real_3 has a value. More...
 

Public Attributes

real3 pt { NAN, NAN, NAN }
 Point type. More...
 

Detailed Description

A simple wrapper for real3 that is able to determine whether or not it's defined.

Upon construction, an optional_real_3 is put into 2 states, valid or invalid. Constructing this with the empty constructor will create an invalid optional_real3, using the x,y,z parameters will create a valid optional_real3. This can be checked by checking the truth the object similar to std::optional (i.e. if(optional_real3) ).

Remarks
This is used in place of std::optional, since std::optional doesn't support arrays. In many ways it functions similarly, but doesn't feature the exact same syntax for the sake of simplicity. This doesn't use any extra memory than a real3, and comes with the benefit of being able to clearly indicate to callers that a function doesn't always return a usable value and differentiate between code for checking a point and code for accessing a point in a single location.

Definition at line 281 of file graph_generator.h.

Constructor & Destructor Documentation

◆ optional_real3() [1/3]

HF::GraphGenerator::optional_real3::optional_real3 ( )
inline

Construct an invalid optional_real3.

Definition at line 285 of file graph_generator.h.

◆ optional_real3() [2/3]

HF::GraphGenerator::optional_real3::optional_real3 ( real_t  x,
real_t  y,
real_t  z 
)
inline

Construct an valid optreal3 from x,y,z parameters.

Parameters
xX Coordinate
yY Coordinate
zZ Coordinate

Definition at line 293 of file graph_generator.h.

◆ optional_real3() [3/3]

HF::GraphGenerator::optional_real3::optional_real3 ( const real3 in_real3)
inline

Construct an optreal3 from x,y,z parameters.

Parameters
in_real3Input x,y,z coordinates in a real3

Definition at line 299 of file graph_generator.h.

Member Function Documentation

◆ operator bool()

HF::GraphGenerator::optional_real3::operator bool ( ) const
inlineexplicit

Check if this optional_real_3 has a value.

Returns
True if this was initialized with x,y, and z coordinates that are not NAN, false otherwise.

Definition at line 312 of file graph_generator.h.

References pt.

◆ operator*()

real3 & HF::GraphGenerator::optional_real3::operator* ( )
inline

Get a reference to the point held by this optional_real3.

Returns
a reference to the point held by this optreal3.

Definition at line 305 of file graph_generator.h.

References pt.

Member Data Documentation

◆ pt

real3 HF::GraphGenerator::optional_real3::pt { NAN, NAN, NAN }

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