Browse Source

Trade: using signed/unsigned int instead of size_t for IDs.

Some functions need to return "invalid ID", which in case of size_t
cannot be -1.

Also the plugins should behave the same in 32/64bit systems, so the type
should be the same for both.
pull/279/head
Vladimír Vondruš 14 years ago
parent
commit
d5d0e49536
  1. 44
      src/Trade/AbstractImporter.h
  2. 18
      src/Trade/MeshData.h
  3. 6
      src/Trade/MeshObjectData.h
  4. 10
      src/Trade/ObjectData.h
  5. 6
      src/Trade/SceneData.h

44
src/Trade/AbstractImporter.h

@ -100,15 +100,15 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin {
* @brief Default scene * @brief Default scene
* *
* When there is more than one scene, returns ID of the default one. * When there is more than one scene, returns ID of the default one.
* Note that this function returns 0 even if there are no scenes. * If there is no default scene, returns -1.
* *
* @note The function is not const, because the value will probably * @note The function is not const, because the value will probably
* be lazy-populated. * be lazy-populated.
*/ */
virtual inline size_t defaultScene() { return 0; } virtual inline int defaultScene() { return -1; }
/** @brief %Scene count */ /** @brief %Scene count */
virtual inline size_t sceneCount() const { return 0; } virtual inline unsigned int sceneCount() const { return 0; }
/** /**
* @brief %Scene * @brief %Scene
@ -116,10 +116,10 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin {
* *
* Returns pointer to given scene or nullptr, if no such scene exists. * Returns pointer to given scene or nullptr, if no such scene exists.
*/ */
virtual inline SceneData* scene(size_t id) { return nullptr; } virtual inline SceneData* scene(unsigned int id) { return nullptr; }
/** @brief %Light count */ /** @brief %Light count */
virtual inline size_t lightCount() const { return 0; } virtual inline unsigned int lightCount() const { return 0; }
/** /**
* @brief %Light * @brief %Light
@ -127,10 +127,10 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin {
* *
* Returns pointer to given light or nullptr, if no such light exists. * Returns pointer to given light or nullptr, if no such light exists.
*/ */
virtual inline LightData* light(size_t id) { return nullptr; } virtual inline LightData* light(unsigned int id) { return nullptr; }
/** @brief %Camera count */ /** @brief %Camera count */
virtual inline size_t cameraCount() const { return 0; } virtual inline unsigned int cameraCount() const { return 0; }
/** /**
* @brief %Camera * @brief %Camera
@ -139,10 +139,10 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin {
* Returns pointer to given camera or nullptr, if no such camera * Returns pointer to given camera or nullptr, if no such camera
* exists. * exists.
*/ */
virtual inline CameraData* camera(size_t id) { return nullptr; } virtual inline CameraData* camera(unsigned int id) { return nullptr; }
/** @brief %Object count */ /** @brief %Object count */
virtual inline size_t objectCount() const { return 0; } virtual inline unsigned int objectCount() const { return 0; }
/** /**
* @brief %Object * @brief %Object
@ -151,10 +151,10 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin {
* Returns pointer to given object or nullptr, if no such object * Returns pointer to given object or nullptr, if no such object
* exists. * exists.
*/ */
virtual inline ObjectData* object(size_t id) { return nullptr; } virtual inline ObjectData* object(unsigned int id) { return nullptr; }
/** @brief %Mesh count */ /** @brief %Mesh count */
virtual inline size_t meshCount() const { return 0; } virtual inline unsigned int meshCount() const { return 0; }
/** /**
* @brief %Mesh * @brief %Mesh
@ -162,10 +162,10 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin {
* *
* Returns pointer to given mesh or nullptr, if no such mesh exists. * Returns pointer to given mesh or nullptr, if no such mesh exists.
*/ */
virtual inline MeshData* mesh(size_t id) { return nullptr; } virtual inline MeshData* mesh(unsigned int id) { return nullptr; }
/** @brief Material count */ /** @brief Material count */
virtual inline size_t materialCount() const { return 0; } virtual inline unsigned int materialCount() const { return 0; }
/** /**
* @brief Material * @brief Material
@ -174,10 +174,10 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin {
* Returns pointer to given material or nullptr, if no such material * Returns pointer to given material or nullptr, if no such material
* exists. * exists.
*/ */
virtual inline AbstractMaterialData* material(size_t id) { return nullptr; } virtual inline AbstractMaterialData* material(unsigned int id) { return nullptr; }
/** @brief %Texture count */ /** @brief %Texture count */
virtual inline size_t textureCount() const { return 0; } virtual inline unsigned int textureCount() const { return 0; }
/** /**
* @brief %Texture * @brief %Texture
@ -186,10 +186,10 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin {
* Returns pointer to given texture or nullptr, if no such texture * Returns pointer to given texture or nullptr, if no such texture
* exists. * exists.
*/ */
virtual inline TextureData* texture(size_t id) { return nullptr; } virtual inline TextureData* texture(unsigned int id) { return nullptr; }
/** @brief One-dimensional image count */ /** @brief One-dimensional image count */
virtual inline size_t image1DCount() const { return 0; } virtual inline unsigned int image1DCount() const { return 0; }
/** /**
* @brief One-dimensional image * @brief One-dimensional image
@ -197,10 +197,10 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin {
* *
* Returns pointer to given image or nullptr, if no such image exists. * Returns pointer to given image or nullptr, if no such image exists.
*/ */
virtual inline ImageData1D* image1D(size_t id) { return nullptr; } virtual inline ImageData1D* image1D(unsigned int id) { return nullptr; }
/** @brief Two-dimensional image count */ /** @brief Two-dimensional image count */
virtual inline size_t image2DCount() const { return 0; } virtual inline unsigned int image2DCount() const { return 0; }
/** /**
* @brief Two-dimensional image * @brief Two-dimensional image
@ -208,10 +208,10 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin {
* *
* Returns pointer to given image or nullptr, if no such image exists. * Returns pointer to given image or nullptr, if no such image exists.
*/ */
virtual inline ImageData2D* image2D(size_t id) { return nullptr; } virtual inline ImageData2D* image2D(unsigned int id) { return nullptr; }
/** @brief Three-dimensional image count */ /** @brief Three-dimensional image count */
virtual inline size_t image3DCount() const { return 0; } virtual inline unsigned int image3DCount() const { return 0; }
/** /**
* @brief Three-dimensional image * @brief Three-dimensional image
@ -219,7 +219,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin {
* *
* Returns pointer to given image or nullptr, if no such image exists. * Returns pointer to given image or nullptr, if no such image exists.
*/ */
virtual inline ImageData3D* image3D(size_t id) { return nullptr; } virtual inline ImageData3D* image3D(unsigned int id) { return nullptr; }
/*@}*/ /*@}*/
}; };

