Browse Source

Disable instantiation of all Abstract* classes.

For classes which already have pure virtual functions instantiation is
not allowed, but for other there needs to be at least one pure virtual
method: the destructor.

Pure virtual functions actually can have implementations, but they must
be called explicitly. Destructors are called explicitly, so for them it
works.
vectorfields
Vladimír Vondruš 14 years ago
parent
commit
83fd5df368
  1. 4
      src/AbstractImage.h
  2. 4
      src/AbstractShaderProgram.h
  3. 6
      src/AbstractTexture.h

4
src/AbstractImage.h

@ -216,7 +216,7 @@ class MAGNUM_EXPORT AbstractImage {
inline AbstractImage(Components components, ComponentType type): _components(components), _type(type) {}
/** @brief Destructor */
inline virtual ~AbstractImage() {}
virtual ~AbstractImage() = 0;
/** @brief Color components */
inline Components components() const { return _components; }
@ -229,6 +229,8 @@ class MAGNUM_EXPORT AbstractImage {
ComponentType _type; /**< @brief Data type */
};
inline AbstractImage::~AbstractImage() {}
}
#endif

4
src/AbstractShaderProgram.h

@ -121,7 +121,7 @@ class MAGNUM_EXPORT AbstractShaderProgram {
*
* Deletes associated OpenGL shader program.
*/
inline ~AbstractShaderProgram() { glDeleteProgram(program); }
virtual ~AbstractShaderProgram() = 0;
/**
* @brief Use shader
@ -300,6 +300,8 @@ class MAGNUM_EXPORT AbstractShaderProgram {
State state;
};
inline AbstractShaderProgram::~AbstractShaderProgram() { glDeleteProgram(program); }
}
#endif

6
src/AbstractTexture.h

@ -472,9 +472,7 @@ class MAGNUM_EXPORT AbstractTexture {
*
* Deletes assigned OpenGL texture.
*/
inline virtual ~AbstractTexture() {
glDeleteTextures(1, &texture);
}
virtual ~AbstractTexture() = 0;
/** @brief %Texture layer */
inline GLint layer() const { return _layer; }
@ -568,6 +566,8 @@ class MAGNUM_EXPORT AbstractTexture {
GLuint texture;
};
inline AbstractTexture::~AbstractTexture() { glDeleteTextures(1, &texture); }
/** @relates AbstractTexture
@brief Convertor of component count and data type to InternalFormat
*/

Loading…
Cancel
Save