From 944ede8587b967827a9ff9e652914aa70b46b854 Mon Sep 17 00:00:00 2001 From: Alexandre Quessy Date: Tue, 26 Nov 2013 22:25:11 -0500 Subject: [PATCH] Add typedefs for std::tr1::shared_ptr<*> --- Common.h | 16 ++++++++++------ Mapper.cpp | 1 + Mapper.h | 26 ++++++++++++-------------- Paint.h | 4 ++-- Shape.h | 6 +++++- 5 files changed, 30 insertions(+), 23 deletions(-) diff --git a/Common.h b/Common.h index ab7fe26..440909e 100644 --- a/Common.h +++ b/Common.h @@ -27,12 +27,13 @@ #include "Shape.h" #include "Mapper.h" -class Common { +class Common +{ public: - static std::vector< std::tr1::shared_ptr > mappings; - static std::vector< std::tr1::shared_ptr > mappers; - static std::tr1::shared_ptr currentMapping; - static std::tr1::shared_ptr currentMapper; + static std::vector mappings; + static std::vector mappers; + static Mapping::ptr currentMapping; + static Mapper::ptr currentMapper; static int currentSourceIdx; @@ -41,7 +42,10 @@ public: static void initializeLibremapper(int frameWidth, int frameHeight); static void nextImage(); - static int nImages() { return mappings.size(); } + static int nImages() + { + return mappings.size(); + } }; #endif /* COMMON_H_ */ diff --git a/Mapper.cpp b/Mapper.cpp index 63dc97c..3c55e6f 100644 --- a/Mapper.cpp +++ b/Mapper.cpp @@ -21,6 +21,7 @@ void QuadTextureMapper::draw() { + // FIXME: use typedefs, member of the class for type names that are too long to type: std::tr1::shared_ptr textureMapping = std::tr1::static_pointer_cast(_mapping); Q_CHECK_PTR(textureMapping); diff --git a/Mapper.h b/Mapper.h index e571fb2..02ec5d2 100644 --- a/Mapper.h +++ b/Mapper.h @@ -22,26 +22,23 @@ #define MAPPER_H_ #include - -#include "Shape.h" -#include "Paint.h" - -#include "Util.h" - #include - #include #include #include #include +#include "Shape.h" +#include "Paint.h" +#include "Util.h" class Mapping { protected: - std::tr1::shared_ptr _paint; - std::tr1::shared_ptr _shape; + Paint::ptr _paint; + Shape::ptr _shape; public: + typedef std::tr1::shared_ptr ptr; Mapping(Paint* paint, Shape* shape) : _paint(paint), _shape(shape) {} @@ -52,14 +49,14 @@ public: } public: - std::tr1::shared_ptr getPaint() const { return _paint; } - std::tr1::shared_ptr getShape() const { return _shape; } + Paint::ptr getPaint() const { return _paint; } + Shape::ptr getShape() const { return _shape; } }; class TextureMapping : public Mapping { private: - std::tr1::shared_ptr _inputShape; + Shape::ptr _inputShape; public: TextureMapping(Paint* paint, @@ -74,17 +71,18 @@ public: _inputShape->build(); } public: - std::tr1::shared_ptr getInputShape() const { return _inputShape; } + Shape::ptr getInputShape() const { return _inputShape; } }; class Mapper { protected: - std::tr1::shared_ptr _mapping; + Mapping::ptr _mapping; Mapper(Mapping* mapping) : _mapping(mapping) {} virtual ~Mapper() {} public: + typedef std::tr1::shared_ptr ptr; virtual void draw() = 0; }; diff --git a/Paint.h b/Paint.h index 448bd79..2e7c213 100644 --- a/Paint.h +++ b/Paint.h @@ -23,16 +23,16 @@ #include #include - #include - #include +#include class Paint { protected: Paint() {} public: + typedef std::tr1::shared_ptr ptr; virtual ~Paint() {} virtual void build() {} }; diff --git a/Shape.h b/Shape.h index b5a0402..7541404 100644 --- a/Shape.h +++ b/Shape.h @@ -21,6 +21,7 @@ #define SHAPE_H_ #include +#include struct Point { @@ -32,9 +33,12 @@ struct Point class Shape { public: + typedef std::tr1::shared_ptr ptr; std::vector vertices; Shape() {} - Shape(std::vector vertices_) : vertices(vertices_) {} + Shape(std::vector vertices_) : + vertices(vertices_) + {} virtual ~Shape() {} virtual void build() {}