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.
pull/279/head
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) {} inline AbstractImage(Components components, ComponentType type): _components(components), _type(type) {}
/** @brief Destructor */ /** @brief Destructor */
inline virtual ~AbstractImage() {} virtual ~AbstractImage() = 0;
/** @brief Color components */ /** @brief Color components */
inline Components components() const { return _components; } inline Components components() const { return _components; }
@ -229,6 +229,8 @@ class MAGNUM_EXPORT AbstractImage {
ComponentType _type; /**< @brief Data type */ ComponentType _type; /**< @brief Data type */
}; };
inline AbstractImage::~AbstractImage() {}
} }
#endif #endif

4
src/AbstractShaderProgram.h

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

6
src/AbstractTexture.h

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

Loading…
Cancel
Save