From db072ad4dc181eca5a1458656b130beb43f475bf Mon Sep 17 00:00:00 2001 From: 53hornet <53hornet@gmail.com> Date: Sat, 2 Feb 2019 23:33:15 -0500 Subject: Init. --- hw3/include/image.h | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 hw3/include/image.h (limited to 'hw3/include/image.h') diff --git a/hw3/include/image.h b/hw3/include/image.h new file mode 100644 index 0000000..938e6c0 --- /dev/null +++ b/hw3/include/image.h @@ -0,0 +1,89 @@ +/******************************************************************/ +/* This file is part of the homework assignments for CSCI-427/527 */ +/* at The College of William & Mary and authored by Pieter Peers. */ +/* No part of this file, whether altered or in original form, can */ +/* be distributed or used outside the context of CSCI-427/527 */ +/* without consent of either the College of William & Mary or */ +/* Pieter Peers. */ +/******************************************************************/ +#ifndef _IMAGE_H_ +#define _IMAGE_H_ + +#include +#include +#include + +#include "color.h" + +class image { + public: + ////////////// + // Typedefs // + ////////////// + typedef color value_type; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef std::unique_ptr::pointer iterator; + typedef std::unique_ptr::pointer const_iterator; + typedef size_t difference_type; + typedef size_t size_type; + + ////////////////// + // Constructors // + ////////////////// + image(size_type width=0, size_type height=0); + image(size_type width, size_type height, const_reference col); + image(const image& src); + image(image&& src); + + virtual ~image(void) { _data.reset(); } + + //////////////// + // Inspectors // + //////////////// + iterator begin(void); + const_iterator begin(void) const; + + iterator end(void); + const_iterator end(void) const; + + size_type size(void) const { return width()*height(); } + size_type width(void) const { return _width; } + size_type height(void) const { return _height; } + + + /////////////// + // Operators // + /////////////// + image& operator=(const image& src); + image& operator=(image&& src); + + reference operator()(size_type x, size_type y); + const_reference operator()(size_type x, size_type y) const; + + ///////////// + // Friends // + ///////////// + friend void swap(image& a, image& b) { a._swap(b); } + friend std::ostream& operator<<(std::ostream& s, const image& img) + { + s << "Image: (" << img.width() << ", " << img.height() << ")"; + return s; + } + +protected: + ///////////////////// + // Private Methods // + ///////////////////// + void _swap(image& img); + void _assign(const image& src); + +private: + ////////////////////////// + // Private Data Members // + ////////////////////////// + size_type _width, _height; + std::unique_ptr _data; +}; + +#endif /* _IMAGE_H_ */ -- cgit v1.2.3