Hi everybody !
I wonder if the QMap class is efficient enough in case of frequent access to the members it references ... let me give more details.
I have a class called COpenGlTexture which is designed as follow :
class COpenGlTexture
{
public:
COpenGlTexture();
COpenGlTexture(const COpenGlTexture&);
~COpenGlTexture();
COpenGlTexture& operator=(const COpenGlTexture&);
void CreateTexture(const QString& textureName);
void DeleteTexture();
bool IsCreated() const { return m_bIsTextureCreated; }
GLuint Texture() const { return m_nTexture; }
private:
void CopyFrom(const COpenGlTexture&);
private:
bool m_bIsTextureCreated;
GLuint m_nTexture;
};
class COpenGlTexture
{
public:
COpenGlTexture();
COpenGlTexture(const COpenGlTexture&);
~COpenGlTexture();
COpenGlTexture& operator=(const COpenGlTexture&);
void CreateTexture(const QString& textureName);
void DeleteTexture();
bool IsCreated() const { return m_bIsTextureCreated; }
GLuint Texture() const { return m_nTexture; }
private:
void CopyFrom(const COpenGlTexture&);
private:
bool m_bIsTextureCreated;
GLuint m_nTexture;
};
To copy to clipboard, switch view to plain text mode
As my application must display some data, using a specific texture for each data types (a data type is defined in one of my enumeration) I thought to do like this :
// Part of application header's file
public:
enum DataType {Type1=0, Type2};
private:
typedef QMap<DataType, COpenGlTexture> OpenGlTextureMap;
OpenGlTextureMap m_Textures;
// Part of application header's file
public:
enum DataType {Type1=0, Type2};
private:
typedef QMap<DataType, COpenGlTexture> OpenGlTextureMap;
OpenGlTextureMap m_Textures;
To copy to clipboard, switch view to plain text mode
What I can also tell is that I want my application to handle many kind of data types, it will just be necessary to add a type in the private enumeration and update the paintEvent function to handle the new type.
It seems (to me) to be good way to handle my datas but I wonder (here we go again) if the use of a QMap will give me good performances as I will have to access my map object value each time (each 100ms) I need to redraw my datas and then consuming some time(perhaps useless) calling to the constructor and affectation operator of my class.
Finally, here are my questions :
* is it a good way to handle my datas ?
* is there any other way to do the same thing ?
* is QMap efficient enough to access each 100 ms each map object value ?
* for the moment I just have to handle 2 data types but in a close futur I may have to handle 3, 4 or much more data types ... same question as previous
Thanks in advance.
Bookmarks