Browse Source

Moved Set utility class to Corrade, since it's now C++11 enabled.

vectorfields
Vladimír Vondruš 14 years ago
parent
commit
b30d1d96c5
  1. 7
      src/Framebuffer.h
  2. 113
      src/Set.h
  3. 4
      src/Trade/AbstractImporter.h

7
src/Framebuffer.h

@ -19,11 +19,12 @@
* @brief Class Magnum::Framebuffer
*/
#include <Utility/Set.h>
#include "BufferedImage.h"
#include "CubeMapTexture.h"
#include "Image.h"
#include "Renderbuffer.h"
#include "Set.h"
namespace Magnum {
@ -75,7 +76,7 @@ class MAGNUM_EXPORT Framebuffer {
Stencil = GL_STENCIL_BUFFER_BIT /**< Stencil value */
};
typedef Set<Clear, GLbitfield> ClearMask; /**< @brief Mask for clearing */
typedef Corrade::Utility::Set<Clear, GLbitfield> ClearMask; /**< @brief Mask for clearing */
/**
* @brief %Framebuffer target
@ -181,7 +182,7 @@ class MAGNUM_EXPORT Framebuffer {
* @brief Output mask for blitting
* @requires_gl30 Extension @extension{EXT,framebuffer_object}
*/
typedef Set<Blit, GLbitfield> BlitMask;
typedef Corrade::Utility::Set<Blit, GLbitfield> BlitMask;
/** @brief Set feature */
static void setFeature(Feature feature, bool enabled);

113
src/Set.h

@ -1,113 +0,0 @@
#ifndef Magnum_Set_h
#define Magnum_Set_h
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
This file is part of Magnum.
Magnum is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 3
only, as published by the Free Software Foundation.
Magnum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License version 3 for more details.
*/
/** @file
* @brief Class Magnum::Set
*/
namespace Magnum {
/** @ingroup utility
@brief %Set
@tparam T Enum type
@tparam U Underlying type of the enum
Provides strongly-typed set-like functionality for strongly typed enums, such
as binary OR and AND operations. The only requirement for enum type is that
all the values must be binary exclusive.
Desired usage is via typedef'ing and then calling SET_OPERATORS() macro with
the resulting type as parameter to have all the operators implemented.
@code
enum class State: unsigned char {
Ready = 0x01,
Waiting = 0x02,
Done = 0x04
};
typedef Set<State, unsigned char> States;
SET_OPERATORS(States)
@endcode
*/
template<class T, class U> class Set {
public:
typedef T Type; /**< @brief Enum type */
typedef U UnderlyingType; /**< @brief Underlying type of the enum */
/** @brief Create empty set */
inline constexpr Set(): value() {}
/** @brief Create set from one value */
inline constexpr Set(T value): value(static_cast<UnderlyingType>(value)) {}
/** @brief Union of two sets */
inline constexpr Set<T, U> operator|(Set<T, U> other) const {
return Set<T, U>(value | other.value);
}
/** @brief Union two sets and assign */
inline Set<T, U>& operator|=(Set<T, U> other) {
value |= other.value;
return *this;
}
/** @brief Intersection of two sets */
inline constexpr Set<T, U> operator&(Set<T, U> other) const {
return Set<T, U>(value & other.value);
}
/** @brief Intersect two sets and assign */
inline Set<T, U>& operator&=(Set<T, U> other) {
value &= other.value;
return *this;
}
/** @brief Set complement */
inline constexpr Set<T, U> operator~() const {
return Set<T, U>(~value);
}
/** @brief Value as boolean */
inline constexpr explicit operator bool() const {
return value == 0;
}
/** @brief Value in underlying type */
inline constexpr explicit operator UnderlyingType() const {
return value;
}
private:
inline constexpr explicit Set(UnderlyingType type): value(type) {}
UnderlyingType value;
};
/** @hideinitializer
@brief Define out-of-class operators for given Set implementation
*/
#define SET_OPERATORS(class) \
inline constexpr class operator|(class::Type a, class b) { \
return b | a; \
} \
inline constexpr class operator&(class::Type a, class b) { \
return b & a; \
}
}
#endif

4
src/Trade/AbstractImporter.h

@ -19,10 +19,10 @@
* @brief Class Magnum::Trade::AbstractImporter
*/
#include <Utility/Set.h>
#include <PluginManager/Plugin.h>
#include "ImageData.h"
#include "Set.h"
namespace Magnum { namespace Trade {
@ -65,7 +65,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin {
};
/** @brief Set of features supported by this importer */
typedef Set<Feature, int> Features;
typedef Corrade::Utility::Set<Feature, int> Features;
/** @brief Constructor */
inline AbstractImporter(Corrade::PluginManager::AbstractPluginManager* manager = nullptr, const std::string& plugin = ""): Plugin(manager, plugin) {}

Loading…
Cancel
Save