18
src/Trade/MeshData.h

@ -63,7 +63,7 @@ class MAGNUM_EXPORT MeshData {
inline const std::vector<unsigned int>* indices() const { return _indices; } /**< @overload */ inline const std::vector<unsigned int>* indices() const { return _indices; } /**< @overload */
/** @brief Count of vertex arrays */ /** @brief Count of vertex arrays */
inline size_t vertexArrayCount() const { return _vertices.size(); } inline unsigned int vertexArrayCount() const { return _vertices.size(); }
/** /**
* @brief Vertices * @brief Vertices
@ -71,11 +71,11 @@ class MAGNUM_EXPORT MeshData {
* @return Vertices or nullptr if there is no vertex array with given * @return Vertices or nullptr if there is no vertex array with given
* ID. * ID.
*/ */
inline std::vector<Vector4>* vertices(size_t id) { return _vertices[id]; } inline std::vector<Vector4>* vertices(unsigned int id) { return _vertices[id]; }
inline const std::vector<Vector4>* vertices(size_t id) const { return _vertices[id]; } /**< @overload */ inline const std::vector<Vector4>* vertices(unsigned int id) const { return _vertices[id]; } /**< @overload */
/** @brief Count of normal arrays */ /** @brief Count of normal arrays */
inline size_t normalArrayCount() const { return _normals.size(); } inline unsigned int normalArrayCount() const { return _normals.size(); }
/** /**
* @brief Normals * @brief Normals
@ -83,11 +83,11 @@ class MAGNUM_EXPORT MeshData {
* @return Vertices or nullptr if there is no normal array with given * @return Vertices or nullptr if there is no normal array with given
* ID. * ID.
*/ */
inline std::vector<Vector3>* normals(size_t id) { return _normals[id]; } inline std::vector<Vector3>* normals(unsigned int id) { return _normals[id]; }
inline const std::vector<Vector3>* normals(size_t id) const { return _normals[id]; } /**< @overload */ inline const std::vector<Vector3>* normals(unsigned int id) const { return _normals[id]; } /**< @overload */
/** @brief Count of 2D texture coordinate arrays */ /** @brief Count of 2D texture coordinate arrays */
inline size_t textureCoords2DArrayCount() const { return _textureCoords2D.size(); } inline unsigned int textureCoords2DArrayCount() const { return _textureCoords2D.size(); }
/** /**
* @brief 2D texture coordinates * @brief 2D texture coordinates
@ -95,8 +95,8 @@ class MAGNUM_EXPORT MeshData {
* @return %Texture coordinates or nullptr if there is no texture * @return %Texture coordinates or nullptr if there is no texture
* coordinates array with given ID. * coordinates array with given ID.
*/ */
inline std::vector<Vector2>* textureCoords2D(size_t id) { return _textureCoords2D[id]; } inline std::vector<Vector2>* textureCoords2D(unsigned int id) { return _textureCoords2D[id]; }
inline const std::vector<Vector2>* textureCoords2D(size_t id) const { return _textureCoords2D[id]; } /**< @overload */ inline const std::vector<Vector2>* textureCoords2D(unsigned int id) const { return _textureCoords2D[id]; } /**< @overload */
private: private:
Mesh::Primitive _primitive; Mesh::Primitive _primitive;

6
src/Trade/MeshObjectData.h

@ -44,13 +44,13 @@ class MeshObjectData: public ObjectData {
* *
* Creates object with mesh instance type. * Creates object with mesh instance type.
*/ */
inline MeshObjectData(std::vector<size_t> children, const Matrix4& transformation, size_t instance, size_t material): ObjectData(children, transformation, InstanceType::Mesh, instance), _material(material) {} inline MeshObjectData(std::vector<unsigned int> children, const Matrix4& transformation, unsigned int instance, unsigned int material): ObjectData(children, transformation, InstanceType::Mesh, instance), _material(material) {}
/** @brief Material ID */ /** @brief Material ID */
inline size_t material() const { return _material; } inline unsigned int material() const { return _material; }
private: private:
size_t _material; unsigned int _material;
}; };
}} }}

