Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Data Structures | Typedefs | Functions
omni::util Namespace Reference

Data Structures

struct  QtDeleter
 Pointer deleter functor. More...
 

Typedefs

template<typename T >
using QUniquePtr = std::unique_ptr< T, QtDeleter >
 QUniquePtr for QObjects. More...
 

Functions

QString fileToStr (const QString &_filename)
 Return content of file from a file name. More...
 
QString removeFileExt (QString const &_filename)
 Remove file extension and return string without file extension. More...
 
bool fileExists (QString const &)
 Checks if file exists and is actually a file and not a directory. More...
 
template<typename T , typename A >
mix (const T &_x, const T &_y, A _a)
 Linear interpolation between two values. More...
 
template<typename T >
bool testPtrEqual (T const *_a, T const *_b)
 Test if two instances (which inherit from SerializationInterface) have. More...
 
template<typename T , typename F >
bool testPtrVectorEqual (T const &_a, T const &_b, F f)
 Test if two vectors which hold unique_ptr's of SerializationInterfaces. More...
 
template<typename T >
bool testPtrVectorEqual (T const &_a, T const &_b)
 Test if two vectors are equal. More...
 
template<typename ENUM >
auto enumToInt (ENUM const &_v) -> typename std::underlying_type< ENUM >::type
 Converts an enum class to integer. More...
 
template<typename ENUM , typename INT >
ENUM intToEnum (INT _i)
 Converts an integer to enum. More...
 

Typedef Documentation

template<typename T >
using omni::util::QUniquePtr = typedef std::unique_ptr<T, QtDeleter>

QUniquePtr for QObjects.

Function Documentation

template<typename ENUM >
auto omni::util::enumToInt ( ENUM const &  _v) -> typename std::underlying_type<ENUM>::type

Converts an enum class to integer.

107  {
108  return static_cast<typename std::underlying_type<ENUM>::type>(_v);
109  }
bool omni::util::fileExists ( QString const &  _filename)

Checks if file exists and is actually a file and not a directory.

49  {
50  QFileInfo checkFile(_filename);
51 
52  // check if file exists and if yes: Is it really a file and no directory?
53  if (checkFile.exists() && checkFile.isFile()) return true;
54 
55  return false;
56  }
QString omni::util::fileToStr ( const QString &  _filename)

Return content of file from a file name.

30  {
31  QFile _f(_filename);
32 
33  _f.open(QIODevice::ReadOnly | QIODevice::Text);
34  return _f.readAll();
35  }
template<typename ENUM , typename INT >
ENUM omni::util::intToEnum ( INT  _i)

Converts an integer to enum.

113  {
114  return static_cast<ENUM>(_i);
115  }
template<typename T , typename A >
T omni::util::mix ( const T &  _x,
const T &  _y,
_a 
)

Linear interpolation between two values.

49  {
50  return _x * (1.0 - _a) + _y * _a;
51  }
QString omni::util::removeFileExt ( QString const &  _filename)

Remove file extension and return string without file extension.

38  {
39  int _lastIndex = _filename.lastIndexOf(".");
40 
41  if (_lastIndex == -1) return _filename;
42 
43  QString _rawName;
44 
45  for (int i = 0; i < _lastIndex; ++i) _rawName.push_back(_filename[i]);
46  return _rawName;
47  }
template<typename T >
bool omni::util::testPtrEqual ( T const *  _a,
T const *  _b 
)

Test if two instances (which inherit from SerializationInterface) have.

66  {
67  return _a && _b ?
68 
69  // Call equal() member function from SerializationInterface
70  _a->equal(_b) : // Otherwise
71  // Compare pointer adresses
72  (_a == _b);
73  }
template<typename T , typename F >
bool omni::util::testPtrVectorEqual ( T const &  _a,
T const &  _b,
f 
)

Test if two vectors which hold unique_ptr's of SerializationInterfaces.

79  {
80  // Size of vector must be equal
81  if (_a.size() != _b.size()) return false;
82 
83  // Test each element for equality
84  size_t _size = _a.size();
85 
86  for (size_t i = 0; i < _size; ++i)
87  {
88  // Call functor with pointers as arguments
89  if (!f(_a[i], _b[i])) return false;
90  }
91  return true;
92  }
template<typename T >
bool omni::util::testPtrVectorEqual ( T const &  _a,
T const &  _b 
)

Test if two vectors are equal.

97  {
98  typedef typename T::value_type value_type;
99  typedef typename value_type::element_type element_type;
100  return testPtrVectorEqual(_a, _b, testPtrEqual<element_type>);
101  }
bool testPtrVectorEqual(T const &_a, T const &_b)
Test if two vectors are equal.
Definition: util.h:96