oevislib_net  0.14.3.0
Loading...
Searching...
No Matches
oevislib_net.Templates.Optional< T > Class Template Reference

Container used to wrap optional input and outputs. More...

Inheritance diagram for oevislib_net.Templates.Optional< T >:

Public Member Functions

 Optional ()
 Constructs an Optional object.
 Optional (T value)
 Constructs a new Optional object copying the value of the specified reference.
Get ()
 Returns the value being wrapped.
GetValueOr (T defaultValue)
 Returns the value being wrapped or a default value if Optional does not contain one.
bool HasValue ()
 Checks if the current object is wrapping a value or is Null.
override object Clone ()
override void Dispose ()
bool Equals (Optional< T > other)
override bool Equals (object obj)
override int GetHashCode ()

Static Public Member Functions

static bool operator== (Optional< T > inOptional1, Optional< T > inOptional2)
static bool operator!= (Optional< T > inOptional1, Optional< T > inOptional2)
static implicit operator Optional< T > (T value)

Protected Attributes

Type elementType

Detailed Description

Container used to wrap optional input and outputs.

Optional inputs are useful in two cases:

When a parameter has a default value that cannot be pre-determined. In this case, passing ov::Null to the parameter will tell the function to compute its value according to the other parameters. When a feature of the algorithm can be disabled. In this case, passing a value will tell the function to activate some specific computation, while passing ov::Null will skip that computation entirely.

Optional outputs, on the other hand, are useful to tell the function to compute some additional data in addition to its main output. When a null Optional is passed to the parameter, the output will not be computed (default value). When the parameter is required, a non-Null object must be passed. ExampleOne of the most popular optional input is inRoi, usually available as a parameter of type const Optional<Region>& inRoi.

When the user wants to specify a region of interest for an image processing function, a Region object can be passed to the parameter. In that case, the computation will be faster and localized to the provided area. On the other hand, if ov::Null is passed, the function will apply the algorithm to the entire image.

T

Type of the objects wrapped by the Optional. It cannot be a reference type.

Member Function Documentation

◆ Get()

T oevislib_net.Templates.Optional< T >.Get ( )
inline

Returns the value being wrapped.

Returns
Value.

◆ GetValueOr()

T oevislib_net.Templates.Optional< T >.GetValueOr ( T defaultValue)
inline

Returns the value being wrapped or a default value if Optional does not contain one.

Parameters
defaultValueDefault value.
Returns
Value.

◆ HasValue()

bool oevislib_net.Templates.Optional< T >.HasValue ( )
inline

Checks if the current object is wrapping a value or is Null.

Returns
True if a value is present, false otherwise.

◆ Optional() [1/2]

oevislib_net.Templates.Optional< T >.Optional ( )
inline

Constructs an Optional object.

◆ Optional() [2/2]

oevislib_net.Templates.Optional< T >.Optional ( T value)
inline

Constructs a new Optional object copying the value of the specified reference.

Parameters
valueValue to wrap.