ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::core::Scalar Class Reference

#include <Scalar.h>

Public Types

enum class  ScalarType { Double , Int64 , Bool }
 

Public Member Functions

 Scalar (float v)
 
 Scalar (double v)
 
 Scalar (int8_t v)
 
 Scalar (int16_t v)
 
 Scalar (int32_t v)
 
 Scalar (int64_t v)
 
template<typename T = int64_t>
 Scalar (long v, typename std::enable_if<!std::is_same< T, long >::value >::type *=0)
 
 Scalar (uint8_t v)
 
 Scalar (uint16_t v)
 
 Scalar (uint32_t v)
 
 Scalar (uint64_t v)
 
 Scalar (bool v)
 
bool IsDouble () const
 
bool IsInt64 () const
 
bool IsBool () const
 
double GetDouble () const
 
int64_t GetInt64 () const
 
bool GetBool () const
 
template<typename T >
To () const
 To<T>() does not check for scalar type and overflows. More...
 
void AssertSameScalarType (Scalar other, const std::string &error_msg) const
 
std::string ToString () const
 
template<typename T >
bool Equal (T value) const
 
bool Equal (bool value) const
 
bool Equal (Scalar other) const
 

Detailed Description

Scalar is a stores one of {double, int64, bool}. Typically Scalar is used to accept C++ scalar arguments of different types via implicit conversion constructor. Doing so can avoid the need for templates.

Definition at line 24 of file Scalar.h.

Member Enumeration Documentation

◆ ScalarType

Enumerator
Double 
Int64 
Bool 

Definition at line 26 of file Scalar.h.

Constructor & Destructor Documentation

◆ Scalar() [1/12]

cloudViewer::core::Scalar::Scalar ( float  v)
inline

Definition at line 28 of file Scalar.h.

References Double.

◆ Scalar() [2/12]

cloudViewer::core::Scalar::Scalar ( double  v)
inline

Definition at line 32 of file Scalar.h.

References Double.

◆ Scalar() [3/12]

cloudViewer::core::Scalar::Scalar ( int8_t  v)
inline

Definition at line 36 of file Scalar.h.

References Int64.

◆ Scalar() [4/12]

cloudViewer::core::Scalar::Scalar ( int16_t  v)
inline

Definition at line 40 of file Scalar.h.

References Int64.

◆ Scalar() [5/12]

cloudViewer::core::Scalar::Scalar ( int32_t  v)
inline

Definition at line 44 of file Scalar.h.

References Int64.

◆ Scalar() [6/12]

cloudViewer::core::Scalar::Scalar ( int64_t  v)
inline

Definition at line 48 of file Scalar.h.

References Int64.

◆ Scalar() [7/12]

template<typename T = int64_t>
cloudViewer::core::Scalar::Scalar ( long  v,
typename std::enable_if<!std::is_same< T, long >::value >::type = 0 
)
inline

Definition at line 59 of file Scalar.h.

References Int64.

◆ Scalar() [8/12]

cloudViewer::core::Scalar::Scalar ( uint8_t  v)
inline

Definition at line 64 of file Scalar.h.

References Int64.

◆ Scalar() [9/12]

cloudViewer::core::Scalar::Scalar ( uint16_t  v)
inline

Definition at line 68 of file Scalar.h.

References Int64.

◆ Scalar() [10/12]

cloudViewer::core::Scalar::Scalar ( uint32_t  v)
inline

Definition at line 72 of file Scalar.h.

References Int64.

◆ Scalar() [11/12]

cloudViewer::core::Scalar::Scalar ( uint64_t  v)
inline

Definition at line 76 of file Scalar.h.

References Int64, and max().

◆ Scalar() [12/12]

cloudViewer::core::Scalar::Scalar ( bool  v)
inline

Definition at line 92 of file Scalar.h.

References Bool.

Member Function Documentation

◆ AssertSameScalarType()

void cloudViewer::core::Scalar::AssertSameScalarType ( Scalar  other,
const std::string &  error_msg 
) const
inline

Definition at line 140 of file Scalar.h.

References LogError, and ToString().

Referenced by cloudViewer::core::Tensor::Arange().

◆ Equal() [1/3]

bool cloudViewer::core::Scalar::Equal ( bool  value) const
inline

Definition at line 184 of file Scalar.h.

References Bool.

◆ Equal() [2/3]

bool cloudViewer::core::Scalar::Equal ( Scalar  other) const
inline

Definition at line 188 of file Scalar.h.

References Bool, Double, Equal(), GetDouble(), GetInt64(), Int64, and LogError.

◆ Equal() [3/3]

template<typename T >
bool cloudViewer::core::Scalar::Equal ( value) const
inline

Definition at line 172 of file Scalar.h.

References Bool, Double, Int64, and LogError.

Referenced by cloudViewer::core::Tensor::Arange(), and Equal().

◆ GetBool()

bool cloudViewer::core::Scalar::GetBool ( ) const
inline

Returns bool value from Scalar. Only works when scalar_type_ is ScalarType::Bool.

Definition at line 119 of file Scalar.h.

References IsBool(), and LogError.

◆ GetDouble()

double cloudViewer::core::Scalar::GetDouble ( ) const
inline

Returns double value from Scalar. Only works when scalar_type_ is ScalarType::Double.

Definition at line 103 of file Scalar.h.

References IsDouble(), and LogError.

Referenced by Equal().

◆ GetInt64()

int64_t cloudViewer::core::Scalar::GetInt64 ( ) const
inline

Returns int64 value from Scalar. Only works when scalar_type_ is ScalarType::Int64.

Definition at line 111 of file Scalar.h.

References IsInt64(), and LogError.

Referenced by Equal().

◆ IsBool()

bool cloudViewer::core::Scalar::IsBool ( ) const
inline

Definition at line 99 of file Scalar.h.

References Bool.

Referenced by GetBool().

◆ IsDouble()

bool cloudViewer::core::Scalar::IsDouble ( ) const
inline

Definition at line 97 of file Scalar.h.

References Double.

Referenced by GetDouble().

◆ IsInt64()

bool cloudViewer::core::Scalar::IsInt64 ( ) const
inline

Definition at line 98 of file Scalar.h.

References Int64.

Referenced by GetInt64().

◆ To()

◆ ToString()

std::string cloudViewer::core::Scalar::ToString ( ) const
inline

Definition at line 153 of file Scalar.h.

References Bool, Double, Int64, LogError, and patch::to_string().

Referenced by AssertSameScalarType().


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