Browse Source

Deleted constructors of classes with only static members.

They shouldn't be instantiated, prevent mistakes with this.
pull/7/head
Vladimír Vondruš 14 years ago
parent
commit
3b37dfa6b8
  1. 2
      src/DebugMarker.h
  2. 16
      src/DimensionTraits.h
  3. 2
      src/Math/Algorithms/GaussJordan.h
  4. 6
      src/Math/Constants.h
  5. 2
      src/Math/Geometry/Distance.h
  6. 2
      src/Math/Geometry/Intersection.h
  7. 6
      src/Math/MathTypeTraits.h
  8. 2
      src/Math/RectangularMatrix.h
  9. 2
      src/Mesh.h
  10. 2
      src/Platform/ExtensionWrangler.h
  11. 4
      src/Renderer.h
  12. 17
      src/SizeTraits.h
  13. 54
      src/TypeTraits.h

2
src/DebugMarker.h

@ -41,6 +41,8 @@ class MAGNUM_EXPORT DebugMarker {
friend class Context; friend class Context;
public: public:
DebugMarker() = delete;
/** @brief Put string mark into OpenGL command stream */ /** @brief Put string mark into OpenGL command stream */
inline static void mark(const std::string& string) { inline static void mark(const std::string& string) {
markImplementation(string); markImplementation(string);

16
src/DimensionTraits.h

@ -37,6 +37,8 @@ namespace Math {
/** @brief Matrix, point and vector specializations for given dimension count */ /** @brief Matrix, point and vector specializations for given dimension count */
template<std::uint8_t dimensions, class T = GLfloat> struct DimensionTraits { template<std::uint8_t dimensions, class T = GLfloat> struct DimensionTraits {
DimensionTraits() = delete;
#ifdef DOXYGEN_GENERATING_OUTPUT #ifdef DOXYGEN_GENERATING_OUTPUT
/** /**
* @brief Vector type * @brief Vector type
@ -66,21 +68,29 @@ template<std::uint8_t dimensions, class T = GLfloat> struct DimensionTraits {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
/* One dimension */ /* One dimension */
template<class T> struct DimensionTraits<1, T> { template<class T> struct DimensionTraits<1, T> {
DimensionTraits() = delete;
typedef Math::Vector<1, T> VectorType; typedef Math::Vector<1, T> VectorType;
}; };
/* Two dimensions - integral */ /* Two dimensions - integral */
template<class T> struct DimensionTraits<2, T> { template<class T> struct DimensionTraits<2, T> {
DimensionTraits() = delete;
typedef Math::Vector2<T> VectorType; typedef Math::Vector2<T> VectorType;
}; };
/* Two dimensions - floating-point */ /* Two dimensions - floating-point */
template<> struct DimensionTraits<2, float> { template<> struct DimensionTraits<2, float> {
DimensionTraits() = delete;
typedef Math::Vector2<float> VectorType; typedef Math::Vector2<float> VectorType;
typedef Math::Point2D<float> PointType; typedef Math::Point2D<float> PointType;
typedef Math::Matrix3<float> MatrixType; typedef Math::Matrix3<float> MatrixType;
}; };
template<> struct DimensionTraits<2, double> { template<> struct DimensionTraits<2, double> {
DimensionTraits() = delete;
typedef Math::Vector2<double> VectorType; typedef Math::Vector2<double> VectorType;
typedef Math::Point2D<double> PointType; typedef Math::Point2D<double> PointType;
typedef Math::Matrix3<double> MatrixType; typedef Math::Matrix3<double> MatrixType;
@ -88,16 +98,22 @@ template<> struct DimensionTraits<2, double> {
/* Three dimensions - integral */ /* Three dimensions - integral */
template<class T> struct DimensionTraits<3, T> { template<class T> struct DimensionTraits<3, T> {
DimensionTraits() = delete;
typedef Math::Vector3<T> VectorType; typedef Math::Vector3<T> VectorType;
}; };
/* Three dimensions - floating-point */ /* Three dimensions - floating-point */
template<> struct DimensionTraits<3, float> { template<> struct DimensionTraits<3, float> {
DimensionTraits() = delete;
typedef Math::Vector3<float> VectorType; typedef Math::Vector3<float> VectorType;
typedef Math::Point3D<float> PointType; typedef Math::Point3D<float> PointType;
typedef Math::Matrix4<float> MatrixType; typedef Math::Matrix4<float> MatrixType;
}; };
template<> struct DimensionTraits<3, double> { template<> struct DimensionTraits<3, double> {
DimensionTraits() = delete;
typedef Math::Vector3<double> VectorType; typedef Math::Vector3<double> VectorType;
typedef Math::Point3D<double> PointType; typedef Math::Point3D<double> PointType;
typedef Math::Matrix4<double> MatrixType; typedef Math::Matrix4<double> MatrixType;

2
src/Math/Algorithms/GaussJordan.h

@ -31,6 +31,8 @@ http://elonen.iki.fi/code/misc-notes/python-gaussj/index.html.
*/ */
class GaussJordan { class GaussJordan {
public: public:
GaussJordan() = delete;
/** /**
* @brief Eliminate transposed matrices in place * @brief Eliminate transposed matrices in place
* @param a Transposed left side of augmented matrix * @param a Transposed left side of augmented matrix

6
src/Math/Constants.h

@ -27,6 +27,8 @@ namespace Magnum { namespace Math {
@see Magnum::Constants @see Magnum::Constants
*/ */
template<class T> struct Constants { template<class T> struct Constants {
Constants() = delete;
/* See MathTypeTraits for answer why these are functions and not constants. */ /* See MathTypeTraits for answer why these are functions and not constants. */
#ifdef DOXYGEN_GENERATING_OUTPUT #ifdef DOXYGEN_GENERATING_OUTPUT
/** /**
@ -43,11 +45,15 @@ template<class T> struct Constants {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template<> struct Constants<double> { template<> struct Constants<double> {
Constants() = delete;
static inline constexpr double pi() { return 3.141592653589793; } static inline constexpr double pi() { return 3.141592653589793; }
static inline constexpr double sqrt2() { return 1.414213562373095; } static inline constexpr double sqrt2() { return 1.414213562373095; }
static inline constexpr double sqrt3() { return 1.732050807568877; } static inline constexpr double sqrt3() { return 1.732050807568877; }
}; };
template<> struct Constants<float> { template<> struct Constants<float> {
Constants() = delete;
static inline constexpr float pi() { return 3.141592654f; } static inline constexpr float pi() { return 3.141592654f; }
static inline constexpr float sqrt2() { return 1.414213562f; } static inline constexpr float sqrt2() { return 1.414213562f; }
static inline constexpr float sqrt3() { return 1.732050808f; } static inline constexpr float sqrt3() { return 1.732050808f; }

2
src/Math/Geometry/Distance.h

@ -28,6 +28,8 @@ namespace Magnum { namespace Math { namespace Geometry {
/** @brief Functions for computing distances */ /** @brief Functions for computing distances */
class Distance { class Distance {
public: public:
Distance() = delete;
/** /**
* @brief %Distance of line and point in 2D * @brief %Distance of line and point in 2D
* @param a First point of the line * @param a First point of the line

2
src/Math/Geometry/Intersection.h

@ -26,6 +26,8 @@ namespace Magnum { namespace Math { namespace Geometry {
/** @brief Functions for computing intersections */ /** @brief Functions for computing intersections */
class Intersection { class Intersection {
public: public:
Intersection() = delete;
/** /**
* @brief %Intersection of a plane and line * @brief %Intersection of a plane and line
* @param planePosition Plane position * @param planePosition Plane position

6
src/Math/MathTypeTraits.h

@ -46,6 +46,8 @@ sense, it has empty implementation for unknown types or types which don't
support given feature, thus forcing the compilation stop with an error. support given feature, thus forcing the compilation stop with an error.
*/ */
template<class T> struct MathTypeTraits { template<class T> struct MathTypeTraits {
MathTypeTraits() = delete;
/* /*
* The following values are implemented as inline functions, not as * The following values are implemented as inline functions, not as
* static const variables, because the compiler will inline the return * static const variables, because the compiler will inline the return
@ -101,6 +103,8 @@ template<class T> struct MathTypeTraits {
namespace Implementation { namespace Implementation {
template<class T> struct MathTypeTraitsIntegral { template<class T> struct MathTypeTraitsIntegral {
MathTypeTraitsIntegral() = delete;
inline constexpr static T epsilon() { return 1; } inline constexpr static T epsilon() { return 1; }
inline constexpr static bool equals(T a, T b) { inline constexpr static bool equals(T a, T b) {
@ -109,6 +113,8 @@ template<class T> struct MathTypeTraitsIntegral {
}; };
template<class T> struct MathTypeTraitsFloatingPoint { template<class T> struct MathTypeTraitsFloatingPoint {
MathTypeTraitsFloatingPoint() = delete;
inline static bool equals(T a, T b) { inline static bool equals(T a, T b) {
return std::abs(a - b) < MathTypeTraits<T>::epsilon(); return std::abs(a - b) < MathTypeTraits<T>::epsilon();
} }

2
src/Math/RectangularMatrix.h

@ -517,6 +517,8 @@ namespace Corrade { namespace Utility {
/** @configurationvalue{Magnum::Math::RectangularMatrix} */ /** @configurationvalue{Magnum::Math::RectangularMatrix} */
template<std::size_t cols, std::size_t rows, class T> struct ConfigurationValue<Magnum::Math::RectangularMatrix<cols, rows, T>> { template<std::size_t cols, std::size_t rows, class T> struct ConfigurationValue<Magnum::Math::RectangularMatrix<cols, rows, T>> {
ConfigurationValue() = delete;
/** @brief Writes elements separated with spaces */ /** @brief Writes elements separated with spaces */
static std::string toString(const Magnum::Math::RectangularMatrix<cols, rows, T>& value, ConfigurationValueFlags flags) { static std::string toString(const Magnum::Math::RectangularMatrix<cols, rows, T>& value, ConfigurationValueFlags flags) {
std::string output; std::string output;

2
src/Mesh.h

@ -754,6 +754,8 @@ namespace Corrade { namespace Utility {
/** @configurationvalue{Magnum::Mesh} */ /** @configurationvalue{Magnum::Mesh} */
template<> struct MAGNUM_EXPORT ConfigurationValue<Magnum::Mesh::Primitive> { template<> struct MAGNUM_EXPORT ConfigurationValue<Magnum::Mesh::Primitive> {
ConfigurationValue() = delete;
/** /**
* @brief Writes enum value as string * @brief Writes enum value as string
* *

2
src/Platform/ExtensionWrangler.h

@ -24,6 +24,8 @@ namespace Magnum { namespace Platform {
/** @brief %Extension wrangler interface */ /** @brief %Extension wrangler interface */
class ExtensionWrangler { class ExtensionWrangler {
public: public:
ExtensionWrangler() = delete;
/** @brief Whether to enable or disable experimental features */ /** @brief Whether to enable or disable experimental features */
enum class ExperimentalFeatures { enum class ExperimentalFeatures {
Disable, Disable,

4
src/Renderer.h

@ -36,9 +36,9 @@ Access to global renderer configuration.
@todo @extension{ARB,viewport_array} @todo @extension{ARB,viewport_array}
*/ */
class MAGNUM_EXPORT Renderer { class MAGNUM_EXPORT Renderer {
Renderer() = delete;
public: public:
Renderer() = delete;
/** /**
* @brief Affected polygon facing for culling, stencil operations and masks * @brief Affected polygon facing for culling, stencil operations and masks
* *

17
src/SizeTraits.h

@ -51,20 +51,26 @@ template<std::size_t byte> struct SizeTraits {
typedef T SizeType; typedef T SizeType;
}; };
#else #else
template<std::size_t byte> struct SizeTraits: public SizeTraits<byte - 1> {}; template<std::size_t byte> struct SizeTraits: public SizeTraits<byte - 1> {
SizeTraits() = delete;
};
#endif #endif
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template<> struct SizeTraits<0> { template<> struct SizeTraits<0> {
SizeTraits() = delete;
typedef GLubyte SizeType; typedef GLubyte SizeType;
}; };
template<> struct SizeTraits<1> { template<> struct SizeTraits<1> {
SizeTraits() = delete;
typedef GLushort SizeType; typedef GLushort SizeType;
}; };
template<> struct SizeTraits<2> { template<> struct SizeTraits<2> {
SizeTraits() = delete;
typedef GLuint SizeType; typedef GLuint SizeType;
}; };
template<> struct SizeTraits<4> { template<> struct SizeTraits<4> {
SizeTraits() = delete;
/* We don't have size type to store 2^32 values */ /* We don't have size type to store 2^32 values */
}; };
#endif #endif
@ -146,6 +152,8 @@ Useful mainly for computing template parameter value, e.g. in conjunction with
SizeTraits class. SizeTraits class.
*/ */
template<std::uint32_t base, std::uint32_t exponent> struct Pow { template<std::uint32_t base, std::uint32_t exponent> struct Pow {
Pow() = delete;
/** @brief Value of the power */ /** @brief Value of the power */
enum: std::uint32_t { enum: std::uint32_t {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
@ -158,6 +166,8 @@ template<std::uint32_t base, std::uint32_t exponent> struct Pow {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template<std::uint32_t base> struct Pow<base, 0> { template<std::uint32_t base> struct Pow<base, 0> {
Pow() = delete;
enum: std::uint32_t { value = 1 }; enum: std::uint32_t { value = 1 };
}; };
#endif #endif
@ -171,6 +181,8 @@ Useful mainly for computing template parameter value, e.g. in conjunction with
SizeTraits class. SizeTraits class.
*/ */
template<std::uint32_t base, std::uint32_t number> struct Log { template<std::uint32_t base, std::uint32_t number> struct Log {
Log() = delete;
/** @brief Value of the logarithm */ /** @brief Value of the logarithm */
enum: std::uint32_t { enum: std::uint32_t {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
@ -182,10 +194,11 @@ template<std::uint32_t base, std::uint32_t number> struct Log {
}; };
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template<std::uint32_t base> struct Log<base, 1>: public Log<base, 0> {};
template<std::uint32_t base> struct Log<base, 0> { template<std::uint32_t base> struct Log<base, 0> {
Log() = delete;
enum: std::uint32_t { value = 0 }; enum: std::uint32_t { value = 0 };
}; };
template<std::uint32_t base> struct Log<base, 1>: public Log<base, 0> {};
#endif #endif
} }

54
src/TypeTraits.h

@ -86,7 +86,9 @@ template<class T> struct TypeTraits: Math::MathTypeTraits<T> {
inline constexpr static std::size_t count(); inline constexpr static std::size_t count();
}; };
#else #else
template<class T> struct TypeTraits {}; template<class T> struct TypeTraits {
TypeTraits() = delete;
};
#endif #endif
/** @brief OpenGL plain types */ /** @brief OpenGL plain types */
@ -124,6 +126,8 @@ type = TypeTraits<GLubyte>::imageType();
@endcode @endcode
*/ */
template<Type T> class TypeOf { template<Type T> class TypeOf {
TypeOf() = delete;
#ifdef DOXYGEN_GENERATING_OUTPUT #ifdef DOXYGEN_GENERATING_OUTPUT
typedef U Type; /**< @brief Type */ typedef U Type; /**< @brief Type */
#endif #endif
@ -137,6 +141,8 @@ time, this class alows to get some information also at runtime with tiny
performance loss. performance loss.
*/ */
struct MAGNUM_EXPORT TypeInfo { struct MAGNUM_EXPORT TypeInfo {
TypeInfo() = delete;
/** /**
* @brief Size of given type * @brief Size of given type
* *
@ -160,15 +166,39 @@ struct MAGNUM_EXPORT TypeInfo {
/** @todo Using Vector3 for textures? */ /** @todo Using Vector3 for textures? */
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template<> struct TypeOf<Type::UnsignedByte> { typedef GLubyte Type; }; template<> struct TypeOf<Type::UnsignedByte> {
template<> struct TypeOf<Type::Byte> { typedef GLbyte Type; }; TypeOf() = delete;
template<> struct TypeOf<Type::UnsignedShort> { typedef GLushort Type; }; typedef GLubyte Type;
template<> struct TypeOf<Type::Short> { typedef GLshort Type; }; };
template<> struct TypeOf<Type::UnsignedInt> { typedef GLuint Type; }; template<> struct TypeOf<Type::Byte> {
template<> struct TypeOf<Type::Int> { typedef GLint Type; }; TypeOf() = delete;
template<> struct TypeOf<Type::Float> { typedef GLfloat Type; }; typedef GLbyte Type;
};
template<> struct TypeOf<Type::UnsignedShort> {
TypeOf() = delete;
typedef GLushort Type;
};
template<> struct TypeOf<Type::Short> {
TypeOf() = delete;
typedef GLshort Type;
};
template<> struct TypeOf<Type::UnsignedInt> {
TypeOf() = delete;
typedef GLuint Type;
};
template<> struct TypeOf<Type::Int> {
TypeOf() = delete;
typedef GLint Type;
};
template<> struct TypeOf<Type::Float> {
TypeOf() = delete;
typedef GLfloat Type;
};
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
template<> struct TypeOf<Type::Double> { typedef GLdouble Type; }; template<> struct TypeOf<Type::Double> {
TypeOf() = delete;
typedef GLdouble Type;
};
#endif #endif
template<> struct TypeTraits<GLubyte>: Math::MathTypeTraits<std::uint8_t> { template<> struct TypeTraits<GLubyte>: Math::MathTypeTraits<std::uint8_t> {
@ -239,6 +269,8 @@ template<> struct TypeTraits<GLdouble>: Math::MathTypeTraits<double> {
namespace Implementation { namespace Implementation {
template<std::size_t vectorSize, class T> struct VectorTypeTraits { template<std::size_t vectorSize, class T> struct VectorTypeTraits {
VectorTypeTraits() = delete;
/* Might be used for attributes, see below */ /* Might be used for attributes, see below */
inline constexpr static Type type() { return TypeTraits<T>::type(); } inline constexpr static Type type() { return TypeTraits<T>::type(); }
/* Might be used for attributes, see below */ /* Might be used for attributes, see below */
@ -286,6 +318,8 @@ template<class T> struct TypeTraits<Color4<T>>: TypeTraits<Math::Vector<4, T>> {
namespace Implementation { namespace Implementation {
template<std::size_t cols, std::size_t rows, class T> struct MatrixTypeTraits { template<std::size_t cols, std::size_t rows, class T> struct MatrixTypeTraits {
MatrixTypeTraits() = delete;
inline constexpr static Type type() { return TypeTraits<T>::type(); } inline constexpr static Type type() { return TypeTraits<T>::type(); }
/* Might be used for attributes, see below */ /* Might be used for attributes, see below */
/* Can not be used for indices */ /* Can not be used for indices */
@ -332,6 +366,8 @@ namespace Corrade { namespace Utility {
/** @configurationvalue{Magnum::TypeInfo} */ /** @configurationvalue{Magnum::TypeInfo} */
template<> struct MAGNUM_EXPORT ConfigurationValue<Magnum::Type> { template<> struct MAGNUM_EXPORT ConfigurationValue<Magnum::Type> {
ConfigurationValue() = delete;
/** /**
* @brief Writes enum value as string * @brief Writes enum value as string
* *

Loading…
Cancel
Save