10
src/Trade/ObjectData.h

@ -50,13 +50,13 @@ class ObjectData {
* @param instanceType Instance type * @param instanceType Instance type
* @param instanceId Instance ID * @param instanceId Instance ID
*/ */
inline ObjectData(std::vector<size_t> children, const Matrix4& transformation, InstanceType instanceType, size_t instanceId): _children(children), _transformation(transformation), _instanceType(instanceType), _instanceId(instanceId) {} inline ObjectData(std::vector<unsigned int> children, const Matrix4& transformation, InstanceType instanceType, unsigned int instanceId): _children(children), _transformation(transformation), _instanceType(instanceType), _instanceId(instanceId) {}
/** @brief Destructor */ /** @brief Destructor */
inline virtual ~ObjectData() {} inline virtual ~ObjectData() {}
/** @brief Child objects */ /** @brief Child objects */
inline std::vector<size_t>& children() { return _children; } inline std::vector<unsigned int>& children() { return _children; }
/** @brief Transformation (relative to parent) */ /** @brief Transformation (relative to parent) */
inline Matrix4 transformation() const { return _transformation; } inline Matrix4 transformation() const { return _transformation; }
@ -75,13 +75,13 @@ class ObjectData {
* @return ID of given camera / light / mesh etc., specified by * @return ID of given camera / light / mesh etc., specified by
* instanceType() * instanceType()
*/ */
inline size_t instanceId() const { return _instanceId; } inline unsigned int instanceId() const { return _instanceId; }
private: private:
std::vector<size_t> _children; std::vector<unsigned int> _children;
Matrix4 _transformation; Matrix4 _transformation;
InstanceType _instanceType; InstanceType _instanceType;
size_t _instanceId; unsigned int _instanceId;
}; };
}} }}

6
src/Trade/SceneData.h

@ -37,13 +37,13 @@ class MAGNUM_EXPORT SceneData {
* @brief Constructor * @brief Constructor
* @param children Child objects * @param children Child objects
*/ */
inline SceneData(const std::vector<size_t>& children): _children(children) {} inline SceneData(const std::vector<unsigned int>& children): _children(children) {}
/** @brief Child objects */ /** @brief Child objects */
inline const std::vector<size_t>& children() const { return _children; } inline const std::vector<unsigned int>& children() const { return _children; }
private: private:
std::vector<size_t> _children; std::vector<unsigned int> _children;
}; };
}} }}

Loading…
Cancel
Save