[DEV] continue removing STL
This commit is contained in:
parent
d8a6c0a9a9
commit
ac23f7b934
@ -523,22 +523,18 @@ namespace etk {
|
|||||||
|
|
||||||
//! @not_in_doc
|
//! @not_in_doc
|
||||||
template<int MY_TYPE_SIZE> etk::Stream& operator <<(etk::Stream& _os, const Color<uint8_t, MY_TYPE_SIZE>& _obj) { // RGB & RGBA 8 bits
|
template<int MY_TYPE_SIZE> etk::Stream& operator <<(etk::Stream& _os, const Color<uint8_t, MY_TYPE_SIZE>& _obj) { // RGB & RGBA 8 bits
|
||||||
// TODO: set it back !!!!
|
|
||||||
/*
|
|
||||||
std::ostringstream os;
|
|
||||||
if (MY_TYPE_SIZE >= 3) {
|
if (MY_TYPE_SIZE >= 3) {
|
||||||
_os << "#";
|
_os << "#";
|
||||||
os << std::setw(2) << std::setfill('0') << std::hex << uint32_t(_obj.r());
|
_os << etk::toHex(_obj.r());
|
||||||
if (MY_TYPE_SIZE >= 2) {
|
if (MY_TYPE_SIZE >= 2) {
|
||||||
os << std::setw(2) << std::setfill('0') << std::hex << uint32_t(_obj.g());
|
_os << etk::toHex(_obj.g());
|
||||||
}
|
}
|
||||||
if (MY_TYPE_SIZE >= 3) {
|
if (MY_TYPE_SIZE >= 3) {
|
||||||
os << std::setw(2) << std::setfill('0') << std::hex << uint32_t(_obj.b());
|
_os << etk::toHex(_obj.b());
|
||||||
}
|
}
|
||||||
if (MY_TYPE_SIZE >= 4) {
|
if (MY_TYPE_SIZE >= 4) {
|
||||||
os << std::setw(2) << std::setfill('0') << std::hex << uint32_t(_obj.a());
|
_os << etk::toHex(_obj.a());
|
||||||
}
|
}
|
||||||
_os << os.str();
|
|
||||||
} else {
|
} else {
|
||||||
if (MY_TYPE_SIZE >= 2) {
|
if (MY_TYPE_SIZE >= 2) {
|
||||||
_os << "be";
|
_os << "be";
|
||||||
@ -546,14 +542,13 @@ namespace etk {
|
|||||||
_os << "Mono";
|
_os << "Mono";
|
||||||
}
|
}
|
||||||
_os << "[U8](";
|
_os << "[U8](";
|
||||||
os << "0x" << std::setw(2) << std::setfill('0') << std::hex << uint32_t(_obj.r());
|
_os << "0x" << etk::toHex(_obj.r());
|
||||||
if (MY_TYPE_SIZE >= 2) {
|
if (MY_TYPE_SIZE >= 2) {
|
||||||
_os << ",";
|
_os << ",";
|
||||||
os << "0x" << std::setw(2) << std::setfill('0') << std::hex << uint32_t(_obj.g());
|
_os << "0x" << etk::toHex(_obj.g());
|
||||||
}
|
}
|
||||||
_os << os.str();
|
|
||||||
_os << ")";
|
_os << ")";
|
||||||
}*/
|
}
|
||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
//! @not_in_doc
|
//! @not_in_doc
|
||||||
@ -568,25 +563,20 @@ namespace etk {
|
|||||||
_os << "Mono";
|
_os << "Mono";
|
||||||
}
|
}
|
||||||
_os << "[U16](";
|
_os << "[U16](";
|
||||||
// TODO: set it back !!!!
|
_os << "0x" << etk::toHex(_obj.r(), 4);
|
||||||
/*
|
|
||||||
os << "0x" << std::setw(4) << std::setfill('0') << std::hex << _obj.r();
|
|
||||||
if (MY_TYPE_SIZE >= 2) {
|
if (MY_TYPE_SIZE >= 2) {
|
||||||
os << ",0x" << std::setw(4) << std::setfill('0') << std::hex << _obj.g();
|
_os << ",0x" << etk::toHex(_obj.g(), 4);
|
||||||
}
|
}
|
||||||
if (MY_TYPE_SIZE >= 3) {
|
if (MY_TYPE_SIZE >= 3) {
|
||||||
os << ",0x" << std::setw(4) << std::setfill('0') << std::hex << _obj.b();
|
_os << ",0x" << etk::toHex(_obj.b(), 4);
|
||||||
}
|
}
|
||||||
if (MY_TYPE_SIZE >= 4) {
|
if (MY_TYPE_SIZE >= 4) {
|
||||||
os << ",0x" << std::setw(4) << std::setfill('0') << std::hex << _obj.a();
|
_os << ",0x" << etk::toHex(_obj.a(), 4);
|
||||||
}
|
}
|
||||||
_os << os.str() << ")";
|
|
||||||
*/
|
|
||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
//! @not_in_doc
|
//! @not_in_doc
|
||||||
template<int MY_TYPE_SIZE> etk::Stream& operator <<(etk::Stream& _os, const Color<uint32_t, MY_TYPE_SIZE>& _obj) { // RGB & RGBA 8 bits
|
template<int MY_TYPE_SIZE> etk::Stream& operator <<(etk::Stream& _os, const Color<uint32_t, MY_TYPE_SIZE>& _obj) { // RGB & RGBA 8 bits
|
||||||
//std::ostringstream os;
|
|
||||||
if (MY_TYPE_SIZE >= 4) {
|
if (MY_TYPE_SIZE >= 4) {
|
||||||
_os << "rgba";
|
_os << "rgba";
|
||||||
} else if (MY_TYPE_SIZE >= 3) {
|
} else if (MY_TYPE_SIZE >= 3) {
|
||||||
@ -597,20 +587,16 @@ namespace etk {
|
|||||||
_os << "Mono";
|
_os << "Mono";
|
||||||
}
|
}
|
||||||
_os << "[U32](";
|
_os << "[U32](";
|
||||||
// TODO: set it back !!!!
|
_os << "0x" << etk::toHex(_obj.r(), 8);
|
||||||
/*
|
|
||||||
os << "0x" << std::setw(8) << std::setfill('0') << std::hex << _obj.r();
|
|
||||||
if (MY_TYPE_SIZE >= 2) {
|
if (MY_TYPE_SIZE >= 2) {
|
||||||
os << ",0x" << std::setw(8) << std::setfill('0') << std::hex << _obj.g();
|
_os << ",0x" << etk::toHex(_obj.g(), 8);
|
||||||
}
|
}
|
||||||
if (MY_TYPE_SIZE >= 3) {
|
if (MY_TYPE_SIZE >= 3) {
|
||||||
os << ",0x" << std::setw(8) << std::setfill('0') << std::hex << _obj.b();
|
_os << ",0x" << etk::toHex(_obj.b(), 8);
|
||||||
}
|
}
|
||||||
if (MY_TYPE_SIZE >= 4) {
|
if (MY_TYPE_SIZE >= 4) {
|
||||||
os << ",0x" << std::setw(8) << std::setfill('0') << std::hex << _obj.a();
|
_os << ",0x" << etk::toHex(_obj.a(), 8);
|
||||||
}
|
}
|
||||||
_os << os.str() << ")";
|
|
||||||
*/
|
|
||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
//! @not_in_doc
|
//! @not_in_doc
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license MPL v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <etk/Function.hpp>
|
||||||
|
uint32_t etk::MM___pppppp = 0;
|
||||||
|
|
@ -19,8 +19,6 @@ namespace etk {
|
|||||||
*
|
*
|
||||||
* @note The name is unique and the value is what you want
|
* @note The name is unique and the value is what you want
|
||||||
*
|
*
|
||||||
* @todo check if something else exist in the generic library. (not the etk::Map and the std::unordered_map
|
|
||||||
*
|
|
||||||
* @note The index are all time available since they are created. The order is the the one created
|
* @note The index are all time available since they are created. The order is the the one created
|
||||||
*
|
*
|
||||||
* A simple example of use:
|
* A simple example of use:
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
#include <etk/debug.hpp>
|
#include <etk/debug.hpp>
|
||||||
#include <etk/tool.hpp>
|
#include <etk/tool.hpp>
|
||||||
#include <etk/Noise.hpp>
|
#include <etk/Noise.hpp>
|
||||||
// for the rand ...
|
extern "C" {
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <cmath>
|
#include <math.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <cstdlib>
|
}
|
||||||
|
|
||||||
etk::BaseNoise::BaseNoise(const ivec2& _size, float _min, float _max) :
|
etk::BaseNoise::BaseNoise(const ivec2& _size, float _min, float _max) :
|
||||||
m_data(_size.x()*_size.y()),
|
m_data(_size.x()*_size.y()),
|
||||||
|
@ -14,7 +14,7 @@ namespace etk {
|
|||||||
*/
|
*/
|
||||||
class Stream {
|
class Stream {
|
||||||
private:
|
private:
|
||||||
// remove dependency of std::string and vector
|
// remove dependency of etk::String and vector
|
||||||
etk::String* m_data;
|
etk::String* m_data;
|
||||||
public:
|
public:
|
||||||
Stream(size_t _basicSize=0);
|
Stream(size_t _basicSize=0);
|
||||||
@ -40,21 +40,6 @@ namespace etk {
|
|||||||
const etk::String& str() const;
|
const etk::String& str() const;
|
||||||
const size_t size() const;
|
const size_t size() const;
|
||||||
};
|
};
|
||||||
// TODO: This is not a good place ...
|
|
||||||
/*
|
|
||||||
//! @not_in_doc
|
|
||||||
template<class ETK_VECTOR_TYPE>
|
|
||||||
etk::Stream& operator <<(etk::Stream& _os, const etk::Vector<ETK_VECTOR_TYPE>& _obj) {
|
|
||||||
_os << "{";
|
|
||||||
for (size_t iii=0; iii< _obj.size(); iii++) {
|
|
||||||
if (iii>0) {
|
|
||||||
_os << ";";
|
|
||||||
}
|
|
||||||
_os << _obj[iii];
|
|
||||||
}
|
|
||||||
_os << "}";
|
|
||||||
return _os;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ etk::String::String(const char* _obj) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
etk::String::String(const std::string _obj) {
|
etk::String::String(const etk::String _obj) {
|
||||||
resize(_obj.size());
|
resize(_obj.size());
|
||||||
for (size_t iii=0; iii<_obj.size(); ++iii) {
|
for (size_t iii=0; iii<_obj.size(); ++iii) {
|
||||||
m_data[iii] = _obj[iii];
|
m_data[iii] = _obj[iii];
|
||||||
@ -1124,3 +1124,47 @@ etk::String etk::operator+ (char _left, const etk::String& _right) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace etk {
|
||||||
|
template<> etk::String toString<etk::String>(const etk::String& _val) {
|
||||||
|
return _val;
|
||||||
|
}
|
||||||
|
template<> bool from_string<etk::String>(etk::String& _variableRet, const etk::UString& _value) {
|
||||||
|
_variableRet = u32char::convertToUtf8(_value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
char etk::toHexChar(uint8_t _value) {
|
||||||
|
char out;
|
||||||
|
if (_value < 10) {
|
||||||
|
return _value + '0';
|
||||||
|
}
|
||||||
|
return _value - 10 + 'A';
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::String etk::toHex(uint64_t _value, uint32_t _size) {
|
||||||
|
etk::String out;
|
||||||
|
for (int32_t iii = 15; iii >=0; --iii) {
|
||||||
|
if ( _size >= iii
|
||||||
|
|| _value >= uint64_t(1)<<iii) {
|
||||||
|
out += etk::toHexChar((_value>>(iii*4)) & 0x0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
etk::String etk::toBin(uint64_t _value, uint32_t _size) {
|
||||||
|
etk::String out;
|
||||||
|
for (int32_t iii = 63; iii >=0; --iii) {
|
||||||
|
if ( _size >= iii
|
||||||
|
|| _value >= uint64_t(1)<<iii) {
|
||||||
|
out += etk::toHexChar((_value>>(iii)) & 0x01);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ namespace etk {
|
|||||||
*/
|
*/
|
||||||
String(const char* _obj);
|
String(const char* _obj);
|
||||||
// TODO : remove this when ready
|
// TODO : remove this when ready
|
||||||
//////// String(const std::string _obj);
|
//////// String(const etk::String _obj);
|
||||||
/**
|
/**
|
||||||
* @brief Partial copy of the null-terminated C string.
|
* @brief Partial copy of the null-terminated C string.
|
||||||
* @param[in] _obj String that might be copyC string that might be copy (end by '\0')
|
* @param[in] _obj String that might be copyC string that might be copy (end by '\0')
|
||||||
@ -574,4 +574,8 @@ namespace etk {
|
|||||||
out += "}";
|
out += "}";
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char toHexChar(uint8_t _value);
|
||||||
|
etk::String toHex(uint64_t _value, uint32_t _size = 2);
|
||||||
|
etk::String toBin(uint64_t _value, uint32_t _size = 1);
|
||||||
}
|
}
|
||||||
|
@ -991,3 +991,16 @@ etk::UString etk::operator+ (char32_t _left, const etk::UString& _right) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace etk {
|
||||||
|
/*
|
||||||
|
template<> etk::UString toString<etk::UString>(const etk::UString& _val) {
|
||||||
|
return _val;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
template<> bool from_string<etk::UString>(etk::UString& _variableRet, const etk::String& _value) {
|
||||||
|
_variableRet = utf8::convertUnicode(_value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -223,6 +223,17 @@ namespace etk {
|
|||||||
changeAllocation(_count);
|
changeAllocation(_count);
|
||||||
m_size = _count;
|
m_size = _count;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @brief List initializer (ex: etk::Vector<etk::String> plop = {"hello", world"}
|
||||||
|
* @param[in] _element element to add in the vector
|
||||||
|
*/
|
||||||
|
template<typename... ETK_VECTOR_TYPE_2>
|
||||||
|
Vector(const ETK_VECTOR_TYPE_2& ... _args):
|
||||||
|
m_data(nullptr),
|
||||||
|
m_size(0),
|
||||||
|
m_allocated(0) {
|
||||||
|
pushBackN(_args...);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Re-copy constructor (copy all needed data)
|
* @brief Re-copy constructor (copy all needed data)
|
||||||
* @param[in] _obj Vector that might be copy
|
* @param[in] _obj Vector that might be copy
|
||||||
@ -414,6 +425,19 @@ namespace etk {
|
|||||||
void pushFront(const ETK_VECTOR_TYPE * _item, size_t _nbElement) {
|
void pushFront(const ETK_VECTOR_TYPE * _item, size_t _nbElement) {
|
||||||
insert(0, _item, _nbElement);
|
insert(0, _item, _nbElement);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @brief Add at the Last position of the Vector (move push)
|
||||||
|
* @param[in] _item Element to add at the end of vector
|
||||||
|
*/
|
||||||
|
void pushBack(ETK_VECTOR_TYPE&& _item) {
|
||||||
|
size_t idElement = m_size;
|
||||||
|
resize(m_size+1);
|
||||||
|
if (idElement < m_size) {
|
||||||
|
m_data[idElement] = etk::move(_item);
|
||||||
|
} else {
|
||||||
|
//TK_ERROR("Resize does not work correctly ... not added item");
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Add at the Last position of the Vector
|
* @brief Add at the Last position of the Vector
|
||||||
* @param[in] _item Element to add at the end of vector
|
* @param[in] _item Element to add at the end of vector
|
||||||
@ -446,6 +470,14 @@ namespace etk {
|
|||||||
m_data[idElement+iii] = _item[iii];
|
m_data[idElement+iii] = _item[iii];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void pushBackN(const ETK_VECTOR_TYPE& _value) {
|
||||||
|
pushBack(_value);
|
||||||
|
}
|
||||||
|
template<typename... ETK_VECTOR_TYPE_2>
|
||||||
|
void pushBackN(const ETK_VECTOR_TYPE& _value, const ETK_VECTOR_TYPE_2& ... _args) {
|
||||||
|
pushBack(_value);
|
||||||
|
pushBackN(_args...);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Remove the first element of the vector
|
* @brief Remove the first element of the vector
|
||||||
*/
|
*/
|
||||||
@ -809,8 +841,8 @@ namespace etk {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
//! @not_in_doc
|
//! @not_in_doc
|
||||||
template<typename T, typename T2>
|
template<typename ETK_VECTOR_TYPE_1, typename ETK_VECTOR_TYPE_2>
|
||||||
bool isIn(const T& _val, const etk::Vector<T2>& _list) {
|
bool isIn(const ETK_VECTOR_TYPE_1& _val, const etk::Vector<ETK_VECTOR_TYPE_2>& _list) {
|
||||||
for (size_t iii=0; iii<_list.size(); ++iii) {
|
for (size_t iii=0; iii<_list.size(); ++iii) {
|
||||||
if (_list[iii] == _val) {
|
if (_list[iii] == _val) {
|
||||||
return true;
|
return true;
|
||||||
@ -818,4 +850,19 @@ namespace etk {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
class Stream;
|
||||||
|
//! @not_in_doc
|
||||||
|
template<class ETK_VECTOR_TYPE>
|
||||||
|
etk::Stream& operator <<(etk::Stream& _os, const etk::Vector<ETK_VECTOR_TYPE>& _obj) {
|
||||||
|
_os << "{";
|
||||||
|
for (size_t iii=0; iii< _obj.size(); iii++) {
|
||||||
|
if (iii>0) {
|
||||||
|
_os << ";";
|
||||||
|
}
|
||||||
|
_os << _obj[iii];
|
||||||
|
}
|
||||||
|
_os << "}";
|
||||||
|
return _os;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,9 @@
|
|||||||
#include <etk/debug.hpp>
|
#include <etk/debug.hpp>
|
||||||
#include <elog/elog.hpp>
|
#include <elog/elog.hpp>
|
||||||
#include <etk/os/FSNode.hpp>
|
#include <etk/os/FSNode.hpp>
|
||||||
#include <etk/Function.hpp>
|
|
||||||
|
|
||||||
static int32_t nbTimeInit = 0;
|
static int32_t nbTimeInit = 0;
|
||||||
uint32_t etk::MM___pppppp = 0;
|
|
||||||
void etk::unInit() {
|
void etk::unInit() {
|
||||||
if (nbTimeInit > 1) {
|
if (nbTimeInit > 1) {
|
||||||
nbTimeInit--;
|
nbTimeInit--;
|
||||||
|
@ -534,7 +534,7 @@ namespace etk {
|
|||||||
*/
|
*/
|
||||||
void identity() {
|
void identity() {
|
||||||
// copy data for the same size :
|
// copy data for the same size :
|
||||||
for (int32_t iii=0; iii< std::mim(m_size.x(), m_size.y()); iii++) {
|
for (int32_t iii=0; iii< etk::mim(m_size.x(), m_size.y()); iii++) {
|
||||||
(*this)(iii,iii) = (T)1;
|
(*this)(iii,iii) = (T)1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -192,14 +192,14 @@ etk::Matrix2x2 etk::Matrix2x2::zero() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
etk::Matrix2x2 etk::Matrix2x2::getAbsolute() const {
|
etk::Matrix2x2 etk::Matrix2x2::getAbsolute() const {
|
||||||
return Matrix2x2(std::abs(m_mat[0]), std::abs(m_mat[1]),
|
return Matrix2x2(etk::abs(m_mat[0]), etk::abs(m_mat[1]),
|
||||||
std::abs(m_mat[2]), std::abs(m_mat[3]));
|
etk::abs(m_mat[2]), etk::abs(m_mat[3]));
|
||||||
}
|
}
|
||||||
void etk::Matrix2x2::absolute() {
|
void etk::Matrix2x2::absolute() {
|
||||||
m_mat[0] = std::abs(m_mat[0]);
|
m_mat[0] = etk::abs(m_mat[0]);
|
||||||
m_mat[1] = std::abs(m_mat[1]);
|
m_mat[1] = etk::abs(m_mat[1]);
|
||||||
m_mat[2] = std::abs(m_mat[2]);
|
m_mat[2] = etk::abs(m_mat[2]);
|
||||||
m_mat[3] = std::abs(m_mat[3]);
|
m_mat[3] = etk::abs(m_mat[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void etk::Matrix2x2::inverse() {
|
void etk::Matrix2x2::inverse() {
|
||||||
@ -208,7 +208,7 @@ void etk::Matrix2x2::inverse() {
|
|||||||
|
|
||||||
etk::Matrix2x2 etk::Matrix2x2::getInverse() const {
|
etk::Matrix2x2 etk::Matrix2x2::getInverse() const {
|
||||||
float det = determinant();
|
float det = determinant();
|
||||||
//assert(std::abs(det) > MACHINE_EPSILON);
|
//assert(etk::abs(det) > MACHINE_EPSILON);
|
||||||
float invDet = 1.0f / det;
|
float invDet = 1.0f / det;
|
||||||
return etk::Matrix2x2(m_mat[3], -m_mat[1], -m_mat[2], m_mat[0]) * invDet;
|
return etk::Matrix2x2(m_mat[3], -m_mat[1], -m_mat[2], m_mat[0]) * invDet;
|
||||||
}
|
}
|
||||||
|
@ -146,21 +146,21 @@ etk::Matrix3x3 etk::Matrix3x3::zero() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void etk::Matrix3x3::absolute() {
|
void etk::Matrix3x3::absolute() {
|
||||||
m_mat[0] = std::abs(m_mat[0]);
|
m_mat[0] = etk::abs(m_mat[0]);
|
||||||
m_mat[1] = std::abs(m_mat[1]);
|
m_mat[1] = etk::abs(m_mat[1]);
|
||||||
m_mat[2] = std::abs(m_mat[2]);
|
m_mat[2] = etk::abs(m_mat[2]);
|
||||||
m_mat[3] = std::abs(m_mat[3]);
|
m_mat[3] = etk::abs(m_mat[3]);
|
||||||
m_mat[4] = std::abs(m_mat[4]);
|
m_mat[4] = etk::abs(m_mat[4]);
|
||||||
m_mat[5] = std::abs(m_mat[5]);
|
m_mat[5] = etk::abs(m_mat[5]);
|
||||||
m_mat[6] = std::abs(m_mat[6]);
|
m_mat[6] = etk::abs(m_mat[6]);
|
||||||
m_mat[7] = std::abs(m_mat[7]);
|
m_mat[7] = etk::abs(m_mat[7]);
|
||||||
m_mat[8] = std::abs(m_mat[8]);
|
m_mat[8] = etk::abs(m_mat[8]);
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::Matrix3x3 etk::Matrix3x3::getAbsolute() const {
|
etk::Matrix3x3 etk::Matrix3x3::getAbsolute() const {
|
||||||
return etk::Matrix3x3(std::abs(m_mat[0]), std::abs(m_mat[1]), std::abs(m_mat[2]),
|
return etk::Matrix3x3(etk::abs(m_mat[0]), etk::abs(m_mat[1]), etk::abs(m_mat[2]),
|
||||||
std::abs(m_mat[3]), std::abs(m_mat[4]), std::abs(m_mat[5]),
|
etk::abs(m_mat[3]), etk::abs(m_mat[4]), etk::abs(m_mat[5]),
|
||||||
std::abs(m_mat[6]), std::abs(m_mat[7]), std::abs(m_mat[8]));
|
etk::abs(m_mat[6]), etk::abs(m_mat[7]), etk::abs(m_mat[8]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ void etk::Matrix3x3::inverse() {
|
|||||||
|
|
||||||
etk::Matrix3x3 etk::Matrix3x3::getInverse() const {
|
etk::Matrix3x3 etk::Matrix3x3::getInverse() const {
|
||||||
float det = determinant();
|
float det = determinant();
|
||||||
//assert(std::abs(det) > MACHINE_EPSILON);
|
//assert(etk::abs(det) > MACHINE_EPSILON);
|
||||||
float invDet = 1.0f / det;
|
float invDet = 1.0f / det;
|
||||||
return etk::Matrix3x3( (m_mat[4]*m_mat[8]-m_mat[7]*m_mat[5]),
|
return etk::Matrix3x3( (m_mat[4]*m_mat[8]-m_mat[7]*m_mat[5]),
|
||||||
-(m_mat[1]*m_mat[8]-m_mat[7]*m_mat[2]),
|
-(m_mat[1]*m_mat[8]-m_mat[7]*m_mat[2]),
|
||||||
|
@ -346,7 +346,7 @@ float etk::Matrix4x4::determinant() const {
|
|||||||
|
|
||||||
etk::Matrix4x4 etk::Matrix4x4::invert() {
|
etk::Matrix4x4 etk::Matrix4x4::invert() {
|
||||||
float det = determinant();
|
float det = determinant();
|
||||||
if(std::abs(det) < (1.0e-7f)) {
|
if(etk::abs(det) < (1.0e-7f)) {
|
||||||
// The matrix is not invertible! Singular case!
|
// The matrix is not invertible! Singular case!
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -125,14 +125,14 @@ etk::Quaternion etk::Quaternion::slerp(const Quaternion& _obj1,
|
|||||||
|
|
||||||
void etk::Quaternion::setEulerAngles(const vec3& _angles) {
|
void etk::Quaternion::setEulerAngles(const vec3& _angles) {
|
||||||
float angle = _angles.x() * 0.5f;
|
float angle = _angles.x() * 0.5f;
|
||||||
float sinX = std::sin(angle);
|
float sinX = etk::sin(angle);
|
||||||
float cosX = std::cos(angle);
|
float cosX = etk::cos(angle);
|
||||||
angle = _angles.y() * 0.5f;
|
angle = _angles.y() * 0.5f;
|
||||||
float sinY = std::sin(angle);
|
float sinY = etk::sin(angle);
|
||||||
float cosY = std::cos(angle);
|
float cosY = etk::cos(angle);
|
||||||
angle = _angles.z() * 0.5f;
|
angle = _angles.z() * 0.5f;
|
||||||
float sinZ = std::sin(angle);
|
float sinZ = etk::sin(angle);
|
||||||
float cosZ = std::cos(angle);
|
float cosZ = etk::cos(angle);
|
||||||
float cosYcosZ = cosY * cosZ;
|
float cosYcosZ = cosY * cosZ;
|
||||||
float sinYcosZ = sinY * cosZ;
|
float sinYcosZ = sinY * cosZ;
|
||||||
float cosYsinZ = cosY * sinZ;
|
float cosYsinZ = cosY * sinZ;
|
||||||
|
@ -188,7 +188,7 @@ namespace etk {
|
|||||||
*/
|
*/
|
||||||
float length() const {
|
float length() const {
|
||||||
#if __CPP_VERSION__ >= 2011 && !defined(__TARGET_OS__MacOs) && !defined(__TARGET_OS__IOs)
|
#if __CPP_VERSION__ >= 2011 && !defined(__TARGET_OS__MacOs) && !defined(__TARGET_OS__IOs)
|
||||||
return std::sqrt(length2());
|
return etk::sqrt(length2());
|
||||||
#else
|
#else
|
||||||
return sqrt(length2());
|
return sqrt(length2());
|
||||||
#endif
|
#endif
|
||||||
@ -270,10 +270,10 @@ namespace etk {
|
|||||||
* @return New quaternion with the absolute value
|
* @return New quaternion with the absolute value
|
||||||
*/
|
*/
|
||||||
Quaternion absolute() const {
|
Quaternion absolute() const {
|
||||||
return Quaternion( std::abs(m_floats[0]),
|
return Quaternion( etk::abs(m_floats[0]),
|
||||||
std::abs(m_floats[1]),
|
etk::abs(m_floats[1]),
|
||||||
std::abs(m_floats[2]),
|
etk::abs(m_floats[2]),
|
||||||
std::abs(m_floats[3]));
|
etk::abs(m_floats[3]));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Get X value
|
* @brief Get X value
|
||||||
|
@ -87,8 +87,8 @@ etk::Stream& etk::operator <<(etk::Stream& _os, const etk::Vector<bvec2 >& _obj)
|
|||||||
vec2 vec2rotate(const vec2& _val, const vec2& _point, float _angle) {
|
vec2 vec2rotate(const vec2& _val, const vec2& _point, float _angle) {
|
||||||
vec2 out = _val;
|
vec2 out = _val;
|
||||||
#if __CPP_VERSION__ >= 2011 && !defined(__STDCPP_LLVM__)
|
#if __CPP_VERSION__ >= 2011 && !defined(__STDCPP_LLVM__)
|
||||||
float sinAngle = std::sin(_angle);
|
float sinAngle = etk::sin(_angle);
|
||||||
float cosAngle = std::cos(_angle);
|
float cosAngle = etk::cos(_angle);
|
||||||
#else
|
#else
|
||||||
float sinAngle = sin(_angle);
|
float sinAngle = sin(_angle);
|
||||||
float cosAngle = cos(_angle);
|
float cosAngle = cos(_angle);
|
||||||
|
@ -365,7 +365,7 @@ namespace etk {
|
|||||||
*/
|
*/
|
||||||
float length() const {
|
float length() const {
|
||||||
#if __CPP_VERSION__ >= 2011 && !defined(__STDCPP_LLVM__)
|
#if __CPP_VERSION__ >= 2011 && !defined(__STDCPP_LLVM__)
|
||||||
return std::sqrt(length2());
|
return etk::sqrt(length2());
|
||||||
#else
|
#else
|
||||||
return sqrt(length2());
|
return sqrt(length2());
|
||||||
#endif
|
#endif
|
||||||
@ -421,8 +421,8 @@ namespace etk {
|
|||||||
* @return New vector containing the value
|
* @return New vector containing the value
|
||||||
*/
|
*/
|
||||||
Vector2D<ETK_TYPE> absolute() const {
|
Vector2D<ETK_TYPE> absolute() const {
|
||||||
return Vector2D<ETK_TYPE>( std::abs(m_floats[0]),
|
return Vector2D<ETK_TYPE>( etk::abs(m_floats[0]),
|
||||||
std::abs(m_floats[1]));
|
etk::abs(m_floats[1]));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Return the axis with the smallest value
|
* @brief Return the axis with the smallest value
|
||||||
|
@ -185,7 +185,7 @@ namespace etk {
|
|||||||
*/
|
*/
|
||||||
float length() const {
|
float length() const {
|
||||||
#if __CPP_VERSION__ >= 2011 && !defined(__STDCPP_LLVM__)
|
#if __CPP_VERSION__ >= 2011 && !defined(__STDCPP_LLVM__)
|
||||||
return std::sqrt(length2());
|
return etk::sqrt(length2());
|
||||||
#else
|
#else
|
||||||
return sqrt(length2());
|
return sqrt(length2());
|
||||||
#endif
|
#endif
|
||||||
@ -274,9 +274,9 @@ namespace etk {
|
|||||||
* @return New vector containing the value
|
* @return New vector containing the value
|
||||||
*/
|
*/
|
||||||
Vector3D<T> absolute() const {
|
Vector3D<T> absolute() const {
|
||||||
return Vector3D<T>( std::abs(m_floats[0]),
|
return Vector3D<T>( etk::abs(m_floats[0]),
|
||||||
std::abs(m_floats[1]),
|
etk::abs(m_floats[1]),
|
||||||
std::abs(m_floats[2]));
|
etk::abs(m_floats[2]));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Return the cross product between this and another vector
|
* @brief Return the cross product between this and another vector
|
||||||
@ -567,16 +567,16 @@ namespace etk {
|
|||||||
* @return The ortho vector
|
* @return The ortho vector
|
||||||
*/
|
*/
|
||||||
Vector3D<T> getOrthoVector() const {
|
Vector3D<T> getOrthoVector() const {
|
||||||
Vector3D<T> vectorAbs(std::abs(m_floats[0]), std::abs(m_floats[1]), std::abs(m_floats[2]));
|
Vector3D<T> vectorAbs(etk::abs(m_floats[0]), etk::abs(m_floats[1]), etk::abs(m_floats[2]));
|
||||||
int32_t minElement = vectorAbs.getMinAxis();
|
int32_t minElement = vectorAbs.getMinAxis();
|
||||||
if (minElement == 0) {
|
if (minElement == 0) {
|
||||||
float devider = 1.0f / std::sqrt(m_floats[1]*m_floats[1] + m_floats[2]*m_floats[2]);
|
float devider = 1.0f / etk::sqrt(m_floats[1]*m_floats[1] + m_floats[2]*m_floats[2]);
|
||||||
return Vector3D<T>(0.0f, -m_floats[2]*devider, m_floats[1]*devider);
|
return Vector3D<T>(0.0f, -m_floats[2]*devider, m_floats[1]*devider);
|
||||||
} else if (minElement == 1) {
|
} else if (minElement == 1) {
|
||||||
float devider = 1.0f / std::sqrt(m_floats[0]*m_floats[0] + m_floats[2]*m_floats[2]);
|
float devider = 1.0f / etk::sqrt(m_floats[0]*m_floats[0] + m_floats[2]*m_floats[2]);
|
||||||
return Vector3D<T>(-m_floats[2]*devider, 0.0f, m_floats[0]*devider);
|
return Vector3D<T>(-m_floats[2]*devider, 0.0f, m_floats[0]*devider);
|
||||||
}
|
}
|
||||||
float devider = 1.0f / std::sqrt(m_floats[0]*m_floats[0] + m_floats[1]*m_floats[1]);
|
float devider = 1.0f / etk::sqrt(m_floats[0]*m_floats[0] + m_floats[1]*m_floats[1]);
|
||||||
return Vector3D<T>(-m_floats[1]*devider, m_floats[0]*devider, 0.0f);
|
return Vector3D<T>(-m_floats[1]*devider, m_floats[0]*devider, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ namespace etk {
|
|||||||
return btSqrt(length2());
|
return btSqrt(length2());
|
||||||
#else
|
#else
|
||||||
#if __CPP_VERSION__ >= 2011 && !defined(__TARGET_OS__MacOs) && !defined(__TARGET_OS__IOs)
|
#if __CPP_VERSION__ >= 2011 && !defined(__TARGET_OS__MacOs) && !defined(__TARGET_OS__IOs)
|
||||||
return std::sqrt(length2());
|
return etk::sqrt(length2());
|
||||||
#else
|
#else
|
||||||
return sqrt(length2());
|
return sqrt(length2());
|
||||||
#endif
|
#endif
|
||||||
@ -221,10 +221,10 @@ namespace etk {
|
|||||||
* @return New vector with the absolute value
|
* @return New vector with the absolute value
|
||||||
*/
|
*/
|
||||||
Vector4D<T> absolute() const {
|
Vector4D<T> absolute() const {
|
||||||
return Vector4D<T>( std::abs(m_floats[0]),
|
return Vector4D<T>( etk::abs(m_floats[0]),
|
||||||
std::abs(m_floats[1]),
|
etk::abs(m_floats[1]),
|
||||||
std::abs(m_floats[2]),
|
etk::abs(m_floats[2]),
|
||||||
std::abs(m_floats[3]));
|
etk::abs(m_floats[3]));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Multiply this vector by the other.
|
* @brief Multiply this vector by the other.
|
||||||
|
20
etk/move.hpp
20
etk/move.hpp
@ -6,7 +6,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <etk/typeTrait.hpp>
|
#include <etk/typeTrait.hpp>
|
||||||
#include <utility>
|
|
||||||
namespace etk {
|
namespace etk {
|
||||||
template<class ETK_MOVE_TYPE>
|
template<class ETK_MOVE_TYPE>
|
||||||
struct RemoveReference {
|
struct RemoveReference {
|
||||||
@ -23,20 +22,11 @@ namespace etk {
|
|||||||
// remove rvalue reference
|
// remove rvalue reference
|
||||||
typedef ETK_MOVE_TYPE m_type;
|
typedef ETK_MOVE_TYPE m_type;
|
||||||
};
|
};
|
||||||
#if 0
|
template<typename ETK_MOVE_TYPE>
|
||||||
template<class ETK_MOVE_TYPE> inline
|
inline typename etk::RemoveReference<ETK_MOVE_TYPE>::m_type&& move(ETK_MOVE_TYPE&& _obj) {
|
||||||
typename etk::RemoveReference<ETK_MOVE_TYPE>::m_type&& move(ETK_MOVE_TYPE&& _obj) {
|
// forward _Arg as movable
|
||||||
// forward _Arg as movable
|
return (typename etk::RemoveReference<ETK_MOVE_TYPE>::m_type&&)_obj;
|
||||||
return ((typename etk::RemoveReference<ETK_MOVE_TYPE>::m_type&&)_obj);
|
}
|
||||||
}
|
|
||||||
#else
|
|
||||||
template<class ETK_MOVE_TYPE> inline
|
|
||||||
ETK_MOVE_TYPE move(const ETK_MOVE_TYPE& _obj) {
|
|
||||||
// forward _Arg as movable
|
|
||||||
return _obj;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
template<typename ETK_SWAP_TYPE>
|
template<typename ETK_SWAP_TYPE>
|
||||||
inline void swap(ETK_SWAP_TYPE& _obj1, ETK_SWAP_TYPE& _obj2) {
|
inline void swap(ETK_SWAP_TYPE& _obj1, ETK_SWAP_TYPE& _obj2) {
|
||||||
|
@ -8,21 +8,20 @@
|
|||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <etk/os/FSNode.hpp>
|
#include <etk/os/FSNode.hpp>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <cstdlib>
|
#include <stdlib.h>
|
||||||
#include <etk/tool.hpp>
|
#include <etk/tool.hpp>
|
||||||
#include <etk/debug.hpp>
|
#include <etk/debug.hpp>
|
||||||
#include <etk/Map.hpp>
|
#include <etk/Map.hpp>
|
||||||
#include <ethread/Mutex.hpp>
|
#include <ethread/Mutex.hpp>
|
||||||
#ifdef __TARGET_OS__Windows
|
#ifdef __TARGET_OS__Windows
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <iostream>
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
extern "C" {
|
extern "C" {
|
||||||
// file browsing ...
|
// file browsing ...
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <cerrno>
|
#include <errno.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_ZIP_DATA
|
#ifdef HAVE_ZIP_DATA
|
||||||
@ -1702,7 +1701,7 @@ etk::Vector<etk::String> etk::FSNode::folderGetSub(bool _getFolder, bool _getFil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::sort(out.begin(), out.end());
|
out.sort(0, out.size(), [](const etk::String& _left, const etk::String& _right) { return(_left<_right); });
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ethread/Mutex.hpp>
|
#include <ethread/Mutex.hpp>
|
||||||
|
#include <ethread/Semaphore.hpp>
|
||||||
#include <etk/Vector.hpp>
|
#include <etk/Vector.hpp>
|
||||||
#include <condition_variable>
|
|
||||||
|
|
||||||
namespace etk {
|
namespace etk {
|
||||||
/**
|
/**
|
||||||
@ -21,7 +21,7 @@ namespace etk {
|
|||||||
template<class MY_TYPE=int32_t> class Fifo {
|
template<class MY_TYPE=int32_t> class Fifo {
|
||||||
private :
|
private :
|
||||||
ethread::Mutex m_mutex; //!< protection of the internal data.
|
ethread::Mutex m_mutex; //!< protection of the internal data.
|
||||||
std::condition_variable m_condition; //!< Message system to send event on an other thread.
|
ethread::Semaphore m_semaphore; //!< protection of the internal data.
|
||||||
etk::Vector<MY_TYPE> m_data; //!< List of all message to send
|
etk::Vector<MY_TYPE> m_data; //!< List of all message to send
|
||||||
public :
|
public :
|
||||||
/**
|
/**
|
||||||
@ -43,15 +43,15 @@ namespace etk {
|
|||||||
* @return false No data found or closed fifo
|
* @return false No data found or closed fifo
|
||||||
*/
|
*/
|
||||||
bool wait(MY_TYPE &_data) {
|
bool wait(MY_TYPE &_data) {
|
||||||
std::unique_lock<ethread::Mutex> lock(m_mutex);
|
|
||||||
// Check if data is not previously here
|
// Check if data is not previously here
|
||||||
while(m_data.size() == 0) {
|
while(m_data.size() == 0) {
|
||||||
m_condition.wait(lock);
|
m_semaphore.wait();
|
||||||
}
|
}
|
||||||
|
ethread::UniqueLock lock(m_mutex);
|
||||||
// End Waiting message :
|
// End Waiting message :
|
||||||
if (m_data.size() > 0) {
|
if (m_data.size() > 0) {
|
||||||
// copy element :
|
// copy element :
|
||||||
std::swap(_data, m_data[0]);
|
etk::swap(_data, m_data[0]);
|
||||||
// remove element :
|
// remove element :
|
||||||
m_data.erase(m_data.begin());
|
m_data.erase(m_data.begin());
|
||||||
return true;
|
return true;
|
||||||
@ -66,17 +66,17 @@ namespace etk {
|
|||||||
* @return false No message found while time-out appear.
|
* @return false No message found while time-out appear.
|
||||||
*/
|
*/
|
||||||
bool wait(MY_TYPE &_data, uint32_t _timeOutInUs) {
|
bool wait(MY_TYPE &_data, uint32_t _timeOutInUs) {
|
||||||
std::unique_lock<ethread::Mutex> lock(m_mutex);
|
|
||||||
// Check if data is not previously here
|
// Check if data is not previously here
|
||||||
while(m_data.size() == 0) {
|
while(m_data.size() == 0) {
|
||||||
if (m_condition.wait_for(lock, std::chrono::microseconds(_timeOutInUs)) == std::cv_status::timeout) {
|
if (m_semaphore.wait(_timeOutInUs) == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ethread::UniqueLock lock(m_mutex);
|
||||||
// End Waiting message :
|
// End Waiting message :
|
||||||
if (m_data.size() > 0) {
|
if (m_data.size() > 0) {
|
||||||
// copy element :
|
// copy element :
|
||||||
std::swap(_data, m_data[0]);
|
etk::swap(_data, m_data[0]);
|
||||||
// remove element :
|
// remove element :
|
||||||
m_data.erase(0);
|
m_data.erase(0);
|
||||||
return true;
|
return true;
|
||||||
@ -88,7 +88,7 @@ namespace etk {
|
|||||||
* @return Number of message in the fifo.
|
* @return Number of message in the fifo.
|
||||||
*/
|
*/
|
||||||
int32_t count() {
|
int32_t count() {
|
||||||
std::unique_lock<ethread::Mutex> lock(m_mutex);
|
ethread::UniqueLock lock(m_mutex);
|
||||||
int32_t nbElement = m_data.size();
|
int32_t nbElement = m_data.size();
|
||||||
return nbElement;
|
return nbElement;
|
||||||
};
|
};
|
||||||
@ -97,27 +97,28 @@ namespace etk {
|
|||||||
* @param[in] _data New data to add at the fifo.
|
* @param[in] _data New data to add at the fifo.
|
||||||
*/
|
*/
|
||||||
void post(MY_TYPE &_data) {
|
void post(MY_TYPE &_data) {
|
||||||
std::unique_lock<ethread::Mutex> lock(m_mutex);
|
ethread::UniqueLock lock(m_mutex);
|
||||||
m_data.pushBack(_data);
|
m_data.pushBack(_data);
|
||||||
m_condition.notify_all();
|
m_semaphore.post();
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @brief Send a message at the other thread by setting a new message in the fifo.
|
* @brief Send a message at the other thread by setting a new message in the fifo.
|
||||||
* @param[in] _data New data to add at the fifo.
|
* @param[in] _data New data to add at the fifo.
|
||||||
*/
|
*/
|
||||||
void post(const MY_TYPE &_data) {
|
void post(const MY_TYPE &_data) {
|
||||||
std::unique_lock<ethread::Mutex> lock(m_mutex);
|
ethread::UniqueLock lock(m_mutex);
|
||||||
m_data.pushBack(_data);
|
m_data.pushBack(_data);
|
||||||
m_condition.notify_all();
|
m_semaphore.post();
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @brief Remove all the message in the fifo.
|
* @brief Remove all the message in the fifo.
|
||||||
*/
|
*/
|
||||||
void clean() {
|
void clean() {
|
||||||
std::unique_lock<ethread::Mutex> lock(m_mutex);
|
ethread::UniqueLock lock(m_mutex);
|
||||||
// remove data
|
// remove data
|
||||||
m_data.clear();
|
m_data.clear();
|
||||||
m_condition.wait_for(lock, std::chrono::microseconds(0));
|
//m_condition.wait_for(lock, echrono::microseconds(0));
|
||||||
|
m_semaphore.post();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,60 @@
|
|||||||
* @license MPL v2.0 (see license file)
|
* @license MPL v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
//#include <etk/Stream.hpp>
|
||||||
|
|
||||||
namespace etk {
|
namespace etk {
|
||||||
|
inline float cos(float _value) {
|
||||||
|
return ::cosf(_value);
|
||||||
|
}
|
||||||
|
inline float sin(float _value) {
|
||||||
|
return ::sinf(_value);
|
||||||
|
}
|
||||||
|
inline float tan(float _value) {
|
||||||
|
return ::tanf(_value);
|
||||||
|
}
|
||||||
|
inline float acos(float _value) {
|
||||||
|
return ::acosf(_value);
|
||||||
|
}
|
||||||
|
inline float asin(float _value) {
|
||||||
|
return ::asinf(_value);
|
||||||
|
}
|
||||||
|
inline float atan(float _value) {
|
||||||
|
return ::atanf(_value);
|
||||||
|
}
|
||||||
|
inline float sqrt(float _value) {
|
||||||
|
return ::sqrtf(_value);
|
||||||
|
}
|
||||||
|
inline double cos(double _value) {
|
||||||
|
return ::cos(_value);
|
||||||
|
}
|
||||||
|
inline double sin(double _value) {
|
||||||
|
return ::sin(_value);
|
||||||
|
}
|
||||||
|
inline double tan(double _value) {
|
||||||
|
return ::tan(_value);
|
||||||
|
}
|
||||||
|
inline double acos(double _value) {
|
||||||
|
return ::acos(_value);
|
||||||
|
}
|
||||||
|
inline double asin(double _value) {
|
||||||
|
return ::asin(_value);
|
||||||
|
}
|
||||||
|
inline double atan(double _value) {
|
||||||
|
return ::atan(_value);
|
||||||
|
}
|
||||||
|
inline double sqrt(double _value) {
|
||||||
|
return ::sqrt(_value);
|
||||||
|
}
|
||||||
template <class TYPE> const TYPE& min(const TYPE& _val1, const TYPE& _val2) {
|
template <class TYPE> const TYPE& min(const TYPE& _val1, const TYPE& _val2) {
|
||||||
return (_val1 > _val2) ? _val2 : _val1;
|
return (_val1 > _val2) ? _val2 : _val1;
|
||||||
}
|
}
|
||||||
template <class TYPE> const TYPE& max(const TYPE& _val1, const TYPE& _val2) {
|
template <class TYPE> const TYPE& max(const TYPE& _val1, const TYPE& _val2) {
|
||||||
return (_val1 > _val2) ? _val1 : _val2;
|
return (_val1 > _val2) ? _val1 : _val2;
|
||||||
}
|
}
|
||||||
|
template <class TYPE> TYPE abs(const TYPE& _value) {
|
||||||
|
return (_value >= 0) ? _value : -_value;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @brief in std, we have min, max but not avg ==> it is missing... the Define of avg template.
|
* @brief in std, we have min, max but not avg ==> it is missing... the Define of avg template.
|
||||||
* @param[in] _min Minimum value of the range
|
* @param[in] _min Minimum value of the range
|
||||||
@ -32,4 +78,14 @@ namespace etk {
|
|||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
template<class ETK_ITERATOR_TYPE_1, class ETK_ITERATOR_TYPE_2>
|
||||||
|
ETK_ITERATOR_TYPE_1 find(ETK_ITERATOR_TYPE_1 _start, ETK_ITERATOR_TYPE_1 _stop, const ETK_ITERATOR_TYPE_2& _value) {
|
||||||
|
while (_start != _stop) {
|
||||||
|
if (*_start == _value) {
|
||||||
|
return _start;
|
||||||
|
}
|
||||||
|
++_start;
|
||||||
|
}
|
||||||
|
return _stop;
|
||||||
|
}
|
||||||
}
|
}
|
13
etk/tool.cpp
13
etk/tool.cpp
@ -6,11 +6,11 @@
|
|||||||
|
|
||||||
#include <etk/tool.hpp>
|
#include <etk/tool.hpp>
|
||||||
#include <etk/os/FSNode.hpp>
|
#include <etk/os/FSNode.hpp>
|
||||||
// for the rand ...
|
extern "C" {
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <cmath>
|
#include <math.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <cstdlib>
|
}
|
||||||
|
|
||||||
double etk::tool::frand(double _a, double _b) {
|
double etk::tool::frand(double _a, double _b) {
|
||||||
return (float)(( (double)rand()/(double)RAND_MAX ) * ((double)_b-(double)_a) + (double)_a);
|
return (float)(( (double)rand()/(double)RAND_MAX ) * ((double)_b-(double)_a) + (double)_a);
|
||||||
@ -19,6 +19,9 @@ double etk::tool::frand(double _a, double _b) {
|
|||||||
int32_t etk::tool::irand(int32_t _a, int32_t _b) {
|
int32_t etk::tool::irand(int32_t _a, int32_t _b) {
|
||||||
return (int32_t)(( rand()/(double)RAND_MAX ) * ((double)_b-(double)_a) + (double)_a);
|
return (int32_t)(( rand()/(double)RAND_MAX ) * ((double)_b-(double)_a) + (double)_a);
|
||||||
}
|
}
|
||||||
|
uint32_t etk::tool::urand(uint32_t _a, uint32_t _b) {
|
||||||
|
return (uint32_t)(( rand()/(double)RAND_MAX ) * ((double)_b-(double)_a) + (double)_a);
|
||||||
|
}
|
||||||
|
|
||||||
void etk::tool::resetRandom() {
|
void etk::tool::resetRandom() {
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
@ -27,7 +27,8 @@ namespace etk {
|
|||||||
* @param[in] _b Bigger value of the random.
|
* @param[in] _b Bigger value of the random.
|
||||||
* @return Random Value between [_a and _b]
|
* @return Random Value between [_a and _b]
|
||||||
*/
|
*/
|
||||||
int32_t irand(int32_t _a, int32_t _b);
|
int32_t irand(int32_t _a=0x80000000, int32_t _b=0x7FFFFFFF);
|
||||||
|
uint32_t urand(uint32_t _a=0, uint32_t _b=0xFFFFFFFF);
|
||||||
/**
|
/**
|
||||||
* @brief Reset the random system with a random value (time).
|
* @brief Reset the random system with a random value (time).
|
||||||
*/
|
*/
|
||||||
|
@ -66,9 +66,7 @@ namespace u32char {
|
|||||||
* @return Number of char in utf8
|
* @return Number of char in utf8
|
||||||
*/
|
*/
|
||||||
int8_t convertUtf8(char32_t _val, char _output[5]);
|
int8_t convertUtf8(char32_t _val, char _output[5]);
|
||||||
#if __CPP_VERSION__ >= 2011
|
etk::String convertToUtf8(const etk::UString& _input);
|
||||||
etk::String convertToUtf8(const etk::UString& _input);
|
|
||||||
#endif
|
|
||||||
char32_t toUpper(char32_t _input);
|
char32_t toUpper(char32_t _input);
|
||||||
char32_t toLower(char32_t _input);
|
char32_t toLower(char32_t _input);
|
||||||
size_t strlen(const char32_t* _input);
|
size_t strlen(const char32_t* _input);
|
||||||
|
@ -54,7 +54,7 @@ TEST(TestQuaternion, constructorMatrix) {
|
|||||||
|
|
||||||
TEST(TestQuaternion, constructorEuler) {
|
TEST(TestQuaternion, constructorEuler) {
|
||||||
etk::Quaternion test0(vec3(M_PI*0.5f, 0, 0));
|
etk::Quaternion test0(vec3(M_PI*0.5f, 0, 0));
|
||||||
etk::Quaternion test01(std::sin(M_PI*0.25f), 0, 0, std::cos(M_PI*0.25f));
|
etk::Quaternion test01(etk::sin(M_PI*0.25f), 0, 0, etk::cos(M_PI*0.25f));
|
||||||
test01.normalize();
|
test01.normalize();
|
||||||
EXPECT_FLOAT_EQ(test0.x(), test01.x());
|
EXPECT_FLOAT_EQ(test0.x(), test01.x());
|
||||||
EXPECT_FLOAT_EQ(test0.y(), test01.y());
|
EXPECT_FLOAT_EQ(test0.y(), test01.y());
|
||||||
@ -62,7 +62,7 @@ TEST(TestQuaternion, constructorEuler) {
|
|||||||
EXPECT_FLOAT_EQ(test0.w(), test01.w());
|
EXPECT_FLOAT_EQ(test0.w(), test01.w());
|
||||||
|
|
||||||
etk::Quaternion test1(vec3(0, M_PI*0.5f, 0));
|
etk::Quaternion test1(vec3(0, M_PI*0.5f, 0));
|
||||||
etk::Quaternion test11(0, std::sin(M_PI*0.25f), 0, std::cos(M_PI*0.25f));
|
etk::Quaternion test11(0, etk::sin(M_PI*0.25f), 0, etk::cos(M_PI*0.25f));
|
||||||
test11.normalize();
|
test11.normalize();
|
||||||
EXPECT_FLOAT_EQ(test1.x(), test11.x());
|
EXPECT_FLOAT_EQ(test1.x(), test11.x());
|
||||||
EXPECT_FLOAT_EQ(test1.y(), test11.y());
|
EXPECT_FLOAT_EQ(test1.y(), test11.y());
|
||||||
@ -70,7 +70,7 @@ TEST(TestQuaternion, constructorEuler) {
|
|||||||
EXPECT_FLOAT_EQ(test1.w(), test11.w());
|
EXPECT_FLOAT_EQ(test1.w(), test11.w());
|
||||||
|
|
||||||
etk::Quaternion test2(vec3(0, 0, M_PI*0.5f));
|
etk::Quaternion test2(vec3(0, 0, M_PI*0.5f));
|
||||||
etk::Quaternion test21(0, 0, std::sin(M_PI*0.25f), std::cos(M_PI*0.25f));
|
etk::Quaternion test21(0, 0, etk::sin(M_PI*0.25f), etk::cos(M_PI*0.25f));
|
||||||
test21.normalize();
|
test21.normalize();
|
||||||
EXPECT_FLOAT_EQ(test2.x(), test21.x());
|
EXPECT_FLOAT_EQ(test2.x(), test21.x());
|
||||||
EXPECT_FLOAT_EQ(test2.y(), test21.y());
|
EXPECT_FLOAT_EQ(test2.y(), test21.y());
|
||||||
|
@ -10,27 +10,27 @@
|
|||||||
#define NAME "Color"
|
#define NAME "Color"
|
||||||
|
|
||||||
TEST(typeTrait, RemoveConstVolatile_1) {
|
TEST(typeTrait, RemoveConstVolatile_1) {
|
||||||
typedef std::remove_cv<const int>::type type1;
|
typedef etk::RemoveConstVolatile<const int>::type type1;
|
||||||
auto ret = etk::IsSame<int, type1>::value;
|
auto ret = etk::IsSame<int, type1>::value;
|
||||||
EXPECT_EQ(ret, true);
|
EXPECT_EQ(ret, true);
|
||||||
}
|
}
|
||||||
TEST(typeTrait, RemoveConstVolatile_2) {
|
TEST(typeTrait, RemoveConstVolatile_2) {
|
||||||
typedef std::remove_cv<volatile int>::type type1;
|
typedef etk::RemoveConstVolatile<volatile int>::type type1;
|
||||||
auto ret = etk::IsSame<int, type1>::value;
|
auto ret = etk::IsSame<int, type1>::value;
|
||||||
EXPECT_EQ(ret, true);
|
EXPECT_EQ(ret, true);
|
||||||
}
|
}
|
||||||
TEST(typeTrait, RemoveConstVolatile_3) {
|
TEST(typeTrait, RemoveConstVolatile_3) {
|
||||||
typedef std::remove_cv<const volatile int>::type type1;
|
typedef etk::RemoveConstVolatile<const volatile int>::type type1;
|
||||||
auto ret = etk::IsSame<int, type1>::value;
|
auto ret = etk::IsSame<int, type1>::value;
|
||||||
EXPECT_EQ(ret, true);
|
EXPECT_EQ(ret, true);
|
||||||
}
|
}
|
||||||
TEST(typeTrait, RemoveConstVolatile_4) {
|
TEST(typeTrait, RemoveConstVolatile_4) {
|
||||||
typedef std::remove_cv<const volatile int*>::type type1;
|
typedef etk::RemoveConstVolatile<const volatile int*>::type type1;
|
||||||
auto ret = etk::IsSame<const volatile int*, type1>::value;
|
auto ret = etk::IsSame<const volatile int*, type1>::value;
|
||||||
EXPECT_EQ(ret, true);
|
EXPECT_EQ(ret, true);
|
||||||
}
|
}
|
||||||
TEST(typeTrait, RemoveConstVolatile_5) {
|
TEST(typeTrait, RemoveConstVolatile_5) {
|
||||||
typedef std::remove_cv<int* const volatile>::type type1;
|
typedef etk::RemoveConstVolatile<int* const volatile>::type type1;
|
||||||
auto ret = etk::IsSame<int*, type1>::value;
|
auto ret = etk::IsSame<int*, type1>::value;
|
||||||
EXPECT_EQ(ret, true);
|
EXPECT_EQ(ret, true);
|
||||||
}
|
}
|
||||||
@ -192,3 +192,26 @@ TEST(typeTrait, IsUnion_4) {
|
|||||||
//etk::EnableIf<has_insertion_operator<etk::Pair<float,float>>::value, uint32_t>::type plop = 55;
|
//etk::EnableIf<has_insertion_operator<etk::Pair<float,float>>::value, uint32_t>::type plop = 55;
|
||||||
etk::EnableIf<has_insertion_operator<int32_t>::value, uint32_t>::type plop = 55;
|
etk::EnableIf<has_insertion_operator<int32_t>::value, uint32_t>::type plop = 55;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static uint32_t contructCount = 0;
|
||||||
|
|
||||||
|
class PlopMove {
|
||||||
|
public:
|
||||||
|
PlopMove() {
|
||||||
|
contructCount ++;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void hello(PlopMove _val) {
|
||||||
|
contructCount += 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(typeMove, move_1) {
|
||||||
|
contructCount = 0;
|
||||||
|
PlopMove value;
|
||||||
|
EXPECT_EQ(contructCount, 1);
|
||||||
|
hello(etk::move(value));
|
||||||
|
EXPECT_EQ(contructCount, 1001);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user