ArmNN
 21.05
BackendOptions::Var Class Reference

Very basic type safe variant. More...

#include <BackendOptions.hpp>

Public Member Functions

 Var (int i)
 Constructors. More...
 
 Var (unsigned int u)
 
 Var (float f)
 
 Var (bool b)
 
 Var (const char *s)
 
 Var (std::string s)
 
template<typename DisallowedType >
 Var (DisallowedType)
 Disallow implicit conversions from types not explicitly allowed below. More...
 
 Var (const Var &other)
 Copy Construct. More...
 
Varoperator= (const Var &other)
 Copy operator. More...
 
bool IsBool () const
 Type getters. More...
 
bool IsInt () const
 
bool IsUnsignedInt () const
 
bool IsFloat () const
 
bool IsString () const
 
bool AsBool () const
 Value getters. More...
 
int AsInt () const
 
unsigned int AsUnsignedInt () const
 
float AsFloat () const
 
std::string AsString () const
 
 ~Var ()
 Destructor. More...
 

Detailed Description

Very basic type safe variant.

Definition at line 36 of file BackendOptions.hpp.

Constructor & Destructor Documentation

◆ Var() [1/8]

Var ( int  i)
inlineexplicit

Constructors.

Definition at line 41 of file BackendOptions.hpp.

41 : m_Vals(i), m_Type(VarTypes::Integer) {};

◆ Var() [2/8]

Var ( unsigned int  u)
inlineexplicit

Definition at line 42 of file BackendOptions.hpp.

42 : m_Vals(u), m_Type(VarTypes::UnsignedInteger) {};

◆ Var() [3/8]

Var ( float  f)
inlineexplicit

Definition at line 43 of file BackendOptions.hpp.

43 : m_Vals(f), m_Type(VarTypes::Float) {};

◆ Var() [4/8]

Var ( bool  b)
inlineexplicit

Definition at line 44 of file BackendOptions.hpp.

44 : m_Vals(b), m_Type(VarTypes::Boolean) {};

◆ Var() [5/8]

Var ( const char *  s)
inlineexplicit

Definition at line 45 of file BackendOptions.hpp.

45 : m_Vals(s), m_Type(VarTypes::String) {};

◆ Var() [6/8]

Var ( std::string  s)
inlineexplicit

Definition at line 46 of file BackendOptions.hpp.

46 : m_Vals(s), m_Type(VarTypes::String) {};

◆ Var() [7/8]

Var ( DisallowedType  )
inline

Disallow implicit conversions from types not explicitly allowed below.

Definition at line 50 of file BackendOptions.hpp.

51  {
52  static_assert(CheckAllowed<DisallowedType>::value, "Type is not allowed for Var<DisallowedType>.");
53  assert(false && "Unreachable code");
54  }

◆ Var() [8/8]

Var ( const Var other)
inline

Copy Construct.

Definition at line 57 of file BackendOptions.hpp.

58  : m_Type(other.m_Type)
59  {
60  switch(m_Type)
61  {
62  case VarTypes::String:
63  {
64  new (&m_Vals.s) std::string(other.m_Vals.s);
65  break;
66  }
67  default:
68  {
69  DoOp(other, [](auto& a, auto& b)
70  {
71  a = b;
72  });
73  break;
74  }
75  }
76  }

◆ ~Var()

~Var ( )
inline

Destructor.

Definition at line 124 of file BackendOptions.hpp.

References armnn::Boolean, BackendOptions::Var::IsBool(), BackendOptions::Var::IsFloat(), BackendOptions::Var::IsInt(), BackendOptions::Var::IsString(), and BackendOptions::Var::IsUnsignedInt().

125  {
126  DoOp(*this, [this](auto& a, auto&)
127  {
128  Destruct(a);
129  });
130  }

Member Function Documentation

◆ AsBool()

bool AsBool ( ) const
inline

Value getters.

Definition at line 117 of file BackendOptions.hpp.

Referenced by armnn::ParseBoolean().

117 { assert(IsBool()); return m_Vals.b; }
bool IsBool() const
Type getters.

◆ AsFloat()

float AsFloat ( ) const
inline

Definition at line 120 of file BackendOptions.hpp.

120 { assert(IsFloat()); return m_Vals.f; }

◆ AsInt()

int AsInt ( ) const
inline

Definition at line 118 of file BackendOptions.hpp.

Referenced by armnn::ParseTuningLevel().

118 { assert(IsInt()); return m_Vals.i; }

◆ AsString()

std::string AsString ( ) const
inline

Definition at line 121 of file BackendOptions.hpp.

Referenced by armnn::ParseFile().

121 { assert(IsString()); return m_Vals.s; }

◆ AsUnsignedInt()

unsigned int AsUnsignedInt ( ) const
inline

Definition at line 119 of file BackendOptions.hpp.

119 { assert(IsUnsignedInt()); return m_Vals.u; }

◆ IsBool()

bool IsBool ( ) const
inline

Type getters.

Definition at line 110 of file BackendOptions.hpp.

References armnn::Boolean.

Referenced by armnn::ParseBoolean(), and BackendOptions::Var::~Var().

110 { return m_Type == VarTypes::Boolean; }

◆ IsFloat()

bool IsFloat ( ) const
inline

Definition at line 113 of file BackendOptions.hpp.

Referenced by BackendOptions::Var::~Var().

113 { return m_Type == VarTypes::Float; }

◆ IsInt()

bool IsInt ( ) const
inline

Definition at line 111 of file BackendOptions.hpp.

Referenced by armnn::ParseTuningLevel(), and BackendOptions::Var::~Var().

111 { return m_Type == VarTypes::Integer; }

◆ IsString()

bool IsString ( ) const
inline

Definition at line 114 of file BackendOptions.hpp.

Referenced by armnn::ParseFile(), and BackendOptions::Var::~Var().

114 { return m_Type == VarTypes::String; }

◆ IsUnsignedInt()

bool IsUnsignedInt ( ) const
inline

Definition at line 112 of file BackendOptions.hpp.

Referenced by BackendOptions::Var::~Var().

112 { return m_Type == VarTypes::UnsignedInteger; }

◆ operator=()

Var& operator= ( const Var other)
inline

Copy operator.

Definition at line 79 of file BackendOptions.hpp.

80  {
81  // Destroy existing string
82  if (m_Type == VarTypes::String)
83  {
84  Destruct(m_Vals.s);
85  }
86 
87  m_Type = other.m_Type;
88  switch(m_Type)
89  {
90  case VarTypes::String:
91  {
92 
93  new (&m_Vals.s) std::string(other.m_Vals.s);
94  break;
95  }
96  default:
97  {
98  DoOp(other, [](auto& a, auto& b)
99  {
100  a = b;
101  });
102  break;
103  }
104  }
105 
106  return *this;
107  };

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