VectorComponentAccessor.hpp

00001 // This file is part of the imaging2 class library.
00002 //
00003 // University of Innsbruck, Infmath Imaging, 2009.
00004 // http://infmath.uibk.ac.at
00005 //
00006 // All rights reserved.
00007 
00008 
00009 #ifndef VECTORCOMPONENTACCESSOR_H
00010 #define VECTORCOMPONENTACCESSOR_H
00011 
00012 #include <core/imaging2.hpp>
00013 
00014 namespace imaging
00015 {
00016 
00034   template <class vector_image_t>
00035   class VectorComponentAccessor : public ImageAccessorInterface<vector_image_t, typename vector_image_t::data_t::data_t>
00036   {
00037   public:
00038     typedef typename vector_image_t::data_t::data_t data_t;
00039     static const size_t dimension =
00040       ImageAccessorInterface<vector_image_t, data_t>::dimension;
00041   private:
00043     class data_reference
00044     {
00045       VectorComponentAccessor<vector_image_t> & _accessor_reference;
00046       const ublas::fixed_vector<size_t, dimension> & _index_reference;
00047 
00048     public:
00049       data_reference(VectorComponentAccessor<vector_image_t> & accessor, const ublas::fixed_vector<size_t, dimension> & index) : _accessor_reference(accessor), _index_reference(index) {}
00050 
00051       float_t operator=(const float_t & input)
00052       { _accessor_reference._image_reference[_index_reference](_accessor_reference._component) = input; return input; }
00053 
00054       operator float_t() const { return _accessor_reference._image_reference[_index_reference](_accessor_reference._component); }
00055     };
00058     size_t _component;
00059 
00060   public:
00065     VectorComponentAccessor(vector_image_t & image, size_t component) : ImageAccessorInterface<vector_image_t, data_t>(image), _component(component) {}
00066 
00067     data_t operator[](const ublas::fixed_vector<size_t, dimension> & index) const { return ImageAccessorInterface<vector_image_t, data_t>::_image_reference[index](_component); }
00068 
00069     data_reference operator[](const ublas::fixed_vector<size_t, dimension> & index) { return data_reference(*this, index); }
00070   };
00071 }
00072 
00073 #endif

Generated on Tue Feb 10 10:01:30 2009 for imaging2 by  doxygen 1.5.5