[DOC] nearly finish the basic documentation

This commit is contained in:
Edouard DUPIN 2016-04-03 23:20:37 +02:00
parent dc853d574f
commit 5f287ebdfe
28 changed files with 1455 additions and 938 deletions

View File

@ -15,9 +15,6 @@
#include <sstream> #include <sstream>
#include <stdexcept> #include <stdexcept>
#undef __class__
#define __class__ "Color"
typedef struct { typedef struct {
const char * colorName; const char * colorName;
etk::Color<> color; etk::Color<> color;

View File

@ -20,20 +20,21 @@ namespace etk {
* For example : * For example :
* - Graphic application use: * - Graphic application use:
* - Image in 3/4 bytes for rgb(a) * - Image in 3/4 bytes for rgb(a)
* - Color description in char : '#F6780FFF' or the equivalent number:0xF6780FFF * - Color description in char : '\#F6780FFF' or the equivalent number:0xF6780FFF
* - middleware will mainely use a the 4 separate value with 1 byte for each. * - middleware will mainely use a the 4 separate value with 1 byte for each.
* - graphic interface (openGL) store image in 1/2/3/4 bytes color and interpolate it in 'n' float. And note that the user color is sored in float. * - graphic interface (openGL) store image in 1/2/3/4 bytes color and interpolate it in 'n' float. And note that the user color is sored in float.
* *
* Then with this class we abstract the transformation format and set an easy same way to use the color independing of the developpement level. * Then with this class we abstract the transformation format and set an easy same way to use the color independing of the developpement level.
* *
* Some of the basic color is defined in the namespace: [namespace[etk::color]]. * Some of the basic color is defined in the namespace: @ref etk::color.
* *
* @template-param MY_TYPE Type of the internal template value. The generic value is uint8_t and float * @param[in] MY_TYPE Type of the internal template value. The generic value is uint8_t and float
* @param[in] MY_TYPE_SIZE Number of value in the color
*/ */
template<typename MY_TYPE=uint8_t, int MY_TYPE_SIZE=4> class Color { template<typename MY_TYPE=uint8_t, int MY_TYPE_SIZE=4> class Color {
public: public:
static const Color<MY_TYPE, MY_TYPE_SIZE> emptyColor; // to auto fill with no data in all case static const Color<MY_TYPE, MY_TYPE_SIZE> emptyColor; //!< To auto fill with no data in all case
static const MY_TYPE defaultAlpha; static const MY_TYPE defaultAlpha; //!< Default alpha value
private: private:
MY_TYPE m_element[MY_TYPE_SIZE]; //!< all the color. MY_TYPE m_element[MY_TYPE_SIZE]; //!< all the color.
public: public:
@ -51,15 +52,27 @@ namespace etk {
Color(MY_TYPE _r, MY_TYPE _g, MY_TYPE _b, MY_TYPE _a) { Color(MY_TYPE _r, MY_TYPE _g, MY_TYPE _b, MY_TYPE _a) {
set(_r, _g, _b, _a); set(_r, _g, _b, _a);
}; };
//! @previous /**
* @brief Contructor with request initialisation.
* @param[in] _r Red color.
* @param[in] _g Green color.
* @param[in] _b Blue color.
*/
Color(MY_TYPE _r, MY_TYPE _g, MY_TYPE _b) { Color(MY_TYPE _r, MY_TYPE _g, MY_TYPE _b) {
set(_r, _g, _b); set(_r, _g, _b);
}; };
//! @previous /**
* @brief Contructor with request initialisation.
* @param[in] _r Red color.
* @param[in] _g Green color.
*/
Color(MY_TYPE _r, MY_TYPE _g) { Color(MY_TYPE _r, MY_TYPE _g) {
set(_r, _g); set(_r, _g);
}; };
//! @previous /**
* @brief Contructor with request initialisation.
* @param[in] _r Red color.
*/
Color(MY_TYPE _r) { Color(MY_TYPE _r) {
set(_r); set(_r);
}; };
@ -80,7 +93,7 @@ namespace etk {
* @return reference on this element. * @return reference on this element.
*/ */
Color<MY_TYPE,MY_TYPE_SIZE>& operator=(const etk::Color<MY_TYPE,MY_TYPE_SIZE>& _input) { Color<MY_TYPE,MY_TYPE_SIZE>& operator=(const etk::Color<MY_TYPE,MY_TYPE_SIZE>& _input) {
for (size_t iii=0; iii<MY_TYPE_SIZE; ++iii) { for (size_t iii=0; iii<MY_TYPE_SIZE;iii) {
m_element[iii] = _input.m_element[iii]; m_element[iii] = _input.m_element[iii];
} }
return *this; return *this;
@ -92,7 +105,7 @@ namespace etk {
* @return false This is the same color. * @return false This is the same color.
*/ */
bool operator!= (const etk::Color<MY_TYPE,MY_TYPE_SIZE>& _obj) const { bool operator!= (const etk::Color<MY_TYPE,MY_TYPE_SIZE>& _obj) const {
for (size_t iii=0; iii<MY_TYPE_SIZE; ++iii) { for (size_t iii=0; iii<MY_TYPE_SIZE;iii) {
if(m_element[iii] != _obj.m_element[iii]) { if(m_element[iii] != _obj.m_element[iii]) {
return true; return true;
} }
@ -106,7 +119,7 @@ namespace etk {
* @return false The color are different. * @return false The color are different.
*/ */
bool operator== (const etk::Color<MY_TYPE,MY_TYPE_SIZE>& _obj) const { bool operator== (const etk::Color<MY_TYPE,MY_TYPE_SIZE>& _obj) const {
for (size_t iii=0; iii<MY_TYPE_SIZE; ++iii) { for (size_t iii=0; iii<MY_TYPE_SIZE;iii) {
if(m_element[iii] != _obj.m_element[iii]) { if(m_element[iii] != _obj.m_element[iii]) {
return false; return false;
} }
@ -114,7 +127,7 @@ namespace etk {
return true; return true;
} }
/** /**
* @breif Get the Generic uint32_t value of the color * @brief Get the Generic uint32_t value of the color
* @return Color in unsigned integer * @return Color in unsigned integer
*/ */
uint32_t get() const; uint32_t get() const;
@ -139,7 +152,12 @@ namespace etk {
m_element[3] = _a; m_element[3] = _a;
} }
}; };
//! @previous /**
* @brief Set the specified color elements.
* @param[in] _r Red color.
* @param[in] _g Green color.
* @param[in] _b Blue color.
*/
void set(MY_TYPE _r, MY_TYPE _g, MY_TYPE _b) { void set(MY_TYPE _r, MY_TYPE _g, MY_TYPE _b) {
if (MY_TYPE_SIZE >= 1) { if (MY_TYPE_SIZE >= 1) {
m_element[0] = _r; m_element[0] = _r;
@ -154,7 +172,11 @@ namespace etk {
m_element[3] = defaultAlpha; m_element[3] = defaultAlpha;
} }
}; };
//! @previous /**
* @brief Set the specified color elements.
* @param[in] _r Red color.
* @param[in] _g Green color.
*/
void set(MY_TYPE _r, MY_TYPE _g) { void set(MY_TYPE _r, MY_TYPE _g) {
if (MY_TYPE_SIZE >= 1) { if (MY_TYPE_SIZE >= 1) {
m_element[0] = _r; m_element[0] = _r;
@ -169,7 +191,10 @@ namespace etk {
m_element[3] = defaultAlpha; m_element[3] = defaultAlpha;
} }
}; };
//! @previous /**
* @brief Set the specified color elements.
* @param[in] _r Red color.
*/
void set(MY_TYPE _r) { void set(MY_TYPE _r) {
if (MY_TYPE_SIZE >= 1) { if (MY_TYPE_SIZE >= 1) {
m_element[0] = _r; m_element[0] = _r;
@ -282,9 +307,11 @@ namespace etk {
m_element[3] = MY_TYPE(_a); m_element[3] = MY_TYPE(_a);
} }
}; };
/* **************************************************** /**
* += operator * @brief Operator+= Addition an other etk::color with this one
*****************************************************/ * @param[in] _obj Reference on the external object
* @return Local reference of the vector additionned
*/
const etk::Color<MY_TYPE,MY_TYPE_SIZE>& operator+= (const etk::Color<MY_TYPE,MY_TYPE_SIZE>& _obj) { const etk::Color<MY_TYPE,MY_TYPE_SIZE>& operator+= (const etk::Color<MY_TYPE,MY_TYPE_SIZE>& _obj) {
if (MY_TYPE_SIZE >= 1) { if (MY_TYPE_SIZE >= 1) {
m_element[0] += _obj.m_element[0]; m_element[0] += _obj.m_element[0];
@ -300,18 +327,22 @@ namespace etk {
} }
return *this; return *this;
} }
/* **************************************************** /**
* + operator * @brief Operator+ Addition an other etk::color with this one
*****************************************************/ * @param[in] _obj Reference on the external object
* @return New vector containing the value
*/
etk::Color<MY_TYPE,MY_TYPE_SIZE> operator+ (const etk::Color<MY_TYPE,MY_TYPE_SIZE>& _obj) const { etk::Color<MY_TYPE,MY_TYPE_SIZE> operator+ (const etk::Color<MY_TYPE,MY_TYPE_SIZE>& _obj) const {
etk::Color<MY_TYPE,MY_TYPE_SIZE> tmpp(*this); etk::Color<MY_TYPE,MY_TYPE_SIZE> tmpp(*this);
tmpp += _obj; tmpp += _obj;
return tmpp; return tmpp;
} }
/* **************************************************** /**
* *= operator * @brief Operator*= Multiply 2 color together
*****************************************************/ * @param[in] _obj Reference on the external object
const etk::Color<MY_TYPE,MY_TYPE_SIZE>& operator*= (const etk::Color<MY_TYPE,MY_TYPE_SIZE>& _obj) { * @return Local reference of the vector
*/
etk::Color<MY_TYPE,MY_TYPE_SIZE>& operator*= (const etk::Color<MY_TYPE,MY_TYPE_SIZE>& _obj) {
if (MY_TYPE_SIZE >= 1) { if (MY_TYPE_SIZE >= 1) {
m_element[0] *= _obj.m_element[0]; m_element[0] *= _obj.m_element[0];
} }
@ -326,7 +357,12 @@ namespace etk {
} }
return *this; return *this;
} }
const etk::Color<MY_TYPE,MY_TYPE_SIZE>& operator*= (const MY_TYPE _val) { /**
* @brief Operator*= Multiply the color With a specific value
* @param[in] _val Value to multiply the color
* @return Local reference of the vector
*/
etk::Color<MY_TYPE,MY_TYPE_SIZE>& operator*= (const MY_TYPE _val) {
if (MY_TYPE_SIZE >= 1) { if (MY_TYPE_SIZE >= 1) {
m_element[0] *= _val; m_element[0] *= _val;
} }
@ -341,28 +377,72 @@ namespace etk {
} }
return *this; return *this;
} }
/* **************************************************** /**
* * operator * @brief Operator*= Multiply 2 color together
*****************************************************/ * @param[in] _obj Reference on the external object
* @return New vector containing the value
*/
etk::Color<MY_TYPE,MY_TYPE_SIZE> operator* (const etk::Color<MY_TYPE,MY_TYPE_SIZE>& _obj) const { etk::Color<MY_TYPE,MY_TYPE_SIZE> operator* (const etk::Color<MY_TYPE,MY_TYPE_SIZE>& _obj) const {
etk::Color<MY_TYPE,MY_TYPE_SIZE> tmpp(*this); etk::Color<MY_TYPE,MY_TYPE_SIZE> tmpp(*this);
tmpp *= _obj; tmpp *= _obj;
return tmpp; return tmpp;
} }
/**
* @brief Operator*= Multiply the color With a specific value
* @param[in] _val Value to multiply the color
* @return New vector containing the value
*/
etk::Color<MY_TYPE,MY_TYPE_SIZE> operator* (const MY_TYPE _val) const { etk::Color<MY_TYPE,MY_TYPE_SIZE> operator* (const MY_TYPE _val) const {
etk::Color<MY_TYPE,MY_TYPE_SIZE> tmpp(*this); etk::Color<MY_TYPE,MY_TYPE_SIZE> tmpp(*this);
tmpp *= _val; tmpp *= _val;
return tmpp; return tmpp;
} }
}; };
/**
* @brief Get a color value started with a "#"
* @param[in] _input String to parse
* @return Value parsed
*/
etk::Color<uint8_t, 4> parseStringStartWithSharp(const std::string& _input); etk::Color<uint8_t, 4> parseStringStartWithSharp(const std::string& _input);
/**
* @brief Get a color value started with a "rgb()" converted in uint8
* @param[in] _input String to parse
* @return Value parsed
*/
etk::Color<uint8_t, 4> parseStringStartWithRGBGen(const std::string& _input); etk::Color<uint8_t, 4> parseStringStartWithRGBGen(const std::string& _input);
/**
* @brief Get a color value started with a "rgb()" keep in double
* @param[in] _input String to parse
* @return Value parsed
*/
etk::Color<double, 4> parseStringStartWithRGB(const std::string& _input); etk::Color<double, 4> parseStringStartWithRGB(const std::string& _input);
/**
* @brief Get a color value started with a "rgb()" converted in uint32
* @param[in] _input String to parse
* @return Value parsed
*/
etk::Color<uint32_t, 4> parseStringStartWithRGBUnsigned32(const std::string& _input); etk::Color<uint32_t, 4> parseStringStartWithRGBUnsigned32(const std::string& _input);
/**
* @brief Get a color value started with a "rgb()" converted in uint16
* @param[in] _input String to parse
* @return Value parsed
*/
etk::Color<uint16_t, 4> parseStringStartWithRGBUnsigned16(const std::string& _input); etk::Color<uint16_t, 4> parseStringStartWithRGBUnsigned16(const std::string& _input);
/**
* @brief Get a color value started with a "rgb()" converted in uint6
* @param[in] _input String to parse
* @return Value parsed
*/
etk::Color<uint8_t, 4> parseStringStartWithRGBUnsigned8(const std::string& _input); etk::Color<uint8_t, 4> parseStringStartWithRGBUnsigned8(const std::string& _input);
/**
* @brief Get a color value started with a "named" converted in uint8 like red, geen ...
* @param[in] _input String to parse
* @return Value parsed
*/
etk::Color<uint8_t, 4> parseStringColorNamed(const std::string& _input); etk::Color<uint8_t, 4> parseStringColorNamed(const std::string& _input);
//! @not_in_doc
template<> uint32_t Color<uint8_t, 4>::get() const; template<> uint32_t Color<uint8_t, 4>::get() const;
template<typename MY_TYPE, int MY_TYPE_SIZE> uint32_t Color<MY_TYPE, MY_TYPE_SIZE>::get() const { template<typename MY_TYPE, int MY_TYPE_SIZE> uint32_t Color<MY_TYPE, MY_TYPE_SIZE>::get() const {
@ -565,7 +645,7 @@ namespace etk {
} }
//! @not_in_doc //! @not_in_doc
template<typename MY_TYPE, int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const std::vector<Color<MY_TYPE, MY_TYPE_SIZE> >& _obj) { template<typename MY_TYPE, int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const std::vector<Color<MY_TYPE, MY_TYPE_SIZE> >& _obj) {
for (size_t iii = 0; iii < _obj.size(); ++iii) { for (size_t iii = 0; iii < _obj.size();iii) {
if (iii != 0) { if (iii != 0) {
_os << " "; _os << " ";
} }
@ -579,153 +659,153 @@ namespace etk {
*/ */
namespace color { namespace color {
extern const Color<> none; //!< No color (alpha = 0) extern const Color<> none; //!< No color (alpha = 0)
extern const Color<> aliceBlue; //!< ++ [color=aliceBlue] aliceBlue color [/color] ++ extern const Color<> aliceBlue; //!< - <span class="color:aliceBlue"> aliceBlue color </span>
extern const Color<> antiqueWhite; //!< ++ [color=antiqueWhite] antiqueWhite color [/color] ++ extern const Color<> antiqueWhite; //!< - <span class="color:antiqueWhite"> antiqueWhite color </span>
extern const Color<> aqua; //!< ++ [color=aqua] aqua color [/color] ++ extern const Color<> aqua; //!< - <span class="color:aqua"> aqua color </span>
extern const Color<> aquamarine; //!< ++ [color=aquamarine] aquamarine color [/color] ++ extern const Color<> aquamarine; //!< - <span class="color:aquamarine"> aquamarine color </span>
extern const Color<> azure; //!< ++ [color=azure] azure color [/color] ++ extern const Color<> azure; //!< - <span class="color:azure"> azure color </span>
extern const Color<> beige; //!< ++ [color=beige] beige color [/color] ++ extern const Color<> beige; //!< - <span class="color:beige"> beige color </span>
extern const Color<> bisque; //!< ++ [color=bisque] bisque color [/color] ++ extern const Color<> bisque; //!< - <span class="color:bisque"> bisque color </span>
extern const Color<> black; //!< ++ [color=black] black color [/color] ++ extern const Color<> black; //!< - <span class="color:black"> black color </span>
extern const Color<> blanchedAlmond; //!< ++ [color=blanchedAlmond] blanchedAlmond color [/color] ++ extern const Color<> blanchedAlmond; //!< - <span class="color:blanchedAlmond"> blanchedAlmond color </span>
extern const Color<> blue; //!< ++ [color=blue] blue color [/color] ++ extern const Color<> blue; //!< - <span class="color:blue"> blue color </span>
extern const Color<> blueViolet; //!< ++ [color=blueViolet] blueViolet color [/color] ++ extern const Color<> blueViolet; //!< - <span class="color:blueViolet"> blueViolet color </span>
extern const Color<> brown; //!< ++ [color=brown] brown color [/color] ++ extern const Color<> brown; //!< - <span class="color:brown"> brown color </span>
extern const Color<> burlyWood; //!< ++ [color=burlyWood] burlyWood color [/color] ++ extern const Color<> burlyWood; //!< - <span class="color:burlyWood"> burlyWood color </span>
extern const Color<> cadetBlue; //!< ++ [color=cadetBlue] cadetBlue color [/color] ++ extern const Color<> cadetBlue; //!< - <span class="color:cadetBlue"> cadetBlue color </span>
extern const Color<> chartreuse; //!< ++ [color=chartreuse] chartreuse color [/color] ++ extern const Color<> chartreuse; //!< - <span class="color:chartreuse"> chartreuse color </span>
extern const Color<> chocolate; //!< ++ [color=chocolate] chocolate color [/color] ++ extern const Color<> chocolate; //!< - <span class="color:chocolate"> chocolate color </span>
extern const Color<> coral; //!< ++ [color=coral] coral color [/color] ++ extern const Color<> coral; //!< - <span class="color:coral"> coral color </span>
extern const Color<> cornflowerBlue; //!< ++ [color=cornflowerBlue] cornflowerBlue color [/color] ++ extern const Color<> cornflowerBlue; //!< - <span class="color:cornflowerBlue"> cornflowerBlue color </span>
extern const Color<> cornsilk; //!< ++ [color=cornsilk] cornsilk color [/color] ++ extern const Color<> cornsilk; //!< - <span class="color:cornsilk"> cornsilk color </span>
extern const Color<> crimson; //!< ++ [color=crimson] crimson color [/color] ++ extern const Color<> crimson; //!< - <span class="color:crimson"> crimson color </span>
extern const Color<> cyan; //!< ++ [color=cyan] cyan color [/color] ++ extern const Color<> cyan; //!< - <span class="color:cyan"> cyan color </span>
extern const Color<> darkBlue; //!< ++ [color=darkBlue] darkBlue color [/color] ++ extern const Color<> darkBlue; //!< - <span class="color:darkBlue"> darkBlue color </span>
extern const Color<> darkCyan; //!< ++ [color=darkCyan] darkCyan color [/color] ++ extern const Color<> darkCyan; //!< - <span class="color:darkCyan"> darkCyan color </span>
extern const Color<> darkGoldenRod; //!< ++ [color=darkGoldenRod] darkGoldenRod color [/color] ++ extern const Color<> darkGoldenRod; //!< - <span class="color:darkGoldenRod"> darkGoldenRod color </span>
extern const Color<> darkGray; //!< ++ [color=darkGray] darkGray color [/color] ++ extern const Color<> darkGray; //!< - <span class="color:darkGray"> darkGray color </span>
extern const Color<> darkGrey; //!< ++ [color=darkGrey] darkGrey color [/color] ++ extern const Color<> darkGrey; //!< - <span class="color:darkGrey"> darkGrey color </span>
extern const Color<> darkGreen; //!< ++ [color=darkGreen] darkGreen color [/color] ++ extern const Color<> darkGreen; //!< - <span class="color:darkGreen"> darkGreen color </span>
extern const Color<> darkKhaki; //!< ++ [color=darkKhaki] darkKhaki color [/color] ++ extern const Color<> darkKhaki; //!< - <span class="color:darkKhaki"> darkKhaki color </span>
extern const Color<> darkMagenta; //!< ++ [color=darkMagenta] darkMagenta color [/color] ++ extern const Color<> darkMagenta; //!< - <span class="color:darkMagenta"> darkMagenta color </span>
extern const Color<> darkOliveGreen; //!< ++ [color=darkOliveGreen] darkOliveGreen color [/color] ++ extern const Color<> darkOliveGreen; //!< - <span class="color:darkOliveGreen"> darkOliveGreen color </span>
extern const Color<> darkorange; //!< ++ [color=darkorange] darkorange color [/color] ++ extern const Color<> darkorange; //!< - <span class="color:darkorange"> darkorange color </span>
extern const Color<> darkOrchid; //!< ++ [color=darkOrchid] darkOrchid color [/color] ++ extern const Color<> darkOrchid; //!< - <span class="color:darkOrchid"> darkOrchid color </span>
extern const Color<> darkRed; //!< ++ [color=darkRed] darkRed color [/color] ++ extern const Color<> darkRed; //!< - <span class="color:darkRed"> darkRed color </span>
extern const Color<> darkSalmon; //!< ++ [color=darkSalmon] darkSalmon color [/color] ++ extern const Color<> darkSalmon; //!< - <span class="color:darkSalmon"> darkSalmon color </span>
extern const Color<> darkSeaGreen; //!< ++ [color=darkSeaGreen] darkSeaGreen color [/color] ++ extern const Color<> darkSeaGreen; //!< - <span class="color:darkSeaGreen"> darkSeaGreen color </span>
extern const Color<> darkSlateBlue; //!< ++ [color=darkSlateBlue] darkSlateBlue color [/color] ++ extern const Color<> darkSlateBlue; //!< - <span class="color:darkSlateBlue"> darkSlateBlue color </span>
extern const Color<> darkSlateGray; //!< ++ [color=darkSlateGray] darkSlateGray color [/color] ++ extern const Color<> darkSlateGray; //!< - <span class="color:darkSlateGray"> darkSlateGray color </span>
extern const Color<> darkSlateGrey; //!< ++ [color=darkSlateGrey] darkSlateGrey color [/color] ++ extern const Color<> darkSlateGrey; //!< - <span class="color:darkSlateGrey"> darkSlateGrey color </span>
extern const Color<> darkTurquoise; //!< ++ [color=darkTurquoise] darkTurquoise color [/color] ++ extern const Color<> darkTurquoise; //!< - <span class="color:darkTurquoise"> darkTurquoise color </span>
extern const Color<> darkViolet; //!< ++ [color=darkViolet] darkViolet color [/color] ++ extern const Color<> darkViolet; //!< - <span class="color:darkViolet"> darkViolet color </span>
extern const Color<> deepPink; //!< ++ [color=deepPink] deepPink color [/color] ++ extern const Color<> deepPink; //!< - <span class="color:deepPink"> deepPink color </span>
extern const Color<> deepSkyBlue; //!< ++ [color=deepSkyBlue] deepSkyBlue color [/color] ++ extern const Color<> deepSkyBlue; //!< - <span class="color:deepSkyBlue"> deepSkyBlue color </span>
extern const Color<> dimGray; //!< ++ [color=dimGray] dimGray color [/color] ++ extern const Color<> dimGray; //!< - <span class="color:dimGray"> dimGray color </span>
extern const Color<> dimGrey; //!< ++ [color=dimGrey] dimGrey color [/color] ++ extern const Color<> dimGrey; //!< - <span class="color:dimGrey"> dimGrey color </span>
extern const Color<> dodgerBlue; //!< ++ [color=dodgerBlue] dodgerBlue color [/color] ++ extern const Color<> dodgerBlue; //!< - <span class="color:dodgerBlue"> dodgerBlue color </span>
extern const Color<> fireBrick; //!< ++ [color=fireBrick] fireBrick color [/color] ++ extern const Color<> fireBrick; //!< - <span class="color:fireBrick"> fireBrick color </span>
extern const Color<> floralWhite; //!< ++ [color=floralWhite] floralWhite color [/color] ++ extern const Color<> floralWhite; //!< - <span class="color:floralWhite"> floralWhite color </span>
extern const Color<> forestGreen; //!< ++ [color=forestGreen] forestGreen color [/color] ++ extern const Color<> forestGreen; //!< - <span class="color:forestGreen"> forestGreen color </span>
extern const Color<> fuchsia; //!< ++ [color=fuchsia] fuchsia color [/color] ++ extern const Color<> fuchsia; //!< - <span class="color:fuchsia"> fuchsia color </span>
extern const Color<> gainsboro; //!< ++ [color=gainsboro] gainsboro color [/color] ++ extern const Color<> gainsboro; //!< - <span class="color:gainsboro"> gainsboro color </span>
extern const Color<> ghostWhite; //!< ++ [color=ghostWhite] ghostWhite color [/color] ++ extern const Color<> ghostWhite; //!< - <span class="color:ghostWhite"> ghostWhite color </span>
extern const Color<> gold; //!< ++ [color=gold] gold color [/color] ++ extern const Color<> gold; //!< - <span class="color:gold"> gold color </span>
extern const Color<> goldenRod; //!< ++ [color=goldenRod] goldenRod color [/color] ++ extern const Color<> goldenRod; //!< - <span class="color:goldenRod"> goldenRod color </span>
extern const Color<> gray; //!< ++ [color=gray] gray color [/color] ++ extern const Color<> gray; //!< - <span class="color:gray"> gray color </span>
extern const Color<> grey; //!< ++ [color=grey] grey color [/color] ++ extern const Color<> grey; //!< - <span class="color:grey"> grey color </span>
extern const Color<> green; //!< ++ [color=green] green color [/color] ++ extern const Color<> green; //!< - <span class="color:green"> green color </span>
extern const Color<> greenYellow; //!< ++ [color=greenYellow] greenYellow color [/color] ++ extern const Color<> greenYellow; //!< - <span class="color:greenYellow"> greenYellow color </span>
extern const Color<> honeyDew; //!< ++ [color=honeyDew] honeyDew color [/color] ++ extern const Color<> honeyDew; //!< - <span class="color:honeyDew"> honeyDew color </span>
extern const Color<> hotPink; //!< ++ [color=hotPink] hotPink color [/color] ++ extern const Color<> hotPink; //!< - <span class="color:hotPink"> hotPink color </span>
extern const Color<> indianRed; //!< ++ [color=indianRed] indianRed color [/color] ++ extern const Color<> indianRed; //!< - <span class="color:indianRed"> indianRed color </span>
extern const Color<> indigo; //!< ++ [color=indigo] indigo color [/color] ++ extern const Color<> indigo; //!< - <span class="color:indigo"> indigo color </span>
extern const Color<> ivory; //!< ++ [color=ivory] ivory color [/color] ++ extern const Color<> ivory; //!< - <span class="color:ivory"> ivory color </span>
extern const Color<> khaki; //!< ++ [color=khaki] khaki color [/color] ++ extern const Color<> khaki; //!< - <span class="color:khaki"> khaki color </span>
extern const Color<> lavender; //!< ++ [color=lavender] lavender color [/color] ++ extern const Color<> lavender; //!< - <span class="color:lavender"> lavender color </span>
extern const Color<> lavenderBlush; //!< ++ [color=lavenderBlush] lavenderBlush color [/color] ++ extern const Color<> lavenderBlush; //!< - <span class="color:lavenderBlush"> lavenderBlush color </span>
extern const Color<> lawnGreen; //!< ++ [color=lawnGreen] lawnGreen color [/color] ++ extern const Color<> lawnGreen; //!< - <span class="color:lawnGreen"> lawnGreen color </span>
extern const Color<> lemonChiffon; //!< ++ [color=lemonChiffon] lemonChiffon color [/color] ++ extern const Color<> lemonChiffon; //!< - <span class="color:lemonChiffon"> lemonChiffon color </span>
extern const Color<> lightBlue; //!< ++ [color=lightBlue] lightBlue color [/color] ++ extern const Color<> lightBlue; //!< - <span class="color:lightBlue"> lightBlue color </span>
extern const Color<> lightCoral; //!< ++ [color=lightCoral] lightCoral color [/color] ++ extern const Color<> lightCoral; //!< - <span class="color:lightCoral"> lightCoral color </span>
extern const Color<> lightCyan; //!< ++ [color=lightCyan] lightCyan color [/color] ++ extern const Color<> lightCyan; //!< - <span class="color:lightCyan"> lightCyan color </span>
extern const Color<> lightGoldenRodYellow; //!< ++ [color=lightGoldenRodYellow] lightGoldenRodYellow color [/color] ++ extern const Color<> lightGoldenRodYellow; //!< - <span class="color:lightGoldenRodYellow"> lightGoldenRodYellow color </span>
extern const Color<> lightGray; //!< ++ [color=lightGray] lightGray color [/color] ++ extern const Color<> lightGray; //!< - <span class="color:lightGray"> lightGray color </span>
extern const Color<> lightGrey; //!< ++ [color=lightGrey] lightGrey color [/color] ++ extern const Color<> lightGrey; //!< - <span class="color:lightGrey"> lightGrey color </span>
extern const Color<> lightGreen; //!< ++ [color=lightGreen] lightGreen color [/color] ++ extern const Color<> lightGreen; //!< - <span class="color:lightGreen"> lightGreen color </span>
extern const Color<> lightPink; //!< ++ [color=lightPink] lightPink color [/color] ++ extern const Color<> lightPink; //!< - <span class="color:lightPink"> lightPink color </span>
extern const Color<> lightSalmon; //!< ++ [color=lightSalmon] lightSalmon color [/color] ++ extern const Color<> lightSalmon; //!< - <span class="color:lightSalmon"> lightSalmon color </span>
extern const Color<> lightSeaGreen; //!< ++ [color=lightSeaGreen] lightSeaGreen color [/color] ++ extern const Color<> lightSeaGreen; //!< - <span class="color:lightSeaGreen"> lightSeaGreen color </span>
extern const Color<> lightSkyBlue; //!< ++ [color=lightSkyBlue] lightSkyBlue color [/color] ++ extern const Color<> lightSkyBlue; //!< - <span class="color:lightSkyBlue"> lightSkyBlue color </span>
extern const Color<> lightSlateGray; //!< ++ [color=lightSlateGray] lightSlateGray color [/color] ++ extern const Color<> lightSlateGray; //!< - <span class="color:lightSlateGray"> lightSlateGray color </span>
extern const Color<> lightSlateGrey; //!< ++ [color=lightSlateGrey] lightSlateGrey color [/color] ++ extern const Color<> lightSlateGrey; //!< - <span class="color:lightSlateGrey"> lightSlateGrey color </span>
extern const Color<> lightSteelBlue; //!< ++ [color=lightSteelBlue] lightSteelBlue color [/color] ++ extern const Color<> lightSteelBlue; //!< - <span class="color:lightSteelBlue"> lightSteelBlue color </span>
extern const Color<> lightYellow; //!< ++ [color=lightYellow] lightYellow color [/color] ++ extern const Color<> lightYellow; //!< - <span class="color:lightYellow"> lightYellow color </span>
extern const Color<> lime; //!< ++ [color=lime] lime color [/color] ++ extern const Color<> lime; //!< - <span class="color:lime"> lime color </span>
extern const Color<> limeGreen; //!< ++ [color=limeGreen] limeGreen color [/color] ++ extern const Color<> limeGreen; //!< - <span class="color:limeGreen"> limeGreen color </span>
extern const Color<> linen; //!< ++ [color=linen] linen color [/color] ++ extern const Color<> linen; //!< - <span class="color:linen"> linen color </span>
extern const Color<> magenta; //!< ++ [color=magenta] magenta color [/color] ++ extern const Color<> magenta; //!< - <span class="color:magenta"> magenta color </span>
extern const Color<> maroon; //!< ++ [color=maroon] maroon color [/color] ++ extern const Color<> maroon; //!< - <span class="color:maroon"> maroon color </span>
extern const Color<> mediumAquaMarine; //!< ++ [color=mediumAquaMarine] mediumAquaMarine color [/color] ++ extern const Color<> mediumAquaMarine; //!< - <span class="color:mediumAquaMarine"> mediumAquaMarine color </span>
extern const Color<> mediumBlue; //!< ++ [color=mediumBlue] mediumBlue color [/color] ++ extern const Color<> mediumBlue; //!< - <span class="color:mediumBlue"> mediumBlue color </span>
extern const Color<> mediumOrchid; //!< ++ [color=mediumOrchid] mediumOrchid color [/color] ++ extern const Color<> mediumOrchid; //!< - <span class="color:mediumOrchid"> mediumOrchid color </span>
extern const Color<> mediumPurple; //!< ++ [color=mediumPurple] mediumPurple color [/color] ++ extern const Color<> mediumPurple; //!< - <span class="color:mediumPurple"> mediumPurple color </span>
extern const Color<> mediumSeaGreen; //!< ++ [color=mediumSeaGreen] mediumSeaGreen color [/color] ++ extern const Color<> mediumSeaGreen; //!< - <span class="color:mediumSeaGreen"> mediumSeaGreen color </span>
extern const Color<> mediumSlateBlue; //!< ++ [color=mediumSlateBlue] mediumSlateBlue color [/color] ++ extern const Color<> mediumSlateBlue; //!< - <span class="color:mediumSlateBlue"> mediumSlateBlue color </span>
extern const Color<> mediumSpringGreen; //!< ++ [color=mediumSpringGreen] mediumSpringGreen color [/color] ++ extern const Color<> mediumSpringGreen; //!< - <span class="color:mediumSpringGreen"> mediumSpringGreen color </span>
extern const Color<> mediumTurquoise; //!< ++ [color=mediumTurquoise] mediumTurquoise color [/color] ++ extern const Color<> mediumTurquoise; //!< - <span class="color:mediumTurquoise"> mediumTurquoise color </span>
extern const Color<> mediumVioletRed; //!< ++ [color=mediumVioletRed] mediumVioletRed color [/color] ++ extern const Color<> mediumVioletRed; //!< - <span class="color:mediumVioletRed"> mediumVioletRed color </span>
extern const Color<> midnightBlue; //!< ++ [color=midnightBlue] midnightBlue color [/color] ++ extern const Color<> midnightBlue; //!< - <span class="color:midnightBlue"> midnightBlue color </span>
extern const Color<> mintCream; //!< ++ [color=mintCream] mintCream color [/color] ++ extern const Color<> mintCream; //!< - <span class="color:mintCream"> mintCream color </span>
extern const Color<> mistyRose; //!< ++ [color=mistyRose] mistyRose color [/color] ++ extern const Color<> mistyRose; //!< - <span class="color:mistyRose"> mistyRose color </span>
extern const Color<> moccasin; //!< ++ [color=moccasin] moccasin color [/color] ++ extern const Color<> moccasin; //!< - <span class="color:moccasin"> moccasin color </span>
extern const Color<> navajoWhite; //!< ++ [color=navajoWhite] navajoWhite color [/color] ++ extern const Color<> navajoWhite; //!< - <span class="color:navajoWhite"> navajoWhite color </span>
extern const Color<> navy; //!< ++ [color=navy] navy color [/color] ++ extern const Color<> navy; //!< - <span class="color:navy"> navy color </span>
extern const Color<> oldLace; //!< ++ [color=oldLace] oldLace color [/color] ++ extern const Color<> oldLace; //!< - <span class="color:oldLace"> oldLace color </span>
extern const Color<> olive; //!< ++ [color=olive] olive color [/color] ++ extern const Color<> olive; //!< - <span class="color:olive"> olive color </span>
extern const Color<> oliveDrab; //!< ++ [color=oliveDrab] oliveDrab color [/color] ++ extern const Color<> oliveDrab; //!< - <span class="color:oliveDrab"> oliveDrab color </span>
extern const Color<> orange; //!< ++ [color=orange] orange color [/color] ++ extern const Color<> orange; //!< - <span class="color:orange"> orange color </span>
extern const Color<> orangeRed; //!< ++ [color=orangeRed] orangeRed color [/color] ++ extern const Color<> orangeRed; //!< - <span class="color:orangeRed"> orangeRed color </span>
extern const Color<> orchid; //!< ++ [color=orchid] orchid color [/color] ++ extern const Color<> orchid; //!< - <span class="color:orchid"> orchid color </span>
extern const Color<> paleGoldenRod; //!< ++ [color=paleGoldenRod] paleGoldenRod color [/color] ++ extern const Color<> paleGoldenRod; //!< - <span class="color:paleGoldenRod"> paleGoldenRod color </span>
extern const Color<> paleGreen; //!< ++ [color=paleGreen] paleGreen color [/color] ++ extern const Color<> paleGreen; //!< - <span class="color:paleGreen"> paleGreen color </span>
extern const Color<> paleTurquoise; //!< ++ [color=paleTurquoise] paleTurquoise color [/color] ++ extern const Color<> paleTurquoise; //!< - <span class="color:paleTurquoise"> paleTurquoise color </span>
extern const Color<> paleVioletRed; //!< ++ [color=paleVioletRed] paleVioletRed color [/color] ++ extern const Color<> paleVioletRed; //!< - <span class="color:paleVioletRed"> paleVioletRed color </span>
extern const Color<> papayaWhip; //!< ++ [color=papayaWhip] papayaWhip color [/color] ++ extern const Color<> papayaWhip; //!< - <span class="color:papayaWhip"> papayaWhip color </span>
extern const Color<> peachPuff; //!< ++ [color=peachPuff] peachPuff color [/color] ++ extern const Color<> peachPuff; //!< - <span class="color:peachPuff"> peachPuff color </span>
extern const Color<> peru; //!< ++ [color=peru] peru color [/color] ++ extern const Color<> peru; //!< - <span class="color:peru"> peru color </span>
extern const Color<> pink; //!< ++ [color=pink] pink color [/color] ++ extern const Color<> pink; //!< - <span class="color:pink"> pink color </span>
extern const Color<> plum; //!< ++ [color=plum] plum color [/color] ++ extern const Color<> plum; //!< - <span class="color:plum"> plum color </span>
extern const Color<> powderBlue; //!< ++ [color=powderBlue] powderBlue color [/color] ++ extern const Color<> powderBlue; //!< - <span class="color:powderBlue"> powderBlue color </span>
extern const Color<> purple; //!< ++ [color=purple] purple color [/color] ++ extern const Color<> purple; //!< - <span class="color:purple"> purple color </span>
extern const Color<> red; //!< ++ [color=red] red color [/color] ++ extern const Color<> red; //!< - <span class="color:red"> red color </span>
extern const Color<> rosyBrown; //!< ++ [color=rosyBrown] rosyBrown color [/color] ++ extern const Color<> rosyBrown; //!< - <span class="color:rosyBrown"> rosyBrown color </span>
extern const Color<> royalBlue; //!< ++ [color=royalBlue] royalBlue color [/color] ++ extern const Color<> royalBlue; //!< - <span class="color:royalBlue"> royalBlue color </span>
extern const Color<> saddleBrown; //!< ++ [color=saddleBrown] saddleBrown color [/color] ++ extern const Color<> saddleBrown; //!< - <span class="color:saddleBrown"> saddleBrown color </span>
extern const Color<> salmon; //!< ++ [color=salmon] salmon color [/color] ++ extern const Color<> salmon; //!< - <span class="color:salmon"> salmon color </span>
extern const Color<> sandyBrown; //!< ++ [color=sandyBrown] sandyBrown color [/color] ++ extern const Color<> sandyBrown; //!< - <span class="color:sandyBrown"> sandyBrown color </span>
extern const Color<> seaGreen; //!< ++ [color=seaGreen] seaGreen color [/color] ++ extern const Color<> seaGreen; //!< - <span class="color:seaGreen"> seaGreen color </span>
extern const Color<> seaShell; //!< ++ [color=seaShell] seaShell color [/color] ++ extern const Color<> seaShell; //!< - <span class="color:seaShell"> seaShell color </span>
extern const Color<> sienna; //!< ++ [color=sienna] sienna color [/color] ++ extern const Color<> sienna; //!< - <span class="color:sienna"> sienna color </span>
extern const Color<> silver; //!< ++ [color=silver] silver color [/color] ++ extern const Color<> silver; //!< - <span class="color:silver"> silver color </span>
extern const Color<> skyBlue; //!< ++ [color=skyBlue] skyBlue color [/color] ++ extern const Color<> skyBlue; //!< - <span class="color:skyBlue"> skyBlue color </span>
extern const Color<> slateBlue; //!< ++ [color=slateBlue] slateBlue color [/color] ++ extern const Color<> slateBlue; //!< - <span class="color:slateBlue"> slateBlue color </span>
extern const Color<> slateGray; //!< ++ [color=slateGray] slateGray color [/color] ++ extern const Color<> slateGray; //!< - <span class="color:slateGray"> slateGray color </span>
extern const Color<> slateGrey; //!< ++ [color=slateGrey] slateGrey color [/color] ++ extern const Color<> slateGrey; //!< - <span class="color:slateGrey"> slateGrey color </span>
extern const Color<> snow; //!< ++ [color=snow] snow color [/color] ++ extern const Color<> snow; //!< - <span class="color:snow"> snow color </span>
extern const Color<> springGreen; //!< ++ [color=springGreen] springGreen color [/color] ++ extern const Color<> springGreen; //!< - <span class="color:springGreen"> springGreen color </span>
extern const Color<> steelBlue; //!< ++ [color=steelBlue] steelBlue color [/color] ++ extern const Color<> steelBlue; //!< - <span class="color:steelBlue"> steelBlue color </span>
extern const Color<> tan; //!< ++ [color=tan] tan color [/color] ++ extern const Color<> tan; //!< - <span class="color:tan"> tan color </span>
extern const Color<> teal; //!< ++ [color=teal] teal color [/color] ++ extern const Color<> teal; //!< - <span class="color:teal"> teal color </span>
extern const Color<> thistle; //!< ++ [color=thistle] thistle color [/color] ++ extern const Color<> thistle; //!< - <span class="color:thistle"> thistle color </span>
extern const Color<> tomato; //!< ++ [color=tomato] tomato color [/color] ++ extern const Color<> tomato; //!< - <span class="color:tomato"> tomato color </span>
extern const Color<> turquoise; //!< ++ [color=turquoise] turquoise color [/color] ++ extern const Color<> turquoise; //!< - <span class="color:turquoise"> turquoise color </span>
extern const Color<> violet; //!< ++ [color=violet] violet color [/color] ++ extern const Color<> violet; //!< - <span class="color:violet"> violet color </span>
extern const Color<> wheat; //!< ++ [color=wheat] wheat color [/color] ++ extern const Color<> wheat; //!< - <span class="color:wheat"> wheat color </span>
extern const Color<> white; //!< ++ [color=white] white color [/color] ++ extern const Color<> white; //!< - <span class="color:white"> white color </span>
extern const Color<> whiteSmoke; //!< ++ [color=whiteSmoke] whiteSmoke color [/color] ++ extern const Color<> whiteSmoke; //!< - <span class="color:whiteSmoke"> whiteSmoke color </span>
extern const Color<> yellow; //!< ++ [color=yellow] yellow color [/color] ++ extern const Color<> yellow; //!< - <span class="color:yellow"> yellow color </span>
extern const Color<> yellowGreen; //!< ++ [color=yellowGreen] yellowGreen color [/color] ++ extern const Color<> yellowGreen; //!< - <span class="color:yellowGreen"> yellowGreen color </span>
}; };
}; };

View File

@ -10,10 +10,6 @@
#pragma once #pragma once
#undef __class__
#define __class__ "etk::Hash"
namespace etk { namespace etk {
/** /**
* @brief internel data of the [class[etk::hash]] class, it contain * @brief internel data of the [class[etk::hash]] class, it contain
@ -39,13 +35,17 @@ namespace etk {
* @brief Hash table tamplate is a simple classical hash interface. * @brief Hash table tamplate is a simple classical hash interface.
* A hash table is a equivalent of the dictionary in python, this is a * A hash table is a equivalent of the dictionary in python, this is a
* simple interfaace between a name and a value: * simple interfaace between a name and a value:
* :** "name" : 19 * - "name" : 19
* :** "name 2" : 99 * - "name 2" : 99
* *
* [note]The name is unique and the value is what you want.[/note] * @note The name is unique and the value is what you want
*
* @todo check if something ele exist in the STD. (not the std::map and the std::unordered_map
*
* @note The index are all time availlable since they are created. The order is the the one created
* *
* A simple example of use: * A simple example of use:
* [code style=c++] * @code{.cpp}
* // Create a integer hash table * // Create a integer hash table
* Hash<int> myValue; * Hash<int> myValue;
* // add some element (note add and set is the same function) * // add some element (note add and set is the same function)
@ -59,7 +59,7 @@ namespace etk {
* myValue.remove("plop"); * myValue.remove("plop");
* //Clean all the table: * //Clean all the table:
* myValue.clear(); * myValue.clear();
* [/code] * @endcode
*/ */
template<class MY_TYPE> class Hash { template<class MY_TYPE> class Hash {
private: private:
@ -84,10 +84,10 @@ namespace etk {
* @note It does not delete pointer if your value is a pointer type... * @note It does not delete pointer if your value is a pointer type...
*/ */
void clear() { void clear() {
for (size_t iii = 0; iii < m_data.size(); ++iii) { for (auto &it : m_data) {
if (m_data[iii] != NULL) { if (it != nullptr) {
delete(m_data[iii]); delete(it);
m_data[iii]=NULL; it=nullptr;
} }
} }
m_data.clear(); m_data.clear();
@ -99,7 +99,7 @@ namespace etk {
*/ */
int64_t getId(const std::string& _key) const { int64_t getId(const std::string& _key) const {
for (size_t iii=0; iii<m_data.size(); iii++) { for (size_t iii=0; iii<m_data.size(); iii++) {
if (m_data[iii] != NULL) { if (m_data[iii] != nullptr) {
//TK_INFO("Compare key : '" << m_data[iii]->m_key << "' with '" << _key << "'" ); //TK_INFO("Compare key : '" << m_data[iii]->m_key << "' with '" << _key << "'" );
if (m_data[iii]->m_key == _key) { if (m_data[iii]->m_key == _key) {
return iii; return iii;
@ -111,7 +111,7 @@ namespace etk {
} }
/** /**
* @brief Check if an element exist or not * @brief Check if an element exist or not
* @param[in] _key Name of the hash requested * @param[in] _name Name of the hash requested
* @return true if the element exist * @return true if the element exist
*/ */
bool exist(const std::string& _name) const { bool exist(const std::string& _name) const {
@ -160,7 +160,7 @@ namespace etk {
int64_t elementId = getId(_key); int64_t elementId = getId(_key);
if (elementId <0) { if (elementId <0) {
HashData<MY_TYPE>* tmp = new HashData<MY_TYPE>(_key, _value); HashData<MY_TYPE>* tmp = new HashData<MY_TYPE>(_key, _value);
if (NULL == tmp) { if (tmp == nullptr) {
//TK_ERROR("allocation error in Hash table : '" << _key << "'"); //TK_ERROR("allocation error in Hash table : '" << _key << "'");
return; return;
} }
@ -170,7 +170,10 @@ namespace etk {
m_data[elementId]->m_value = _value; m_data[elementId]->m_value = _value;
} }
/** /**
* @previous * @brief Set an element value
* @note add and set is the same function.
* @param[in] _key Name of the value to set in the hash table.
* @param[in] _value Value to set in the hash table.
*/ */
void set(const std::string& _key, const MY_TYPE& _value) { void set(const std::string& _key, const MY_TYPE& _value) {
add(_key, _value); add(_key, _value);
@ -186,7 +189,7 @@ namespace etk {
return; return;
} }
delete(m_data[elementId]); delete(m_data[elementId]);
m_data[elementId] = NULL; m_data[elementId] = nullptr;
m_data.erase(m_data.begin()+elementId); m_data.erase(m_data.begin()+elementId);
} }
/** /**
@ -206,7 +209,10 @@ namespace etk {
return getValue(_pos); return getValue(_pos);
} }
/** /**
* @previous * @brief get an element with his id.
* @param[in] _pos Position on the element in the hash table.
* @return requested element at this position.
* @note this is a dangerous use of the hash table. Maybe you will use a simple vector.
*/ */
const MY_TYPE& operator[] (size_t _pos) const { const MY_TYPE& operator[] (size_t _pos) const {
return getValue(_pos); return getValue(_pos);
@ -231,16 +237,16 @@ namespace etk {
*/ */
std::vector<std::string> getKeys() const { std::vector<std::string> getKeys() const {
std::vector<std::string> keys; std::vector<std::string> keys;
for (size_t iii = 0; iii < m_data.size(); ++iii) { for (auto &it : m_data) {
if (m_data[iii] != NULL) { if (it != nullptr) {
keys.push_back(m_data[iii]->m_key); keys.push_back(it->m_key);
} }
} }
return keys; return keys;
} }
/** /**
* @brief Get a value of the hash table at a specific position. * @brief Get a value of the hash table at a specific position.
* @param[in] _posPosition of the element in the hash table. * @param[in] _pos of the element in the hash table.
* @return Value availlable at this position. * @return Value availlable at this position.
*/ */
const MY_TYPE& getValue(size_t _pos) const { const MY_TYPE& getValue(size_t _pos) const {
@ -253,7 +259,7 @@ namespace etk {
return m_data[_pos]->m_value; return m_data[_pos]->m_value;
} }
/** /**
* @previous * @copydoc getValue (size_t)
*/ */
MY_TYPE& getValue(size_t _pos) { MY_TYPE& getValue(size_t _pos) {
// NOTE :Do not change log level, this generate error only in debug mode // NOTE :Do not change log level, this generate error only in debug mode
@ -265,8 +271,5 @@ namespace etk {
return m_data[_pos]->m_value; return m_data[_pos]->m_value;
} }
}; };
}; }
#undef __class__
#define __class__ NULL

View File

@ -17,7 +17,7 @@
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
etk::BaseNoise::BaseNoise(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()),
m_size(_size) { m_size(_size) {
m_data.resize(_size.x()*_size.y(), 0); m_data.resize(_size.x()*_size.y(), 0);

View File

@ -16,18 +16,31 @@ namespace etk {
/** /**
* @brief BaseNoise Noise basic data. * @brief BaseNoise Noise basic data.
* @todo Validate it, this is a !!! PROTOTYPE !!! * @todo Validate it, this is a !!! PROTOTYPE !!!
* @todo Remove this from ETK
*/ */
class BaseNoise { class BaseNoise {
private: private:
std::vector<float> m_data; std::vector<float> m_data; //!< basic interface date
ivec2 m_size; ivec2 m_size; //!< Size of the noise data
public: public:
BaseNoise(ivec2 _size, float _min, float _max); /**
~BaseNoise(); * @brief basic constructor with randon settings
* @param[in] _size Size of the basic noise
* @param[in] _min Minimum value of the random
* @param[in] _max Maximum value of the random
*/
BaseNoise(const ivec2& _size, float _min, float _max);
/**
* @brief Get value at a specific position.
* @param[in] _x X position
* @param[in] _y Y position
* @return random noise value
*/
float get(int32_t _x, int32_t _y) const; float get(int32_t _x, int32_t _y) const;
}; };
/** /**
* @brief List of noise type supported * @brief List of noise type supported
* @todo Remove this from ETK
*/ */
enum noiseType { enum noiseType {
noiseType_base, //!< basic random noise noiseType_base, //!< basic random noise
@ -41,6 +54,7 @@ namespace etk {
/** /**
* @brief Noise basic interface. * @brief Noise basic interface.
* @todo Validate it, this is a !!! PROTOTYPE !!! * @todo Validate it, this is a !!! PROTOTYPE !!!
* @todo Remove this from ETK
*/ */
class Noise { class Noise {
private: private:

View File

@ -12,75 +12,82 @@
#include <vector> #include <vector>
namespace etk { namespace etk {
/**
* @brief 2 dimention matrix template to manage simpliest algo
* @note Prototype
*/
template <typename T> class Matrix { template <typename T> class Matrix {
private: private:
ivec2 m_size; uivec2 m_size; //!< Size of the Matrix
std::vector<T> m_data; std::vector<T> m_data; //!< Data of the matrix
public: public:
/***************************************************** /**
* Constructor * @brief Contructor that create a Vector with a specific size and specific raw data
*****************************************************/ * @param[in] _size Dimention of the matrix
Matrix(ivec2 _size, T* _defaultVal=nullptr) : * @param[in] _defaultVal Default list of element that might be set in the matrix
*/
Matrix(const ivec2& _size, T* _defaultVal=nullptr) :
m_size(_size), m_size(_size),
etk::Vector2D<T>(_size.x.x()* _size.y()) { etk::Vector2D<T>(_size.x()* _size.y()) {
if (defaultVal != nullptr) { if (defaultVal == nullptr) {
clear();
return;
}
// copy all the elements // copy all the elements
for(int32_t iii=0; iii<=m_size.x()*m_size.y(); iii++) { for(size_t iii = 0;
iii <= m_size.x()*m_size.y();
++iii) {
// cast and set value : // cast and set value :
m_data[iii] = T(_defaultVal++); m_data[iii] = T(_defaultVal++);
} }
} else {
Clear();
} }
}; /**
* @brief default contructor that create a Vector with a specific size and specific raw data
* @param[in] _width Dimention width of the matrix
* @param[in] _heigh Dimention heigh of the matrix
* @param[in] _defaultVal Default list of element that might be set in the matrix
*/
Matrix(int32_t _width=0, int32_t _heigh=0, T* _defaultVal=nullptr) : Matrix(int32_t _width=0, int32_t _heigh=0, T* _defaultVal=nullptr) :
m_size(_width, _heigh), m_size(_width, _heigh),
etk::Vector2D<T>(_width*_heigh) { etk::Vector2D<T>(_width*_heigh) {
if (_defaultVal != nullptr) { if (_defaultVal == nullptr) {
clear();
return;
}
// copy all the elements // copy all the elements
for(int32_t iii=0; iii<=m_size.x()*m_size.y(); iii++) { for(size_t iii = 0;
iii <= m_size.x()*m_size.y();
++iii) {
// cast and set value : // cast and set value :
m_data[iii] = (T)_defaultVal++; m_data[iii] = T(_defaultVal++);
} }
} else {
Clear();
} }
}; /**
Matrix(const Matrix<double>& obj) : * @brief Copy contructor with ETK_TYPE_MATRIX_2 type matrix input
* @param[in] _obj Object matrix to copy
*/
template<class ETK_TYPE_MATRIX_2>
Matrix(const Matrix<ETK_TYPE_MATRIX_2>& _obj) :
m_size(_obj.m_size), m_size(_obj.m_size),
etk::Vector2D<T>(_obj.m_size.x()* _obj.m_size.y()) { etk::Vector2D<T>(_obj.m_size.x()* _obj.m_size.y()) {
// copy all the elements // copy all the elements
for(int32_t iii=0; iii<=m_size.x()*m_size.y(); iii++) { for(size_t iii = 0;
iii <= m_size.x()*m_size.y();
++iii) {
// cast and set value : // cast and set value :
m_data[iii] = (T)_obj.m_data[iii]; m_data[iii] = T(_obj.m_data[iii]);
} }
} }
Matrix(const Matrix<float>& _obj) : /**
m_size(_obj.m_size), * @brief Virtualisation of destructor
etk::Vector2D<T>(_obj.m_size.x()* _obj.m_size.y()) { */
// copy all the elements virtual ~Matrix() = default;
for(int32_t iii=0; iii<=m_size.x()*m_size.y(); iii++) {
// cast and set value :
m_data[iii] = (T)_obj.m_data[iii];
}
}
Matrix(const Matrix<int32_t>& _obj) :
m_size(_obj.m_size.x(), _obj.m_size.y()),
etk::Vector2D<T>(_obj.m_size.x()* _obj.m_size.y()) {
// copy all the elements
for (int32_t iii=0; iii<=m_size.x()*m_size.y(); iii++) {
// cast and set value :
m_data[iii] = (T)_obj.m_data[iii];
}
}
/*****************************************************
* Destructor
*****************************************************/
virtual ~Matrix() {};
/***************************************************** /**
* = assigment * @brief Operator= Asign the current object with an other object
*****************************************************/ * @param[in] _obj Reference on the external object
* @return Local reference of the vector asigned
*/
const Matrix<T>& operator= (const Matrix<T>& _obj ) { const Matrix<T>& operator= (const Matrix<T>& _obj ) {
// check if it was the same pointer // check if it was the same pointer
if (this == &_obj ) { if (this == &_obj ) {
@ -90,29 +97,49 @@ namespace etk {
m_size = _obj.m_size; m_size = _obj.m_size;
m_data = _obj.m_data; m_data = _obj.m_data;
return *this; return *this;
}; }
/**
* @brief Operator= Asign the current object with a unique value
* @param[in] _value Value to set in the matrix data
* @return Local reference of the vector asigned
*/
const Matrix<T>& operator= (T& _value) { const Matrix<T>& operator= (T& _value) {
// set data : // set data :
for (int32_t iii=0; iii<m_data.size(); iii++) { for(size_t iii = 0;
iii <= m_size.x()*m_size.y();
++iii) {
m_data = _value; m_data = _value;
} }
return *this; return *this;
}; }
/***************************************************** /**
* == operator * @brief Equality compare operator with an other object.
*****************************************************/ * @param[in] _obj Reference on the comparing object
* @return true The Objects are identical
* @return false The Objects are NOT identical
*/
bool operator== (const Matrix<T>& _obj) const { bool operator== (const Matrix<T>& _obj) const {
return (m_data == _obj.m_data); return (m_data == _obj.m_data);
}; }
/***************************************************** /**
* != operator * @brief In-Equality compare operator with an other object.
*****************************************************/ * @param[in] _obj Reference on the comparing object
* @return true The Objects are NOT identical
* @return false The Objects are identical
*/
bool operator!= (const Matrix<T>& _obj) const { bool operator!= (const Matrix<T>& _obj) const {
return (m_data != _obj.m_data); return (m_data != _obj.m_data);
}; }
/***************************************************** /**
* += operator * @brief Operator+= Addition an other matrix with this one
*****************************************************/ * <pre>
* (a b) (e f) (a+e b+f)
* (c d) + (g h) = (c+g d+h)
* </pre>
* @note If the size are different, we create a matrix witth the max size of the 2 others ...
* @param[in] _obj Reference on the external object
* @return Local reference of the vector additionned
*/
const Matrix<T>& operator+= (const Matrix<T>& _obj) { const Matrix<T>& operator+= (const Matrix<T>& _obj) {
if (m_size != _obj.m_size) { if (m_size != _obj.m_size) {
//TK_CRITICAL("add 2 Matrix with différent size ... ==> generate the max size of all the 2 matrix"); //TK_CRITICAL("add 2 Matrix with différent size ... ==> generate the max size of all the 2 matrix");
@ -135,27 +162,41 @@ namespace etk {
m_size = tmpMatrix.m_size; m_size = tmpMatrix.m_size;
m_data = tmpMatrix.m_data; m_data = tmpMatrix.m_data;
} else { } else {
// copy data for the same size : // copy data for the same size:
for (int32_t iii=0; iii< m_data.size(); iii++) { for (int32_t iii=0; iii< m_data.size(); iii++) {
m_data[iii] += _obj.m_data[iii]; m_data[iii] += _obj.m_data[iii];
} }
} }
return *this; return *this;
}; }
/***************************************************** /**
* + operator * @brief Operator+= Addition an other matrix with this one
*****************************************************/ * <pre>
* (a b) (e f) (a+e b+f)
* (c d) + (g h) = (c+g d+h)
* </pre>
* @note If the size are different, we create a matrix witth the max size of the 2 others ...
* @param[in] _obj Reference on the external object
* @return New matrix containing the value
*/
Matrix<T> operator+ (const Matrix<T>& _obj) { Matrix<T> operator+ (const Matrix<T>& _obj) {
Matrix<T> tmpp(*this); Matrix<T> tmpp(*this);
tmpp += _obj; tmpp += _obj;
return tmpp; return tmpp;
} }
/***************************************************** /**
* -= operator * @brief Operator+= Addition an other matrix with this one
*****************************************************/ * <pre>
* (a b) (e f) (a-e b-f)
* (c d) - (g h) = (c-g d-h)
* </pre>
* @note If the size are different, we create a matrix witth the max size of the 2 others ...
* @param[in] _obj Reference on the external object
* @return Local reference of the vector additionned
*/
const Matrix<T>& operator-= (const Matrix<T>& _obj) { const Matrix<T>& operator-= (const Matrix<T>& _obj) {
if (m_size != _obj.m_size) { if (m_size != _obj.m_size) {
//TK_CRITICAL("less 2 Matrix with différent size ... ==> generate the max size of all the 2 matrix"); //TK_CRITICAL("less 2 Matrix with different size ... ==> generate the max size of all the 2 matrix");
etk::Matrix<T> tmpMatrix(std::max(m_size.x(),_obj.m_size.x()), std::max(m_size.y(),_obj.m_size.y())); etk::Matrix<T> tmpMatrix(std::max(m_size.x(),_obj.m_size.x()), std::max(m_size.y(),_obj.m_size.y()));
for (int32_t jjj=0; jjj< m_size.y; jjj++) { for (int32_t jjj=0; jjj< m_size.y; jjj++) {
T* tmpPointer = tmpMatrix[jjj]; T* tmpPointer = tmpMatrix[jjj];
@ -182,17 +223,26 @@ namespace etk {
} }
return *this; return *this;
}; };
/***************************************************** /**
* - operator * @brief Operator+= Addition an other matrix with this one
*****************************************************/ * <pre>
* (a b) (e f) (a-e b-f)
* (c d) - (g h) = (c-g d-h)
* </pre>
* @note If the size are different, we create a matrix witth the max size of the 2 others ...
* @param[in] _obj Reference on the external object
* @return New matrix containing the value
*/
Matrix<T> operator- (const Matrix<T>& _obj) { Matrix<T> operator- (const Matrix<T>& _obj) {
Matrix<T> tmpp(*this); Matrix<T> tmpp(*this);
tmpp += _obj; tmpp += _obj;
return tmpp; return tmpp;
} }
/***************************************************** /**
* *= operator * @brief Operator*= Multiplication an other matrix with this one
*****************************************************/ * @param[in] _obj Reference on the external object
* @return Local reference of the vector multiplicated
*/
const Matrix<T>& operator*= (const Matrix<T>& _obj) { const Matrix<T>& operator*= (const Matrix<T>& _obj) {
if( m_size.x() != _obj.m_size.y() if( m_size.x() != _obj.m_size.y()
|| m_size.y() != _obj.m_size.x()) { || m_size.y() != _obj.m_size.x()) {
@ -213,46 +263,89 @@ namespace etk {
m_data = tmpMatrix.m_data; m_data = tmpMatrix.m_data;
return *this; return *this;
}; };
/***************************************************** /**
* * operator * @brief Operator* Multiplication an other matrix with this one
*****************************************************/ * @param[in] _obj Reference on the external object
* @return New matrix containing the value
*/
Matrix<T> operator* (const Matrix<T>& _obj) { Matrix<T> operator* (const Matrix<T>& _obj) {
Matrix tmpp(*this); Matrix tmpp(*this);
tmpp *= _obj; tmpp *= _obj;
return tmpp; return tmpp;
} }
/***************************************************** // TODO : Check if is possible to do elemntValue = mayMatrix[xxx, yyy]
* [] operator /**
*****************************************************/ * @brief Operator[] Access at the first element (const pointer) of a line
const T* operator[] (int32_t _line) const { * <pre>
return &m_data[_line*m_size.x()]; * elemntValue = mayMatrix[YYY][xxx];
* </pre>
* @param[in] _yyy Line Id requested [0..m_size.y()]
* @return Const pointer on the first line element
*/
const T* operator[] (int32_t _yyy) const {
return &m_data[_yyy*m_size.x()];
} }
T* operator[] (int32_t _line) { /**
return &m_data[_line*m_size.x()]; * @brief Operator[] Access at the first element (pointer) of a line
* <pre>
* elemntValue = mayMatrix[YYY][xxx];
* </pre>
* @param[in] _yyy Line Id requested [0..m_size.y()]
* @return Pointer on the first line element
*/
T* operator[] (int32_t _yyy) {
return &m_data[_yyy*m_size.x()];
} }
/***************************************************** /**
* () operator * @brief Operator[] Access at the element at a specific position
*****************************************************/ * <pre>
T& operator () (int32_t _line, int32_t _colomn) { * elemntValue = mayMatrix[ivec2(xxx,yyy)];
return m_data[_line*m_size.x() + _colomn]; * </pre>
* @param[in] _pos Position in the matrix
* @return Const Reference on the element
*/
const T& operator[] (const ivec2& _pos) const {
return m_data[_pos.y()*m_size.x() + _pos.x()];
} }
/***************************************************** /**
* - operator * @brief Operator[] Access at the element at a specific position
*****************************************************/ * <pre>
Matrix<T> operator - () { * elemntValue = mayMatrix[ivec2(xxx,yyy)];
* </pre>
* @param[in] _pos Position in the matrix
* @return Reference on the element
*/
T& operator[] (const ivec2& _pos) {
return m_data[_pos.y()*m_size.x() + _pos.x()];
}
/**
* @brief Operator() Access at the element at a specific position
* <pre>
* elemntValue = mayMatrix(xxx,yyy);
* </pre>
* @param[in] _xxx Colomn position in the matrix
* @param[in] _yyy Line position in the matrix
* @return Reference on the element
*/
T& operator () (size_t _xxx, size_t _yyy) {
return m_data[_yyy*m_size.x() + _xxx];
}
/**
* @brief Operator- Multiply with -1
* @return New matrix containing the value
*/
Matrix<T> operator- () const {
Matrix<T> tmp(m_size); Matrix<T> tmp(m_size);
for (int32_t iii=0; iii<m_data.Size(); iii++) { for (int32_t iii=0; iii<m_data.Size(); iii++) {
tmp.m_data[iii] = -m_data[iii]; tmp.m_data[iii] = -m_data[iii];
}
return tmp; return tmp;
} }
/*****************************************************
* Other mathematical function
*****************************************************/
/** /**
* @ brief Transpose Matrix * @brief Transpose Matrix
* @ return the transpose matrix * @return New matrix containing the value
*/ */
Matrix<T> transpose() { Matrix<T> transpose() const {
// create a matrix with the inverted size // create a matrix with the inverted size
Matrix<T> tmpMatrix(m_size); Matrix<T> tmpMatrix(m_size);
for (int32_t jjj=0; jjj< m_size.y(); jjj++) { for (int32_t jjj=0; jjj< m_size.y(); jjj++) {
@ -261,23 +354,23 @@ namespace etk {
} }
} }
return tmpMatrix; return tmpMatrix;
}; }
/** /**
* @ brief Create a convolution on the matrix : set convolution on the lines * @brief Create a convolution on the matrix : set convolution on the lines
* @ param[in] _obj The convolution operator * @param[in] _obj The convolution operator
* @ return the value of the convolution * @return New matrix containing the current matrix concoluate
*/ */
Matrix<T>& convolution(Matrix<T>& _obj) { Matrix<T> convolution(Matrix<T>& _obj) const {
Matrix<T> tmppp(1,1); Matrix<T> tmppp(1,1);
// TODO : ... // TODO : ...
return tmppp; return tmppp;
}; }
/** /**
* @ brief generate a devide of the curent Matrix with the specify power of 2 * @brief generate a devide of the curent Matrix with the specify power of 2
* @ param[in] _decalage The power of 2 of the division * @param[in] _decalage The power of 2 of the division
* @ return the result * @return New matrix containing the matrix fix()
*/ */
Matrix<T>& fix(int32_t _decalage) { Matrix<T> fix(int32_t _decalage) const {
Matrix<T> tmppp(m_size); Matrix<T> tmppp(m_size);
T tmpVal = 0; T tmpVal = 0;
for(int32_t iii=0; iii<m_data.size(); iii++) { for(int32_t iii=0; iii<m_data.size(); iii++) {
@ -293,11 +386,11 @@ namespace etk {
return tmppp; return tmppp;
}; };
/** /**
* @ brief generate a devide of the curent Matrix with the specify power of 2 * @brief generate a devide of the curent Matrix with the specify power of 2
* @ param[in] _decalage The power of 2 of the division * @param[in] _decalage The power of 2 of the division
* @ return the result * @return New matrix containing the rounded matrix
*/ */
Matrix<T>& round(int32_t _decalage) { Matrix<T> round(int32_t _decalage) const {
Matrix<T> tmppp(m_size); Matrix<T> tmppp(m_size);
for(int32_t iii=0; iii<m_data.size(); iii++) { for(int32_t iii=0; iii<m_data.size(); iii++) {
tmppp.m_data[iii] = ( m_data[iii]+(1<<(_decalage-1)) ) >> _decalage; tmppp.m_data[iii] = ( m_data[iii]+(1<<(_decalage-1)) ) >> _decalage;
@ -305,11 +398,11 @@ namespace etk {
return tmppp; return tmppp;
}; };
/** /**
* @ brief Generate a resised matrix * @brief Generate a resised matrix
* @ param[in] _size new output size * @param[in] _size new output size
* @ return Te resied matrix * @return New matrix resized
*/ */
Matrix<T>& resize(etk::Vector2D<int32_t> _size) { Matrix<T> resize(etk::Vector2D<int32_t> _size) const {
Matrix<T> tmppp(_size); Matrix<T> tmppp(_size);
for(int32_t iii=0; iii<m_data.m_size.x() && iii<tmppp.m_size.x(); iii++) { for(int32_t iii=0; iii<m_data.m_size.x() && iii<tmppp.m_size.x(); iii++) {
for(int32_t jjj=0; jjj<m_data.m_size.y() && jjj<tmppp.m_size.y(); jjj++) { for(int32_t jjj=0; jjj<m_data.m_size.y() && jjj<tmppp.m_size.y(); jjj++) {
@ -322,11 +415,11 @@ namespace etk {
* @brief Select element in the matrix from a list of element Ids * @brief Select element in the matrix from a list of element Ids
* @param[in] _np Width of the output matrix * @param[in] _np Width of the output matrix
* @param[in] _p List pointer of x * @param[in] _p List pointer of x
* @param[in] _np Heigh of the output matrix * @param[in] _nq Heigh of the output matrix
* @param[in] _q List pointer of y * @param[in] _q List pointer of y
* @return the new matrix * @return New matrix resized
*/ */
Matrix<T>& select(int32_t _np, int32_t* _p, int32_t _nq, int32_t* _q) { Matrix<T> select(int32_t _np, int32_t* _p, int32_t _nq, int32_t* _q) const {
if (_np < 1 || _nq < 1) { if (_np < 1 || _nq < 1) {
TK_WARNING("bad index array sizes"); TK_WARNING("bad index array sizes");
} }
@ -344,9 +437,6 @@ namespace etk {
} }
return tmppp; return tmppp;
} }
/*****************************************************
* utilities :
*****************************************************/
/** /**
* @brief Clear the Upper triangle of the current Matrix * @brief Clear the Upper triangle of the current Matrix
* <pre> * <pre>
@ -401,7 +491,7 @@ namespace etk {
* @param[in] _input The compared Matix. * @param[in] _input The compared Matix.
* @return The absolute max value. * @return The absolute max value.
*/ */
T maxDifference(const Matrix<T>& _input) { T maxDifference(const Matrix<T>& _input) const {
if (m_size != _input.m_size) { if (m_size != _input.m_size) {
TK_WARNING("better to do with same size Matrix"); TK_WARNING("better to do with same size Matrix");
} }
@ -413,14 +503,21 @@ namespace etk {
if (diff<0) { if (diff<0) {
diff = -diff; diff = -diff;
} }
if (diff > max) if (diff > max) {
max = diff; max = diff;
} }
} }
return max; return max;
}; }
/** /**
* @brief Clear all the matrix. * @brief Clear all the matrix.
* <pre>
* 0 0 0 0 0
* 0 0 0 0 0
* 0 0 0 0 0
* 0 0 0 0 0
* 0 0 0 0 0
* </pre>
*/ */
void clear() { void clear() {
// copy data for the same size : // copy data for the same size :
@ -429,7 +526,13 @@ namespace etk {
} }
}; };
/** /**
* @brief Set the diagonal at 1 * @brief Set the matrix identity
* <pre>
* 1 0 0 0 0
* 0 1 0 0 0
* 0 0 1 0 0
* 0 0 0 1 0
* </pre>
*/ */
void identity() { void identity() {
// copy data for the same size : // copy data for the same size :
@ -448,13 +551,14 @@ namespace etk {
* @brief Get the size of the current Matrix. * @brief Get the size of the current Matrix.
* @return Dimention of the matrix * @return Dimention of the matrix
*/ */
Vector2D<int32_t> size() { const uivec2& size() const {
return m_size; return m_size;
}; };
}; };
} }
// To siplify the writing of the code ==> this is not compatible with GLSL ... // To siplify the writing of the code ==> this is not compatible with GLSL ...
typedef etk::Matrix<float> mat; using dmat = etk::Matrix<double>; //!< Helper to simplify using of matrix
typedef etk::Matrix<int32_t> imat; using mat = etk::Matrix<float>; //!< Helper to simplify using of matrix
typedef etk::Matrix<uint32_t> uimat; using imat = etk::Matrix<int32_t>; //!< Helper to simplify using of matrix
using uimat = etk::Matrix<uint32_t>; //!< Helper to simplify using of matrix

View File

@ -78,10 +78,6 @@ etk::Matrix2::Matrix2(const double* _values) {
m_mat[5] = _values[5]; m_mat[5] = _values[5];
} }
etk::Matrix2::~Matrix2() {
}
const etk::Matrix2& etk::Matrix2::operator= (const etk::Matrix2& _obj ) { const etk::Matrix2& etk::Matrix2::operator= (const etk::Matrix2& _obj ) {
for(int32_t iii=0; iii<2*3 ; ++iii) { for(int32_t iii=0; iii<2*3 ; ++iii) {
m_mat[iii] = _obj.m_mat[iii]; m_mat[iii] = _obj.m_mat[iii];
@ -152,14 +148,14 @@ etk::Matrix2 etk::Matrix2::operator * (const etk::Matrix2& _obj) {
return tmp; return tmp;
} }
vec2 etk::Matrix2::operator * (const vec2& _obj) const { vec2 etk::Matrix2::operator * (const vec2& _point) const {
return vec2(_obj.x()*m_mat[0] + _obj.y()*m_mat[1] + m_mat[2], return vec2(_point.x()*m_mat[0] + _point.y()*m_mat[1] + m_mat[2],
_obj.x()*m_mat[4] + _obj.y()*m_mat[3] + m_mat[5]); _point.x()*m_mat[4] + _point.y()*m_mat[3] + m_mat[5]);
} }
vec2 etk::Matrix2::applyScaleRotation(const vec2& _obj) const { vec2 etk::Matrix2::applyScaleRotation(const vec2& _point) const {
return vec2(_obj.x()*m_mat[0] + _obj.y()*m_mat[1], return vec2(_point.x()*m_mat[0] + _point.y()*m_mat[1],
_obj.x()*m_mat[4] + _obj.y()*m_mat[3]); _point.x()*m_mat[4] + _point.y()*m_mat[3]);
} }
etk::Matrix2 etk::Matrix2::operator ~ () const { etk::Matrix2 etk::Matrix2::operator ~ () const {

View File

@ -11,76 +11,128 @@
#include <etk/math/Vector2D.h> #include <etk/math/Vector2D.h>
#include <etk/types.h> #include <etk/types.h>
namespace etk { namespace etk {
/**
* @brief Transformation matrix for vector 2D.
*/
class Matrix2 { class Matrix2 {
public: private:
/* /**
* @brief Internal data
* sx shx tx * sx shx tx
* sy shy ty * sy shy ty
*/ */
float m_mat[2*3]; float m_mat[2*3];
/**
* @brief Load Identity matrix
*/
void identity();
public: public:
/***************************************************** /**
* Constructor * @brief Constructor that load identity
*****************************************************/ */
Matrix2(); Matrix2();
/**
* @brief Copy constructor.
* @param[in] _obj Matrix object to copy
*/
Matrix2(const Matrix2& _obj); Matrix2(const Matrix2& _obj);
/**
* @brief Configuration constructor.
* @param[in] _sx Scale threw X axis
* @param[in] _shy Rotate in radian threw Y axis
* @param[in] _shx Rotate in radian threw X axis
* @param[in] _sy Scale threw Y axis
* @param[in] _tx Translate threw X axis
* @param[in] _ty translate threw Y axis
*/
Matrix2(float _sx, Matrix2(float _sx,
float _shy, float _shy,
float _shx, float _shx,
float _sy, float _sy,
float _tx, float _tx,
float _ty); float _ty);
/**
* @brief Configuration constructor.
* @param[in] _values vector of values in float
*/
Matrix2(const float* _values); Matrix2(const float* _values);
/**
* @brief Configuration constructor.
* @param[in] _values vector of values in double
*/
Matrix2(const double* _values); Matrix2(const double* _values);
/***************************************************** /**
* Destructor * @brief Load Identity matrix
*****************************************************/ */
~Matrix2(); void identity();
/***************************************************** /**
* = assigment * @brief Operator= Asign the current object with an other object
*****************************************************/ * @param[in] _obj Reference on the external object
* @return Local reference of the vector asigned
*/
const Matrix2& operator= (const Matrix2& _obj ); const Matrix2& operator= (const Matrix2& _obj );
/***************************************************** /**
* == operator * @brief Equality compare operator with an other object.
*****************************************************/ * @param[in] _obj Reference on the comparing object
* @return true The Objects are identical
* @return false The Objects are NOT identical
*/
bool operator== (const Matrix2& _obj) const; bool operator== (const Matrix2& _obj) const;
/***************************************************** /**
* != operator * @brief In-Equality compare operator with an other object.
*****************************************************/ * @param[in] _obj Reference on the comparing object
* @return true The Objects are NOT identical
* @return false The Objects are identical
*/
bool operator!= (const Matrix2& _obj) const; bool operator!= (const Matrix2& _obj) const;
/***************************************************** /**
* += operator * @brief Operator+= Addition an other matrix with this one
*****************************************************/ * @param[in] _obj Reference on the external object
* @return Local reference of the vector additionned
*/
const Matrix2& operator+= (const Matrix2& _obj); const Matrix2& operator+= (const Matrix2& _obj);
/***************************************************** /**
* + operator * @brief Operator+ Addition an other matrix with this one
*****************************************************/ * @param[in] _obj Reference on the external object
* @return New vector containing the value
*/
Matrix2 operator+ (const Matrix2& _obj) const; Matrix2 operator+ (const Matrix2& _obj) const;
/***************************************************** /**
* -= operator * @brief Operator-= Decrement an other matrix with this one
*****************************************************/ * @param[in] _obj Reference on the external object
* @return Local reference of the vector decremented
*/
const Matrix2& operator-= (const Matrix2& _obj); const Matrix2& operator-= (const Matrix2& _obj);
/***************************************************** /**
* - operator * @brief Operator- Decrement an other matrix with this one
*****************************************************/ * @param[in] _obj Reference on the external object
* @return New vector containing the value
*/
Matrix2 operator- (const Matrix2& _obj) const; Matrix2 operator- (const Matrix2& _obj) const;
/***************************************************** /**
* *= operator * @brief Operator*= Multiplication an other matrix with this one
*****************************************************/ * @param[in] _obj Reference on the external object
* @return Local reference of the vector multiplicated
*/
const Matrix2& operator *= (const Matrix2& _obj); const Matrix2& operator *= (const Matrix2& _obj);
/***************************************************** /**
* * operator * @brief Operator* Multiplication an other matrix with this one
*****************************************************/ * @param[in] _obj Reference on the external object
* @return New vector containing the value
*/
Matrix2 operator * (const Matrix2& _obj); Matrix2 operator * (const Matrix2& _obj);
vec2 operator * (const vec2& _obj) const; /**
vec2 applyScaleRotation(const vec2& _obj) const; * @brief Operator* apply matrix on a vector
/***************************************************** * @param[in] _point Point value to apply the matrix
* ~ operator * @return New vector containing the value
*****************************************************/ */
vec2 operator * (const vec2& _point) const;
/**
* @brief Apply matrix on a vector Scale Rotate, but NOT the translation
* @param[in] _point Point value to apply the matrix
* @return New vector containing the value
*/
vec2 applyScaleRotation(const vec2& _point) const;
/**
* @brief Inverse the current Matrix
* @return New vector containing the value
*/
Matrix2 operator ~ () const; Matrix2 operator ~ () const;
/** /**
* @brief Flip the mathix threw the X axis * @brief Flip the mathix threw the X axis
@ -93,10 +145,12 @@ namespace etk {
/** /**
* @brief Scale the current Matrix. * @brief Scale the current Matrix.
* @param[in] _vect Vector to scale matrix. * @param[in] _vect Vector to scale matrix.
* @param[in] _value Single value to scale in X andf Y.
*/ */
void scale(const vec2& _vect); void scale(const vec2& _vect);
//! @previous /**
* @brief Scale the current Matrix.
* @param[in] _value Single value to scale in X andf Y.
*/
void scale(float _value); void scale(float _value);
/** /**
* @brief Makes a rotation matrix. * @brief Makes a rotation matrix.
@ -120,15 +174,40 @@ namespace etk {
*/ */
void invert(); void invert();
}; };
/**
* @brief Create a matrix 2D with a simple rotation
* @param[in] _angleRad Radian angle to set at the matrix
* @return New matrix of the transformation requested
*/
Matrix2 mat2Rotate(float _angleRad); Matrix2 mat2Rotate(float _angleRad);
/**
* @brief Create a matrix 2D with a simple scale
* @param[in] _scale 2 dimention scale
* @return New matrix of the transformation requested
*/
Matrix2 mat2Scale(const vec2& _scale); Matrix2 mat2Scale(const vec2& _scale);
/**
* @brief Create a matrix 2D with a simple scale
* @param[in] _scale same scale in 2 and Y
* @return New matrix of the transformation requested
*/
Matrix2 mat2Scale(float _scale); Matrix2 mat2Scale(float _scale);
/**
* @brief Create a matrix 2D with a simple translation
* @param[in] _translate 2 dimention translation
* @return New matrix of the transformation requested
*/
Matrix2 mat2Translate(const vec2& _translate); Matrix2 mat2Translate(const vec2& _translate);
/**
* @brief Create a matrix 2D with a simple skew
* @param[in] _skew 2 dimention skew
* @return New matrix of the transformation requested
*/
Matrix2 mat2Skew(const vec2& _skew); Matrix2 mat2Skew(const vec2& _skew);
//! @not_in_doc //! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const etk::Matrix2& _obj); std::ostream& operator <<(std::ostream& _os, const etk::Matrix2& _obj);
} }
// simplify using of matrix ... // simplify using of matrix ...
typedef etk::Matrix2 mat2; using mat2 = etk::Matrix2; //!< Use simplification in upper application to use matrix like openGL shader

View File

@ -11,8 +11,6 @@
#include <etk/debug.h> #include <etk/debug.h>
#include <math.h> #include <math.h>
#if 1
void etk::Matrix4::identity() { void etk::Matrix4::identity() {
for(int32_t iii=0; iii<4*4 ; iii++) { for(int32_t iii=0; iii<4*4 ; iii++) {
m_mat[iii] = 0; m_mat[iii] = 0;
@ -65,10 +63,6 @@ etk::Matrix4::Matrix4(float* _obj) {
} }
} }
etk::Matrix4::~Matrix4() {
}
const etk::Matrix4& etk::Matrix4::operator= (const etk::Matrix4& _obj ) { const etk::Matrix4& etk::Matrix4::operator= (const etk::Matrix4& _obj ) {
for(int32_t iii=0; iii<4*4 ; ++iii) { for(int32_t iii=0; iii<4*4 ; ++iii) {
m_mat[iii] = _obj.m_mat[iii]; m_mat[iii] = _obj.m_mat[iii];
@ -442,5 +436,3 @@ mat4 etk::matRotate(const vec3& _vect, float _angleRad) {
return tmp; return tmp;
} }
#endif

View File

@ -12,78 +12,147 @@
#include <etk/math/Vector3D.h> #include <etk/math/Vector3D.h>
#if 1
#include <math.h> #include <math.h>
/**
* @brief Convert degree in radian
* @param[in] a Value to converted in degree
* @return Angle in radian
*/
#define DEG_TO_RAD(a) ((a)*M_PI/180.0f) #define DEG_TO_RAD(a) ((a)*M_PI/180.0f)
/**
* @brief Convert radian in degree
* @param[in] a Value to converted in radian
* @return Angle in degree
*/
#define RAD_TO_DEG(a) ((a)*180.0f/M_PI) #define RAD_TO_DEG(a) ((a)*180.0f/M_PI)
namespace etk { namespace etk {
/**
* @brief Transformation matrix for vector 3D.
*/
class Matrix4 { class Matrix4 {
private:
float m_mat[4*4]; //!< matrix data
public: public:
float m_mat[4*4]; /**
* @brief configure identity of the matrix
*/
void identity(); void identity();
/***************************************************** /**
* Constructor * @brief Constructor that load identity
*****************************************************/ */
Matrix4(); Matrix4();
/**
* @brief Copy constructor.
* @param[in] _obj Matrix object to copy
*/
Matrix4(const Matrix4& _obj); Matrix4(const Matrix4& _obj);
/**
* @brief Configuration constructor.
* @param[in] _a1 1st colomn, 1 line value
* @param[in] _b1 2nd colomn, 1 line value
* @param[in] _c1 3rd colomn, 1 line value
* @param[in] _d1 4th colomn, 1 line value
* @param[in] _a2 1st colomn, 2 line value
* @param[in] _b2 2nd colomn, 2 line value
* @param[in] _c2 3rd colomn, 2 line value
* @param[in] _d2 4th colomn, 2 line value
* @param[in] _a3 1st colomn, 3 line value
* @param[in] _b3 2nd colomn, 3 line value
* @param[in] _c3 3rd colomn, 3 line value
* @param[in] _d3 4th colomn, 3 line value
* @param[in] _a4 1st colomn, 4 line value
* @param[in] _b4 2nd colomn, 4 line value
* @param[in] _c4 3rd colomn, 4 line value
* @param[in] _d4 4th colomn, 4 line value
*/
Matrix4(float _a1, float _b1, float _c1, float _d1, Matrix4(float _a1, float _b1, float _c1, float _d1,
float _a2, float _b2, float _c2, float _d2, float _a2, float _b2, float _c2, float _d2,
float _a3, float _b3, float _c3, float _d3, float _a3, float _b3, float _c3, float _d3,
float _a4, float _b4, float _c4, float _d4); float _a4, float _b4, float _c4, float _d4);
Matrix4(float* _obj); /**
/***************************************************** * @brief Configuration constructor.
* Destructor * @param[in] _values vector of values
*****************************************************/ */
~Matrix4(); Matrix4(float* _values);
/***************************************************** /**
* = assigment * @brief Operator= Asign the current object with an other object
*****************************************************/ * @param[in] _obj Reference on the external object
const Matrix4& operator= (const Matrix4& _obj ); * @return Local reference of the vector asigned
/***************************************************** */
* == operator const Matrix4& operator= (const Matrix4& _obj);
*****************************************************/ /**
* @brief Equality compare operator with an other object.
* @param[in] _obj Reference on the comparing object
* @return true The Objects are identical
* @return false The Objects are NOT identical
*/
bool operator== (const Matrix4& _obj) const; bool operator== (const Matrix4& _obj) const;
/***************************************************** /**
* != operator * @brief In-Equality compare operator with an other object.
*****************************************************/ * @param[in] _obj Reference on the comparing object
* @return true The Objects are NOT identical
* @return false The Objects are identical
*/
bool operator!= (const Matrix4& _obj) const; bool operator!= (const Matrix4& _obj) const;
/***************************************************** /**
* += operator * @brief Operator+= Addition an other matrix with this one
*****************************************************/ * @param[in] _obj Reference on the external object
* @return Local reference of the vector additionned
*/
const Matrix4& operator+= (const Matrix4& _obj); const Matrix4& operator+= (const Matrix4& _obj);
/***************************************************** /**
* + operator * @brief Operator+ Addition an other matrix with this one
*****************************************************/ * @param[in] _obj Reference on the external object
* @return New vector containing the value
*/
Matrix4 operator+ (const Matrix4& _obj) const; Matrix4 operator+ (const Matrix4& _obj) const;
/***************************************************** /**
* -= operator * @brief Operator-= Decrement an other matrix with this one
*****************************************************/ * @param[in] _obj Reference on the external object
* @return Local reference of the vector decremented
*/
const Matrix4& operator-= (const Matrix4& _obj); const Matrix4& operator-= (const Matrix4& _obj);
/***************************************************** /**
* - operator * @brief Operator- Decrement an other matrix with this one
*****************************************************/ * @param[in] _obj Reference on the external object
* @return New vector containing the value
*/
Matrix4 operator- (const Matrix4& _obj) const; Matrix4 operator- (const Matrix4& _obj) const;
/***************************************************** /**
* *= operator * @brief Operator*= Multiplication an other matrix with this one
*****************************************************/ * @param[in] _obj Reference on the external object
* @return Local reference of the vector multiplicated
*/
const Matrix4& operator*= (const Matrix4& _obj); const Matrix4& operator*= (const Matrix4& _obj);
/***************************************************** /**
* * operator * @brief Operator* Multiplication an other matrix with this one
*****************************************************/ * @param[in] _obj Reference on the external object
* @return New vector containing the value
*/
Matrix4 operator* (const Matrix4& _obj) const; Matrix4 operator* (const Matrix4& _obj) const;
/**
* @brief Operator* apply matrix on a vector
* @param[in] _point Point value to apply the matrix
* @return New vector containing the value
*/
vec3 operator*(const vec3& _point) const; vec3 operator*(const vec3& _point) const;
/***************************************************** /**
* other basic function : * @brief Transpose the current matix (usefull for OpenGL display)
*****************************************************/ */
void transpose(); void transpose();
/** /**
* @brief Scale the current Matrix. * @brief Scale the current Matrix.
* @param[in] _vect Scale vector to apply. * @param[in] _vect Scale vector to apply.
*/ */
void scale(const vec3& _vect); void scale(const vec3& _vect);
//! @previous /**
* @brief Scale the current Matrix.
* @param[in] _sx Scale X value to apply.
* @param[in] _sy Scale Y value to apply.
* @param[in] _sz Scale Z value to apply.
*/
void scale(float _sx, float _sy, float _sz); void scale(float _sx, float _sy, float _sz);
/** /**
* @brief Makes a rotation matrix about an arbitrary axis. * @brief Makes a rotation matrix about an arbitrary axis.
@ -118,9 +187,26 @@ namespace etk {
Matrix4 matFrustum(float _xmin, float _xmax, float _ymin, float _ymax, float _zNear, float _zFar); Matrix4 matFrustum(float _xmin, float _xmax, float _ymin, float _ymax, float _zNear, float _zFar);
Matrix4 matPerspective(float _foxy, float _aspect, float _zNear, float _zFar); Matrix4 matPerspective(float _foxy, float _aspect, float _zNear, float _zFar);
Matrix4 matOrtho(float _left, float _right, float _bottom, float _top, float _nearVal, float _farVal); Matrix4 matOrtho(float _left, float _right, float _bottom, float _top, float _nearVal, float _farVal);
Matrix4 matTranslate(vec3 _vect); /**
Matrix4 matScale(vec3 _vect); * @brief Create a matrix 3D with a simple translation
Matrix4 matRotate(vec3 _vect, float _angleRad=0.0); * @param[in] _translate 3 dimention translation
* @return New matrix of the transformation requested
*/
Matrix4 matTranslate(vec3 _translate);
/**
* @brief Create a matrix 3D with a simple scale
* @param[in] _scale 3 dimention scale
* @return New matrix of the transformation requested
*/
Matrix4 matScale(vec3 _scale);
/**
* @brief Create a matrix 3D with a simple rotation
* @param[in] _normal vector aroud witch apply the rotation
* @param[in] _angleRad Radian angle to set at the matrix
* @return New matrix of the transformation requested
*/
Matrix4 matRotate(vec3 _normal, float _angleRad=0.0);
//! @not_in_doc
Matrix4 matRotate2(vec3 _vect); Matrix4 matRotate2(vec3 _vect);
Matrix4 matLookAt(const vec3& _eye, Matrix4 matLookAt(const vec3& _eye,
const vec3& _target, const vec3& _target,
@ -131,21 +217,5 @@ namespace etk {
// To siplify the writing of the code ==> this permit to have the same name with the glsl language... // To siplify the writing of the code ==> this permit to have the same name with the glsl language...
typedef etk::Matrix4 mat4; using mat4 = etk::Matrix4; //!< Matrix naming like openGl shader
#else
// include matrix from bulletlib mat4 interface:
#include <vectormath/scalar/vectormath_aos.h>
// To siplify the writing of the code ==> this permit to have the same name with the glsl language...
typedef Vectormath::Aos::Matrix4 mat4;
//! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const mat4& _obj);
// TODO : Remove this ???
namespace etk {
mat4 matTranslate(const vec3& _vect);
mat4 matScale(const vec3& _vect);
mat4 matRotate(const vec3& _vect, float _angleRad=0.0);
}
#endif

View File

@ -532,15 +532,15 @@ namespace etk {
// To siplify the writing of the code ==> this permit to have the same name with the glsl language... // To siplify the writing of the code ==> this permit to have the same name with the glsl language...
#ifdef ETK_BUILD_LINEARMATH #ifdef ETK_BUILD_LINEARMATH
typedef btVector3 vec3; //!< wrapper on etk::Vector3D<float> to have the same naming has OpenGL shader using vec3 = btVector3; //!< wrapper on etk::Vector3D<float> to have the same naming has OpenGL shader
#else #else
typedef etk::Vector3D<float> vec3; //!< wrapper on etk::Vector3D<float> to have the same naming has OpenGL shader using vec3 = etk::Vector3D<float>; //!< wrapper on etk::Vector3D<float> to have the same naming has OpenGL shader
#endif #endif
typedef etk::Vector3D<float> ovec3; //!< wrapper on etk::Vector3D<float> to be complient all time with openGL internal mode (instead of vec3) using ovec3 = etk::Vector3D<float>; //!< wrapper on etk::Vector3D<float> to be complient all time with openGL internal mode (instead of vec3)
typedef etk::Vector3D<int32_t> ivec3; //!< wrapper on etk::Vector3D<int32_t> to have the same naming has OpenGL shader using ivec3 = etk::Vector3D<int32_t>; //!< wrapper on etk::Vector3D<int32_t> to have the same naming has OpenGL shader
// not compatible with glsl ... but it is better to have a same writing // not compatible with glsl ... but it is better to have a same writing
typedef etk::Vector3D<uint32_t> uivec3; //!< wrapper on etk::Vector3D<uint32_t> to have the same naming has OpenGL shader using uivec3 = etk::Vector3D<uint32_t>; //!< wrapper on etk::Vector3D<uint32_t> to have the same naming has OpenGL shader
typedef etk::Vector3D<bool> bvec3; //!< wrapper on etk::Vector3D<bool> to have the same naming has OpenGL shader using bvec3 = etk::Vector3D<bool>; //!< wrapper on etk::Vector3D<bool> to have the same naming has OpenGL shader
//! @not_in_doc //! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const vec3& _obj); std::ostream& operator <<(std::ostream& _os, const vec3& _obj);

View File

@ -432,10 +432,10 @@ namespace etk {
} }
// To siplify the writing of the code ==> this permit to have the same name with the glsl language... // To siplify the writing of the code ==> this permit to have the same name with the glsl language...
typedef etk::Vector4D<float> vec4; //!< wrapper on etk::Vector4D<float> to have the same naming has OpenGL shader using vec4 = etk::Vector4D<float>; //!< wrapper on etk::Vector4D<float> to have the same naming has OpenGL shader
typedef etk::Vector4D<int32_t> ivec4; //!< wrapper on etk::Vector4D<int32_t> to have the same naming has OpenGL shader using ivec4 = etk::Vector4D<int32_t>; //!< wrapper on etk::Vector4D<int32_t> to have the same naming has OpenGL shader
// not compatible with glsl ... but it is better to have a same writing // not compatible with glsl ... but it is better to have a same writing
typedef etk::Vector4D<uint32_t> uivec4; //!< wrapper on etk::Vector4D<uint32_t> to have the same naming has OpenGL shader using uivec4 = etk::Vector4D<uint32_t>; //!< wrapper on etk::Vector4D<uint32_t> to have the same naming has OpenGL shader
typedef etk::Vector4D<bool> bvec4; //!< wrapper on etk::Vector4D<bool> to have the same naming has OpenGL shader using bvec4 = etk::Vector4D<bool>; //!< wrapper on etk::Vector4D<bool> to have the same naming has OpenGL shader

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,9 @@
#pragma once #pragma once
#include <etk/os/FSNodeRight.h> #include <etk/os/FSNodeRight.h>
/**
* @brief Local maximum file name size
*/
#define MAX_FILE_NAME (10240) #define MAX_FILE_NAME (10240)
//http://developer.android.com/guide/topics/data/data-storage.html //http://developer.android.com/guide/topics/data/data-storage.html
@ -32,76 +34,88 @@ namespace etk {
} }
#endif #endif
namespace etk { namespace etk {
/**
* @brief Set the firt argument of the application start (this permit to get the real position of the execution path and executable position
* @param[in] _val First parameter.
*/
void setArgZero(const std::string& _val); void setArgZero(const std::string& _val);
/**
* @brief Simplify a path with all the complication that mean ".." or "///\//"
* @param[in] _input Parth to simplify
* @return the simplified path.
*/
std::string simplifyPath(std::string _input); std::string simplifyPath(std::string _input);
/** /**
* @brief Get application name. * @brief Get application name.
* @return The application name * @return The application name
*/ */
std::string FSNodeGetApplicationName(); std::string FSNodeGetApplicationName();
/** /**
* List of Type that a node can have (this wrap some type that not exist on Windows) * @brief List of Type that a node can have (this wrap some type that not exist on Windows)
*/ */
enum typeNode { enum typeNode {
FSN_UNKNOW, //!< Type of the node is not known typeNode_unknow, //!< Type of the node is not known
FSN_BLOCK, //!< The node is a block aceess device (Not availlable on Windows) typeNode_block, //!< The node is a block aceess device (Not availlable on Windows)
FSN_CHARACTER, //!< The node is a Char device type (Not availlable on Windows) typeNode_character, //!< The node is a Char device type (Not availlable on Windows)
FSN_FOLDER, //!< The node is a folder typeNode_folder, //!< The node is a folder
FSN_FIFO, //!< The node is a Fifo (Not availlable on Windows) typeNode_fifo, //!< The node is a Fifo (Not availlable on Windows)
FSN_LINK, //!< The node is a Link typeNode_link, //!< The node is a Link
FSN_FILE, //!< The node is a File typeNode_file, //!< The node is a File
FSN_SOCKET, //!< The node is a socket typeNode_socket, //!< The node is a socket
}; };
//! @not_in_doc
std::ostream& operator <<(std::ostream &_os, const enum etk::typeNode &_obj); std::ostream& operator <<(std::ostream &_os, const enum etk::typeNode &_obj);
/**
* @brief Seek mode availlable (just to wrap it ...)
*/
enum seekNode{ enum seekNode{
FSN_SEEK_START, seekNode_start, //!< request seek position start at the START of the file
FSN_SEEK_END, seekNode_end, //!< request seek position start at the END of the file
FSN_SEEK_CURRENT, seekNode_current, //!< request seek position start at the CURRENT position in the file
}; };
/**
* @brief Type of the file/folder/... accessible in the Node
*/
enum FSNType { enum FSNType {
FSN_TYPE_UNKNOW, FSNType_unknow, //!< Unknow type of the node (many time no file name seted)
// user might done abstraction ==> acces of the sdcard when possible ... // user might done abstraction ==> acces of the sdcard when possible ...
FSN_TYPE_DIRECT, FSNType_direct, //!< Access at the file System with a direct naming like "/home/plop/xxx.txt"
FSN_TYPE_RELATIF, FSNType_relatif, //!< Access at the file System with a relative naming like "../plop/xxx.txt"
// depend on case // depend on case
// - PC : ~/ // - PC : ~/
// - Android : /sdcard/ // - Android : /sdcard/
// - Apple : ???? // - Apple : ????
FSN_TYPE_HOME, FSNType_home, //!< acces at the home path of the system (with name of the current user)
// depend of the case // depend of the case
// - PC : /usr/shared/programName/ // - PC : /usr/shared/programName/
// - Android : Internal at the executable file (pointer on static area) // - Android : Internal at the executable file (pointer on static area)
// - Apple : Internal at the executable file // - Apple : Internal at the executable file
FSN_TYPE_DATA, FSNType_data, //!< Access on the application data (internal application data are the one provided with the binary)
// depend on case // depend on case
// - PC : ~/.local/programName/ // - PC : ~/.local/programName/
// - Android : /data/data/programName/files/ // - Android : /data/data/programName/files/
// - Apple : ???? // - Apple : ????
FSN_TYPE_USER_DATA, FSNType_userData, //!< Access on the user application data (where the data are stored when the application stop)
// depend on case // depend on case
// - PC : ~/.programName/cache/ // - PC : ~/.programName/cache/
// - Android : /data/data/programName/cache/ // - Android : /data/data/programName/cache/
// - Apple : ???? // - Apple : ????
FSN_TYPE_CACHE, FSNType_cache, //!< Access on the application temporary path (remove when user want and whe the compter restart or have not enought memory)
// depend on case // depend on case
// - try on FSN_TYPE_USER_DATA:/theme/themeName/xxx // - try on USER_DATA:/theme/themeName/xxx
// - try on FSN_TYPE_DATA:/theme/themeName/xxx // - try on DATA:/theme/themeName/xxx
// and jump to the default theme file // and jump to the default theme file
// - try on FSN_TYPE_USER_DATA:/theme/default/xxx // - try on USER_DATA:/theme/default/xxx
// - try on FSN_TYPE_DATA:/theme/default/xxx // - try on DATA:/theme/default/xxx
FSN_TYPE_THEME, FSNType_theme, //!< Theme area
FSN_TYPE_THEME_DATA FSNType_themeData //!< Theme data area
}; };
//! @not_in_doc
std::ostream& operator <<(std::ostream &_os, const enum etk::FSNType &_obj); std::ostream& operator <<(std::ostream &_os, const enum etk::FSNType &_obj);
/* /*
@ -144,7 +158,9 @@ namespace etk {
./ ./
*/ */
/** /**
* @brief FS node is for File system IO access This class is independent of the OS, If you acces to a file in windows, it might generate the right loke Linux (it is important to know that windows right is lighter than linux) * @brief FS node is for File System IO access (named classicly "node in linux EXT)
* This class is independent of the OS, If you acces to a file in windows, it might
* generate the right like Linux (it is important to know that windows right is lighter than linux)
*/ */
class FSNode { class FSNode {
private: private:
@ -210,11 +226,11 @@ namespace etk {
* @return false : The node does not exist. * @return false : The node does not exist.
*/ */
bool exist() const { bool exist() const {
return (m_typeNode!=etk::FSN_UNKNOW); return (m_typeNode!=etk::typeNode_unknow);
}; };
/** /**
* @brief Get the node type * @brief Get the node type
* @return the requested type, FSN_UNKNOW if it does not existed * @return the requested type, typeNode_unknow if it does not existed
*/ */
enum typeNode getNodeType() const { enum typeNode getNodeType() const {
return m_typeNode; return m_typeNode;
@ -234,10 +250,10 @@ namespace etk {
*/ */
bool setRight(etk::FSNodeRight _newRight); bool setRight(etk::FSNodeRight _newRight);
/** /**
* @brief Change the Node seeing (not rename the node, for this @ref Move) * @brief Change the Node seeing (not rename the node, for this @ref etk::FSNodeMove)
* @param[in] _newName New node name to show * @param[in] _newName New node name to show
* @return true : action done * @return true action done
* @return false : action not done * @return false action not done
*/ */
void setName(const std::string& _newName); void setName(const std::string& _newName);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
@ -398,6 +414,14 @@ namespace etk {
bool _getFolderAndOther = true, bool _getFolderAndOther = true,
bool _getFile = true, bool _getFile = true,
bool _temporaryFile = true); bool _temporaryFile = true);
/**
* @brief Get the List of all node inside a node (folder only)
* @param[in] _showHidenFile Add hidden file/folder/...
* @param[in] _getFolderAndOther get folder
* @param[in] _getFile Get files
* @param[in] _filter Generic regex string to filter file names
* @return The requested list
*/
std::vector<etk::FSNode*> folderGetSubList(bool _showHidenFile = true, std::vector<etk::FSNode*> folderGetSubList(bool _showHidenFile = true,
bool _getFolderAndOther = true, bool _getFolderAndOther = true,
bool _getFile = true, bool _getFile = true,
@ -516,17 +540,23 @@ namespace etk {
* @return Number of element written (in block number) * @return Number of element written (in block number)
*/ */
int64_t fileWrite(const void* _data, int64_t _blockSize, int64_t _nbBlock); int64_t fileWrite(const void* _data, int64_t _blockSize, int64_t _nbBlock);
// TODO: etk::FSNode& operator<< (const std::ostream& _data);
/** /**
* @brief Stream write mode * @brief Stream write mode
* @param[in] _data Stream to write * @param[in] _data Stream to write
* @return The current FSNode reference to add other stream.
* @note not stable API ... * @note not stable API ...
*/ */
//etk::FSNode& operator<< (const std::ostream& _data);
etk::FSNode& operator<< (const std::stringstream& _data); etk::FSNode& operator<< (const std::stringstream& _data);
//! @copydoc etk::FSNode::operator<<(const std::stringstream&)
etk::FSNode& operator<< (const std::string& _data); etk::FSNode& operator<< (const std::string& _data);
//! @copydoc etk::FSNode::operator<<(const std::stringstream&)
etk::FSNode& operator<< (const char* _data); etk::FSNode& operator<< (const char* _data);
//! @copydoc etk::FSNode::operator<<(const std::stringstream&)
etk::FSNode& operator<< (const int32_t _data); etk::FSNode& operator<< (const int32_t _data);
//! @copydoc etk::FSNode::operator<<(const std::stringstream&)
etk::FSNode& operator<< (const uint32_t _data); etk::FSNode& operator<< (const uint32_t _data);
//! @copydoc etk::FSNode::operator<<(const std::stringstream&)
etk::FSNode& operator<< (const float _data); etk::FSNode& operator<< (const float _data);
/** /**
* @brief Get the position in the file. * @brief Get the position in the file.
@ -555,6 +585,10 @@ namespace etk {
fileRead(&value[0], sizeof(T), fileSize()/sizeof(T)); fileRead(&value[0], sizeof(T), fileSize()/sizeof(T));
return value; return value;
} }
/**
* @brief Read all element in a file and set it in a generic std::string
* @return the read string
*/
std::string fileReadAllString() { std::string fileReadAllString() {
std::string value; std::string value;
value.resize(fileSize()); value.resize(fileSize());
@ -568,10 +602,16 @@ namespace etk {
#endif #endif
/** /**
* @brief Write all the vector in a file * @brief Write all the vector in a file
* @param[in] _value Data to write in the File
*/ */
template<typename T> void fileWriteAll(const std::vector<T>& _value) { template<typename T>
void fileWriteAll(const std::vector<T>& _value) {
fileWrite(static_cast<const void*>(&(_value[0])), sizeof(T), _value.size()/sizeof(T)); fileWrite(static_cast<const void*>(&(_value[0])), sizeof(T), _value.size()/sizeof(T));
} }
/**
* @brief Write all the vector in a file
* @param[in] _value String data to write in the File
*/
void fileWriteAll(const std::string& _value) { void fileWriteAll(const std::string& _value) {
fileWrite(static_cast<const void*>(&(_value[0])), sizeof(char), _value.size()/sizeof(char)); fileWrite(static_cast<const void*>(&(_value[0])), sizeof(char), _value.size()/sizeof(char));
} }
@ -587,7 +627,7 @@ namespace etk {
*/ */
void sortElementList(std::vector<etk::FSNode *>& _list); void sortElementList(std::vector<etk::FSNode *>& _list);
}; };
//! @not_in_doc
std::ostream& operator <<(std::ostream &_os, const etk::FSNode &_obj); std::ostream& operator <<(std::ostream &_os, const etk::FSNode &_obj);
/** /**
@ -709,9 +749,9 @@ namespace etk {
* @return true : Action done corectly * @return true : Action done corectly
* @return false : An error occured * @return false : An error occured
*/ */
bool FSNodeCreate(const std::string& _path, etk::FSNodeRight _right, enum etk::typeNode _type=etk::FSN_FOLDER); bool FSNodeCreate(const std::string& _path, etk::FSNodeRight _right, enum etk::typeNode _type=etk::typeNode_folder);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
bool FSNodeCreate(const std::u32string& _path, etk::FSNodeRight _right, enum etk::typeNode _type=etk::FSN_FOLDER); bool FSNodeCreate(const std::u32string& _path, etk::FSNodeRight _right, enum etk::typeNode _type=etk::typeNode_folder);
#endif #endif
/** /**
* @brief Simple access for : chexk the exestance of an element * @brief Simple access for : chexk the exestance of an element

View File

@ -11,167 +11,146 @@
// Right Flags : // Right Flags :
enum { enum {
RIGHT_OTHER_EXECUTE = 1 << 0, right_other_execute = 1 << 0,
RIGHT_OTHER_WRITE = 1 << 1, right_other_write = 1 << 1,
RIGHT_OTHER_READ = 1 << 2, right_other_read = 1 << 2,
RIGHT_GROUP_EXECUTE = 1 << 3, right_group_execute = 1 << 3,
RIGHT_GROUP_WRITE = 1 << 4, right_group_write = 1 << 4,
RIGHT_GROUP_READ = 1 << 5, right_group_read = 1 << 5,
RIGHT_USER_EXECUTE = 1 << 6, right_user_execute = 1 << 6,
RIGHT_USER_WRITE = 1 << 7, right_user_write = 1 << 7,
RIGHT_USER_READ = 1 << 8, right_user_read = 1 << 8,
}; };
etk::FSNodeRight::FSNodeRight() : etk::FSNodeRight::FSNodeRight() :
m_rights(0) m_rights(0) {
{
} }
etk::FSNodeRight::FSNodeRight(int16_t _newRight) : etk::FSNodeRight::FSNodeRight(int16_t _newRight) :
m_rights(_newRight&0x01FF) m_rights(_newRight&0x01FF) {
{
} }
// copy operator :
const etk::FSNodeRight& etk::FSNodeRight::operator= (const etk::FSNodeRight &_obj ) etk::FSNodeRight& etk::FSNodeRight::operator= (const etk::FSNodeRight &_obj ) {
{
m_rights = _obj.m_rights; m_rights = _obj.m_rights;
return *this; return *this;
} }
// set right : etk::FSNodeRight& etk::FSNodeRight::operator= (const int32_t _newVal) {
const etk::FSNodeRight& etk::FSNodeRight::operator= (const int32_t _newVal )
{
m_rights = _newVal&0x01FF; m_rights = _newVal&0x01FF;
return *this; return *this;
} }
// User void etk::FSNodeRight::clear() {
bool etk::FSNodeRight::isUserReadable() const m_rights = 0;
{
return ((m_rights&RIGHT_USER_READ)!=0)?true:false;
} }
bool etk::FSNodeRight::isUserWritable() const bool etk::FSNodeRight::isUserReadable() const {
{ return ((m_rights&right_user_read)!=0)?true:false;
return ((m_rights&RIGHT_USER_WRITE)!=0)?true:false;
} }
bool etk::FSNodeRight::isUserRunable() const bool etk::FSNodeRight::isUserWritable() const {
{ return ((m_rights&right_user_write)!=0)?true:false;
return ((m_rights&RIGHT_USER_EXECUTE)!=0)?true:false;
} }
void etk::FSNodeRight::setUserReadable(bool _newStatus) bool etk::FSNodeRight::isUserRunable() const {
{ return ((m_rights&right_user_execute)!=0)?true:false;
}
void etk::FSNodeRight::setUserReadable(bool _newStatus) {
// reset the flag : // reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_USER_READ); m_rights &= (0xFFFFFFFF - right_user_read);
if (true == _newStatus) { if (_newStatus == true) {
m_rights |= RIGHT_USER_READ; m_rights |= right_user_read;
} }
} }
void etk::FSNodeRight::setUserWritable(bool _newStatus) void etk::FSNodeRight::setUserWritable(bool _newStatus) {
{
// reset the flag : // reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_USER_WRITE); m_rights &= (0xFFFFFFFF - right_user_write);
if (true == _newStatus) { if (_newStatus == true) {
m_rights |= RIGHT_USER_WRITE; m_rights |= right_user_write;
} }
} }
void etk::FSNodeRight::setUserRunable(bool _newStatus) void etk::FSNodeRight::setUserRunable(bool _newStatus) {
{
// reset the flag : // reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_USER_EXECUTE); m_rights &= (0xFFFFFFFF - right_user_execute);
if (true == _newStatus) { if (_newStatus == true) {
m_rights |= RIGHT_USER_EXECUTE; m_rights |= right_user_execute;
} }
} }
// group bool etk::FSNodeRight::isGroupReadable() const {
bool etk::FSNodeRight::isGroupReadable() const return ((m_rights&right_group_read)!=0)?true:false;
{
return ((m_rights&RIGHT_GROUP_READ)!=0)?true:false;
} }
bool etk::FSNodeRight::isGroupWritable() const bool etk::FSNodeRight::isGroupWritable() const {
{ return ((m_rights&right_group_write)!=0)?true:false;
return ((m_rights&RIGHT_GROUP_WRITE)!=0)?true:false;
} }
bool etk::FSNodeRight::isGroupRunable() const bool etk::FSNodeRight::isGroupRunable() const {
{ return ((m_rights&right_group_execute)!=0)?true:false;
return ((m_rights&RIGHT_GROUP_EXECUTE)!=0)?true:false;
} }
void etk::FSNodeRight::setGroupReadable(bool _newStatus) void etk::FSNodeRight::setGroupReadable(bool _newStatus) {
{
// reset the flag : // reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_GROUP_READ); m_rights &= (0xFFFFFFFF - right_group_read);
if (true == _newStatus) { if (true == _newStatus) {
m_rights |= RIGHT_GROUP_READ; m_rights |= right_group_read;
} }
} }
void etk::FSNodeRight::setGroupWritable(bool _newStatus) void etk::FSNodeRight::setGroupWritable(bool _newStatus) {
{
// reset the flag : // reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_GROUP_WRITE); m_rights &= (0xFFFFFFFF - right_group_write);
if (true == _newStatus) { if (true == _newStatus) {
m_rights |= RIGHT_GROUP_WRITE; m_rights |= right_group_write;
} }
} }
void etk::FSNodeRight::setGroupRunable(bool _newStatus) void etk::FSNodeRight::setGroupRunable(bool _newStatus) {
{
// reset the flag : // reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_GROUP_EXECUTE); m_rights &= (0xFFFFFFFF - right_group_execute);
if (true == _newStatus) { if (true == _newStatus) {
m_rights |= RIGHT_GROUP_EXECUTE; m_rights |= right_group_execute;
} }
} }
// other bool etk::FSNodeRight::isOtherReadable() const {
bool etk::FSNodeRight::isOtherReadable() const return ((m_rights&right_other_read) != 0)?true:false;
{
return ((m_rights&RIGHT_OTHER_READ) != 0)?true:false;
} }
bool etk::FSNodeRight::isOtherWritable() const bool etk::FSNodeRight::isOtherWritable() const {
{ return ((m_rights&right_other_write) != 0)?true:false;
return ((m_rights&RIGHT_OTHER_WRITE) != 0)?true:false;
} }
bool etk::FSNodeRight::isOtherRunable() const bool etk::FSNodeRight::isOtherRunable() const {
{ return ((m_rights&right_other_execute) != 0)?true:false;
return ((m_rights&RIGHT_OTHER_EXECUTE) != 0)?true:false;
} }
void etk::FSNodeRight::setOtherReadable(bool _newStatus) void etk::FSNodeRight::setOtherReadable(bool _newStatus) {
{ // reset the flag:
// reset the flag : m_rights &= (0xFFFFFFFF - right_other_read);
m_rights &= (0xFFFFFFFF - RIGHT_OTHER_READ); if (_newStatus == true) {
if (true == _newStatus) { m_rights |= right_other_read;
m_rights |= RIGHT_OTHER_READ;
} }
} }
void etk::FSNodeRight::setOtherWritable(bool _newStatus) void etk::FSNodeRight::setOtherWritable(bool _newStatus) {
{
// reset the flag : // reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_OTHER_WRITE); m_rights &= (0xFFFFFFFF - right_other_write);
if (true == _newStatus) { if (_newStatus == true) {
m_rights |= RIGHT_OTHER_WRITE; m_rights |= right_other_write;
} }
} }
void etk::FSNodeRight::setOtherRunable(bool _newStatus) void etk::FSNodeRight::setOtherRunable(bool _newStatus) {
{
// reset the flag : // reset the flag :
m_rights &= (0xFFFFFFFF - RIGHT_OTHER_EXECUTE); m_rights &= (0xFFFFFFFF - right_other_execute);
if (true == _newStatus) { if (_newStatus == true) {
m_rights |= RIGHT_OTHER_EXECUTE; m_rights |= right_other_execute;
} }
} }
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011

View File

@ -11,45 +11,144 @@
#pragma once #pragma once
namespace etk { namespace etk {
/**
* @brief File System Right management
*/
class FSNodeRight { class FSNodeRight {
private: private:
uint16_t m_rights; uint16_t m_rights; //!< right manage in a bit field
public: public:
FSNodeRight(); /**
FSNodeRight(int16_t _newRight); * @brief Right contructor.
~FSNodeRight() { }; * @param[in] _newRight Right to set by default
// copy operator : */
const etk::FSNodeRight& operator= (const etk::FSNodeRight &_obj ); FSNodeRight(int16_t _newRight = 0);
// set right : /**
const etk::FSNodeRight& operator= (const int32_t _newVal ); * @brief Copy asignement operator (operator=)
* @param[in] _obj Object to copy
void clear() { * @return Local reference on the object
m_rights = 0; */
}; etk::FSNodeRight& operator= (const etk::FSNodeRight &_obj);
// User /**
* @brief Asignement operator (operator=)
* @param[in] _newVal Value to set on the right
* @return Local reference on the object
*/
etk::FSNodeRight& operator= (const int32_t _newVal );
/**
* @brief Clear right (set the value at 0 ==> cant not be read/write/execute
*/
void clear();
/**
* @brief Get the "Read status" for the "User"
* @return true The file/folder/... is readable
* @return false The file/folder/... is NOT readable
*/
bool isUserReadable() const; bool isUserReadable() const;
/**
* @brief Get the "Write status" for the "User"
* @return true The file/folder/... is writable
* @return false The file/folder/... is NOT writable
*/
bool isUserWritable() const; bool isUserWritable() const;
/**
* @brief Get the "execute status" for the "User"
* @return true The file/folder/... is executable
* @return false The file/folder/... is NOT executable
*/
bool isUserRunable() const; bool isUserRunable() const;
/**
* @brief Set the "Read status" for the "User"
* @param[in] _newStatus New value to set on the file/folder/...
*/
void setUserReadable(bool _newStatus); void setUserReadable(bool _newStatus);
/**
* @brief Set the "Write status" for the "User"
* @param[in] _newStatus New value to set on the file/folder/...
*/
void setUserWritable(bool _newStatus); void setUserWritable(bool _newStatus);
/**
* @brief Set the "execute status" for the "User"
* @param[in] _newStatus New value to set on the file/folder/...
*/
void setUserRunable(bool _newStatus); void setUserRunable(bool _newStatus);
// group /**
* @brief Get the "Read status" for the "Group"
* @return true The file/folder/... is readable
* @return false The file/folder/... is NOT readable
*/
bool isGroupReadable() const; bool isGroupReadable() const;
/**
* @brief Get the "Write status" for the "Group"
* @return true The file/folder/... is writable
* @return false The file/folder/... is NOT writable
*/
bool isGroupWritable() const; bool isGroupWritable() const;
/**
* @brief Get the "execute status" for the "Group"
* @return true The file/folder/... is executable
* @return false The file/folder/... is NOT executable
*/
bool isGroupRunable() const; bool isGroupRunable() const;
/**
* @brief Set the "Read status" for the "Group"
* @param[in] _newStatus New value to set on the file/folder/...
*/
void setGroupReadable(bool _newStatus); void setGroupReadable(bool _newStatus);
/**
* @brief Set the "Write status" for the "Group"
* @param[in] _newStatus New value to set on the file/folder/...
*/
void setGroupWritable(bool _newStatus); void setGroupWritable(bool _newStatus);
/**
* @brief Set the "Execute status" for the "Group"
* @param[in] _newStatus New value to set on the file/folder/...
*/
void setGroupRunable(bool _newStatus); void setGroupRunable(bool _newStatus);
// other /**
* @brief Get the "Read status" for the "Other"
* @return true The file/folder/... is readable
* @return false The file/folder/... is NOT readable
*/
bool isOtherReadable() const; bool isOtherReadable() const;
/**
* @brief Get the "Write status" for the "Other"
* @return true The file/folder/... is writable
* @return false The file/folder/... is NOT writable
*/
bool isOtherWritable() const; bool isOtherWritable() const;
/**
* @brief Get the "execute status" for the "Other"
* @return true The file/folder/... is executable
* @return false The file/folder/... is NOT executable
*/
bool isOtherRunable() const; bool isOtherRunable() const;
/**
* @brief Set the "Read status" for the "Other"
* @param[in] _newStatus New value to set on the file/folder/...
*/
void setOtherReadable(bool _newStatus); void setOtherReadable(bool _newStatus);
/**
* @brief Set the "Write status" for the "Other"
* @param[in] _newStatus New value to set on the file/folder/...
*/
void setOtherWritable(bool _newStatus); void setOtherWritable(bool _newStatus);
/**
* @brief Set the "Execute status" for the "Other"
* @param[in] _newStatus New value to set on the file/folder/...
*/
void setOtherRunable(bool _newStatus); void setOtherRunable(bool _newStatus);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
/**
* @brief Get the write written in a string mode (like in linux rw-r-----)
* @return String with the right in string
*/
std::u32string getURight() const; std::u32string getURight() const;
#endif #endif
/**
* @brief Get the write written in a string mode (like in linux rw-r-----)
* @return String with the right in string
*/
std::string getRight() const; std::string getRight() const;
}; };
//! @not_in_doc //! @not_in_doc

View File

@ -103,7 +103,10 @@ namespace etk {
m_data.push_back(_data); m_data.push_back(_data);
m_condition.notify_all(); m_condition.notify_all();
}; };
//! @previous /**
* @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.
*/
void post(const MY_TYPE &_data) { void post(const MY_TYPE &_data) {
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<std::mutex> lock(m_mutex);
m_data.push_back(_data); m_data.push_back(_data);

View File

@ -9,8 +9,6 @@
#include <etk/stdTools.h> #include <etk/stdTools.h>
#include <etk/debug.h> #include <etk/debug.h>
#undef __class__
#define __class__ "u32char"
const char32_t u32char::Null('\0'); const char32_t u32char::Null('\0');
const char32_t u32char::Return('\n'); const char32_t u32char::Return('\n');
@ -137,10 +135,6 @@ int8_t u32char::convertUtf8(char32_t _val, char _output[5]) {
} }
#endif #endif
#undef __class__
#define __class__ "utf8"
static uint8_t sizeElement(const char* _data, int32_t _lenMax) { static uint8_t sizeElement(const char* _data, int32_t _lenMax) {
uint8_t size = 0; uint8_t size = 0;
TK_ASSERT(0 <= _lenMax, "size can not be < 0 ..."); TK_ASSERT(0 <= _lenMax, "size can not be < 0 ...");
@ -309,8 +303,6 @@ char32_t utf8::iterator::operator* () {
} }
#undef __class__
#define __class__ "etk"
namespace etk { namespace etk {
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
template<> std::string to_string<std::u32string>(const std::u32string& _input) { template<> std::string to_string<std::u32string>(const std::u32string& _input) {

View File

@ -16,35 +16,66 @@
#include <algorithm> #include <algorithm>
#include <chrono> #include <chrono>
/**
* @brief Unicode simple wrapper interface
*/
namespace u32char { namespace u32char {
extern const char32_t Null; //!< '\0' extern const char32_t Null; //!< Value '\\0'
extern const char32_t Return; //!< '\n' extern const char32_t Return; //!< Value '\\n'
extern const char32_t CarrierReturn; //!< '\r' CR extern const char32_t CarrierReturn; //!< Value '\\r' CR
extern const char32_t Tabulation; //!< '\t' TAB extern const char32_t Tabulation; //!< Value '\\t' TAB
extern const char32_t Suppress; //!< BS (SUPPRESS) extern const char32_t Suppress; //!< Value BS (SUPPRESS)
extern const char32_t Delete; //!< DEL extern const char32_t Delete; //!< Value DEL
extern const char32_t Space; //!< ' ' SPACE extern const char32_t Space; //!< Value ' ' SPACE
extern const char32_t Escape; //!< ESC Escape extern const char32_t Escape; //!< Value ESC Escape
/** /**
* @brief check if the current element is white or not : '\t' '\n' '\r' ' ' * @brief check if the current element is white or not : '\\t' '\\n' '\\r' ' '
* @return tue if it is white char * @param[in] _val Value to interprete
* @return true if it is white char
* @return false otherwise
*/ */
bool isWhiteChar(char32_t _val); bool isWhiteChar(char32_t _val);
/**
* @brief check if the current element is NOT [a-zA-Z0-9]
* @param[in] _val Value to interprete
* @return true Not in the previous list
* @return false otherwise
*/
bool isSpecialChar(char32_t _val); bool isSpecialChar(char32_t _val);
/** /**
* @brief check if the curent element is number or not * @brief check if the curent element is number or not [0-9]
* @return tue if it is a number char * @param[in] _val Value to interprete
* @return true if it is a number char
* @return false otherwise
*/ */
bool isInteger(char32_t _val); bool isInteger(char32_t _val);
/**
* @brief Convert char32_t in an interfer
* @param[in] _val Value to interprete
* @return The parsed Value or ...
*/
int32_t toInt(char32_t _val); int32_t toInt(char32_t _val);
/**
* @brief Change order of the value to have an order of display with A->Z and after a->z and after 0->9 and after all the rest ....
* @param[in] _val Value in unicode
* @return A value usable in interfer only ... to check order...
*/
char32_t changeOrder(char32_t _val); char32_t changeOrder(char32_t _val);
/**
* @brief Conver unicode in UTF8 value
* @param[in] _val Value to convert
* @param[out] _output Char data converted
* @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 #if __CPP_VERSION__ >= 2011
std::string convertToUtf8(const std::u32string& _input); std::string convertToUtf8(const std::u32string& _input);
#endif #endif
}; };
/**
* @brief UTF-8 simple wrapper interface
*/
namespace utf8 { namespace utf8 {
/** /**
* @brief Get the size of an utf8 char with his first char. * @brief Get the size of an utf8 char with his first char.
@ -58,7 +89,11 @@ namespace utf8 {
* @return true if it was the first char. * @return true if it was the first char.
*/ */
bool theoricFirst(const char _input); bool theoricFirst(const char _input);
/**
* @brief Convert a char* in a unicode value
* @param[in] _input pointer on a string C (utf-8) to convert
* @return Converted Value
*/
char32_t convertChar32(const char* _input); char32_t convertChar32(const char* _input);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
std::u32string convertUnicode(const std::string& _input); std::u32string convertUnicode(const std::string& _input);
@ -402,41 +437,61 @@ namespace utf8 {
namespace std { namespace std {
#if (defined(__TARGET_OS__MacOs) || defined(__TARGET_OS__Windows)) #if (defined(__TARGET_OS__MacOs) || defined(__TARGET_OS__Windows))
typedef std::basic_string<char32_t> u32string; using u32string = std::basic_string<char32_t>;
#endif #endif
#if (defined(__TARGET_OS__Android)) #if (defined(__TARGET_OS__Android))
//! @previous //! @not_in_doc
std::string to_string(int _val); std::string to_string(int _val);
//! @previous //! @not_in_doc
std::string to_string(long _val); std::string to_string(long _val);
//! @previous //! @not_in_doc
std::string to_string(long long _val); std::string to_string(long long _val);
//! @previous //! @not_in_doc
std::string to_string(unsigned _val); std::string to_string(unsigned _val);
//! @previous //! @not_in_doc
std::string to_string(unsigned long _val); std::string to_string(unsigned long _val);
//! @previous //! @not_in_doc
std::string to_string(unsigned long long _val); std::string to_string(unsigned long long _val);
//! @previous //! @not_in_doc
std::string to_string(float _val); std::string to_string(float _val);
//! @previous //! @not_in_doc
std::string to_string(double _val); std::string to_string(double _val);
//! @previous //! @not_in_doc
std::string to_string(long double _val); std::string to_string(long double _val);
//! @not_in_doc
double stod(const std::string& _str, size_t* _idx = 0); double stod(const std::string& _str, size_t* _idx = 0);
//! @not_in_doc
float stof(const std::string& _str, size_t* _idx = 0); float stof(const std::string& _str, size_t* _idx = 0);
//! @not_in_doc
int stoi(const std::string& _str, size_t* _idx = 0, int _base = 10); int stoi(const std::string& _str, size_t* _idx = 0, int _base = 10);
//! @not_in_doc
long stol(const std::string& _str, size_t* _idx = 0, int _base = 10); long stol(const std::string& _str, size_t* _idx = 0, int _base = 10);
//! @not_in_doc
long double stold(const std::string& _str, size_t* _idx = 0); long double stold(const std::string& _str, size_t* _idx = 0);
//! @not_in_doc
long long stoll(const std::string& _str, size_t* _idx = 0, int _base = 10); long long stoll(const std::string& _str, size_t* _idx = 0, int _base = 10);
//! @not_in_doc
unsigned long stoul(const std::string& _str, size_t* _idx = 0, int _base = 10); unsigned long stoul(const std::string& _str, size_t* _idx = 0, int _base = 10);
//! @not_in_doc
unsigned long long stoull(const std::string& _str, size_t* _idx = 0, int _base = 10); unsigned long long stoull(const std::string& _str, size_t* _idx = 0, int _base = 10);
#endif #endif
}; };
namespace etk { namespace etk {
// these declaration is to prevent some under template declaration of unknown type // these declaration is to prevent some under template declaration of unknown type
template <class TYPE> std::string to_string(const TYPE& _variable); /**
template <class TYPE> std::string to_string(const std::vector<TYPE>& _list) { * @brief Template to declare convertion from anything in std::string
* @param[in] _variable Variable to convert
* @return String of the value
*/
template <class TYPE>
std::string to_string(const TYPE& _variable);
/**
* @brief Template to declare convertion from std::vector<anything> in std::string
* @param[in] _list Variable to convert
* @return String of the value: {...,...,...}
*/
template <class TYPE>
std::string to_string(const std::vector<TYPE>& _list) {
std::string out = "{"; std::string out = "{";
for (size_t iii=0; iii<_list.size(); ++iii) { for (size_t iii=0; iii<_list.size(); ++iii) {
if (iii!=0) { if (iii!=0) {
@ -448,131 +503,142 @@ namespace etk {
return out; return out;
} }
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
template <class TYPE> std::u32string to_u32string(const TYPE& _variable); template <class TYPE>
std::u32string to_u32string(const TYPE& _variable);
#endif #endif
// these declaration is to prevent some under template declaration of unknown type // these declaration is to prevent some under template declaration of unknown type
template <class TYPE> bool from_string(TYPE& _variableRet, const std::string& _value); /**
* @brief Template to declare convertion from string to anything
* @param[out] _variableRet Output value
* @param[in] _value input property
* @return true if the can be converted.
*/
template <class TYPE>
bool from_string(TYPE& _variableRet, const std::string& _value);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
template <class TYPE> bool from_string(TYPE& _variableRet, const std::u32string& _value); template <class TYPE>
bool from_string(TYPE& _variableRet, const std::u32string& _value);
#endif #endif
// TODO : Change this in : // TODO : Change this in :
// TODO : template <typename TYPE> TYPE string_to<TYPE>(const std::u32string& _value); ==> check exceptions ... // TODO : template <typename TYPE> TYPE string_to<TYPE>(const std::u32string& _value); ==> check exceptions ...
//! @not_in_doc
long double string_to_long_double(const std::string& _str); long double string_to_long_double(const std::string& _str);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
long double string_to_long_double(const std::u32string& _str); long double string_to_long_double(const std::u32string& _str);
#endif #endif
//! @not_in_doc
double string_to_double(const std::string& _str); double string_to_double(const std::string& _str);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
double string_to_double(const std::u32string& _str); double string_to_double(const std::u32string& _str);
#endif #endif
//! @not_in_doc
float string_to_float(const std::string& _str); float string_to_float(const std::string& _str);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
float string_to_float(const std::u32string& _str); float string_to_float(const std::u32string& _str);
#endif #endif
//! @not_in_doc
int8_t string_to_int8_t(const std::string& _str, int _base = 10); int8_t string_to_int8_t(const std::string& _str, int _base = 10);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
int8_t string_to_int8_t(const std::u32string& _str, int _base = 10); int8_t string_to_int8_t(const std::u32string& _str, int _base = 10);
#endif #endif
//! @not_in_doc
int16_t string_to_int16_t(const std::string& _str, int _base = 10); int16_t string_to_int16_t(const std::string& _str, int _base = 10);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
int16_t string_to_int16_t(const std::u32string& _str, int _base = 10); int16_t string_to_int16_t(const std::u32string& _str, int _base = 10);
#endif #endif
//! @not_in_doc
int32_t string_to_int32_t(const std::string& _str, int _base = 10); int32_t string_to_int32_t(const std::string& _str, int _base = 10);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
int32_t string_to_int32_t(const std::u32string& _str, int _base = 10); int32_t string_to_int32_t(const std::u32string& _str, int _base = 10);
#endif #endif
//! @not_in_doc
int64_t string_to_int64_t(const std::string& _str, int _base = 10); int64_t string_to_int64_t(const std::string& _str, int _base = 10);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
int64_t string_to_int64_t(const std::u32string& _str, int _base = 10); int64_t string_to_int64_t(const std::u32string& _str, int _base = 10);
#endif #endif
//! @not_in_doc
uint8_t string_to_uint8_t(const std::string& _str, int _base = 10); uint8_t string_to_uint8_t(const std::string& _str, int _base = 10);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
uint8_t string_to_uint8_t(const std::u32string& _str, int _base = 10); uint8_t string_to_uint8_t(const std::u32string& _str, int _base = 10);
#endif #endif
//! @not_in_doc
uint16_t string_to_uint16_t(const std::string& _str, int _base = 10); uint16_t string_to_uint16_t(const std::string& _str, int _base = 10);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
uint16_t string_to_uint16_t(const std::u32string& _str, int _base = 10); uint16_t string_to_uint16_t(const std::u32string& _str, int _base = 10);
#endif #endif
//! @not_in_doc
uint32_t string_to_uint32_t(const std::string& _str, int _base = 10); uint32_t string_to_uint32_t(const std::string& _str, int _base = 10);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
uint32_t string_to_uint32_t(const std::u32string& _str, int _base = 10); uint32_t string_to_uint32_t(const std::u32string& _str, int _base = 10);
#endif #endif
//! @not_in_doc
uint64_t string_to_uint64_t(const std::string& _str, int _base = 10); uint64_t string_to_uint64_t(const std::string& _str, int _base = 10);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
uint64_t string_to_uint64_t(const std::u32string& _str, int _base = 10); uint64_t string_to_uint64_t(const std::u32string& _str, int _base = 10);
#endif #endif
//! @not_in_doc
bool string_to_bool(const std::string& _str); bool string_to_bool(const std::string& _str);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
bool string_to_bool(const std::u32string& _str); bool string_to_bool(const std::u32string& _str);
#endif #endif
//! @not_in_doc
std::string tolower(std::string _obj); std::string tolower(std::string _obj);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
//! @previous //! @previous
std::u32string tolower(std::u32string _obj); std::u32string tolower(std::u32string _obj);
#endif #endif
//! @not_in_doc
std::string toupper(std::string _obj); std::string toupper(std::string _obj);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
//! @previous //! @previous
std::u32string toupper(std::u32string _obj); std::u32string toupper(std::u32string _obj);
#endif #endif
//! @not_in_doc
bool compare_no_case(const std::string& _obj, const std::string& _val); bool compare_no_case(const std::string& _obj, const std::string& _val);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
//! @previous //! @previous
bool compare_no_case(const std::u32string& _obj, const std::u32string& _val); bool compare_no_case(const std::u32string& _obj, const std::u32string& _val);
#endif #endif
//! @not_in_doc
bool end_with(const std::string& _obj, const std::string& _val, bool _caseSensitive = true); bool end_with(const std::string& _obj, const std::string& _val, bool _caseSensitive = true);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
//! @previous //! @previous
bool end_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive = true); bool end_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive = true);
#endif #endif
//! @not_in_doc
bool start_with(const std::string& _obj, const std::string& _val, bool _caseSensitive = true); bool start_with(const std::string& _obj, const std::string& _val, bool _caseSensitive = true);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
//! @previous //! @previous
bool start_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive = true); bool start_with(const std::u32string& _obj, const std::u32string& _val, bool _caseSensitive = true);
#endif #endif
//! @not_in_doc
std::string replace(const std::string& _obj, char _val, char _replace); std::string replace(const std::string& _obj, char _val, char _replace);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
//! @previous //! @previous
std::u32string replace(const std::u32string& _obj, char32_t _val, char32_t _replace); std::u32string replace(const std::u32string& _obj, char32_t _val, char32_t _replace);
#endif #endif
//! @not_in_doc
std::string extract_line(const std::string& _obj, int32_t _pos); std::string extract_line(const std::string& _obj, int32_t _pos);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
//! @previous //! @previous
std::u32string extract_line(const std::u32string& _obj, int32_t _pos); std::u32string extract_line(const std::u32string& _obj, int32_t _pos);
#endif #endif
//! @not_in_doc
std::vector<std::string> split(const std::string& _input, char _val); std::vector<std::string> split(const std::string& _input, char _val);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
//! @previous //! @previous
std::vector<std::u32string> split(const std::u32string& _input, char32_t _val); std::vector<std::u32string> split(const std::u32string& _input, char32_t _val);
#endif #endif
//! @not_in_doc
void sort(std::vector<std::string *>& _list); void sort(std::vector<std::string *>& _list);
#if __CPP_VERSION__ >= 2011 #if __CPP_VERSION__ >= 2011
//! @previous //! @previous
void sort(std::vector<std::u32string *>& _list); void sort(std::vector<std::u32string *>& _list);
#endif #endif
//! @not_in_doc
template<typename T, typename T2> bool isIn(const T& _val, const std::vector<T2>& _list) { template<typename T, typename T2>
bool isIn(const T& _val, const std::vector<T2>& _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;
@ -583,8 +649,15 @@ namespace etk {
}; };
namespace std { namespace std {
template <class TYPE> const TYPE& avg(const TYPE& a, const TYPE& b, const TYPE& c) { /**
return std::min(std::max(a,b),c); * @brief in std, we have min, max but not avg ==> it is missing... the Defineing avg template.
* @param[in] _min Minimum value of the range
* @param[in] _val The value that we want a min/max
* @param[in] _max Maximum value of the range
* @return Value that min/max applied
*/
template <class TYPE> const TYPE& avg(const TYPE& _min, const TYPE& _val, const TYPE& _max) {
return std::min(std::max(_min,_val),_max);
} }
}; };
@ -623,10 +696,14 @@ namespace std {
std::ostream& operator <<(std::ostream& _os, const std::chrono::system_clock::time_point& _obj); std::ostream& operator <<(std::ostream& _os, const std::chrono::system_clock::time_point& _obj);
//! @not_in_doc //! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const std::chrono::steady_clock::time_point& _obj); std::ostream& operator <<(std::ostream& _os, const std::chrono::steady_clock::time_point& _obj);
}
}; /**
* @brief Claculate the size of a string (unicode)
int32_t strlen(const char32_t * _data); * @param[in] _data Data to parse to find the end of string
* @return the Number of char32_t befor the '\\0' value
*/
int32_t strlen(const char32_t* _data);
#if (defined(__TARGET_OS__Windows)) #if (defined(__TARGET_OS__Windows))
#define M_PI 3.14159265358979323846 #define M_PI 3.14159265358979323846

View File

@ -11,15 +11,24 @@
#pragma once #pragma once
namespace etk { namespace etk {
/**
* @brief Some un-usefull tools
* @todo Remove all of this use std11 random
*/
namespace tool { namespace tool {
/** /**
* @brief Get a random value in a specific range. * @brief Get a random value in a specific range in float.
* @param[in] _a Lower value of the random. * @param[in] _a Lower value of the random.
* @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]
*/ */
double frand(double _a, double _b); double frand(double _a, double _b);
//! @previous /**
* @brief Get a random value in a specific range in integer.
* @param[in] _a Lower value of the random.
* @param[in] _b Bigger value of the random.
* @return Random Value between [_a and _b]
*/
int32_t irand(int32_t _a, int32_t _b); int32_t irand(int32_t _a, int32_t _b);
/** /**
* @brief Reset the random system with a random value (time). * @brief Reset the random system with a random value (time).

View File

@ -44,13 +44,15 @@
#include <etk/stdTools.h> #include <etk/stdTools.h>
#ifndef ETK_BUILD_LINEARMATH #ifndef ETK_BUILD_LINEARMATH
typedef float btScalar; //! @brief If not using linear math from bullet lib, we need to define the basic element of a btScalar (float)
using btScalar = float;
#endif #endif
#ifndef _WIN32 #ifndef _WIN32
#include <math.h> #include <math.h>
#ifndef _MATH_H_MATHDEF #ifndef _MATH_H_MATHDEF
typedef float float_t; //! @not_in_doc
using float_t = float;
#endif #endif
#endif #endif

View File

@ -26,10 +26,6 @@
#include "testHash.hpp" #include "testHash.hpp"
#include "testStdShared.hpp" #include "testStdShared.hpp"
#undef __class__
#define __class__ "etktest"
int main(int argc, const char *argv[]) { int main(int argc, const char *argv[]) {
// init Google test : // init Google test :
::testing::InitGoogleTest(&argc, const_cast<char **>(argv)); ::testing::InitGoogleTest(&argc, const_cast<char **>(argv));

View File

@ -10,9 +10,6 @@
#undef NAME #undef NAME
#define NAME "Archive" #define NAME "Archive"
#undef __class__
#define __class__ "etktest"
#ifdef ETK_BUILD_MINIZIP #ifdef ETK_BUILD_MINIZIP
TEST(TestEtkArchive, CreationWrong) { TEST(TestEtkArchive, CreationWrong) {

View File

@ -10,9 +10,6 @@
#undef NAME #undef NAME
#define NAME "Color" #define NAME "Color"
#undef __class__
#define __class__ "etktest"
TEST(TestEtkColor, RGBA8) { TEST(TestEtkColor, RGBA8) {
etk::Color<uint8_t, 4> colorRGBA8(0x52,0x0F, 0x65, 0x44); etk::Color<uint8_t, 4> colorRGBA8(0x52,0x0F, 0x65, 0x44);
EXPECT_EQ(colorRGBA8.r(), 0x52); EXPECT_EQ(colorRGBA8.r(), 0x52);

View File

@ -10,9 +10,6 @@
#undef NAME #undef NAME
#define NAME "FSNode" #define NAME "FSNode"
#undef __class__
#define __class__ "etktest"
TEST(TestEtkFSNode, checkType) { TEST(TestEtkFSNode, checkType) {
std::string fileName("USERDATA:myFileTest.txt"); std::string fileName("USERDATA:myFileTest.txt");
etk::FSNode myNodeTest1(fileName); etk::FSNode myNodeTest1(fileName);

View File

@ -11,9 +11,6 @@
#undef NAME #undef NAME
#define NAME "Hash" #define NAME "Hash"
#undef __class__
#define __class__ "etktest"
TEST(TestEtkHash, Creation) { TEST(TestEtkHash, Creation) {
etk::Hash<std::string> testData; etk::Hash<std::string> testData;
EXPECT_EQ(testData.size(), 0); EXPECT_EQ(testData.size(), 0);

View File

@ -11,9 +11,6 @@
#undef NAME #undef NAME
#define NAME "Shared_ptr" #define NAME "Shared_ptr"
#undef __class__
#define __class__ "etktest"
class Example : public std::enable_shared_from_this<Example> { class Example : public std::enable_shared_from_this<Example> {
protected: protected:
int32_t m_id; int32_t m_id;