blob: 938e6c0d41deda87798a43ce541cb57ff2af917a (
plain) (
tree)
|
|
/******************************************************************/
/* 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 <string>
#include <memory>
#include <ostream>
#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<value_type[]>::pointer iterator;
typedef std::unique_ptr<const value_type[]>::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<value_type[]> _data;
};
#endif /* _IMAGE_H_ */
|