DGtal 0.3.0

CImageContainer.h

Go to the documentation of this file.
00001 
00017 #pragma once
00018 
00029 #if defined(CImageContainerRECURSES)
00030 #error Recursive header files inclusion detected in CImageContainer.h
00031 #else // defined(CImageContainerRECURSES)
00032 
00033 #define CImageContainerRECURSES
00034 
00035 #if !defined CImageContainer_h
00036 
00037 #define CImageContainer_h
00038 
00039 #include <boost/concept_check.hpp>
00040 #include <boost/concept/assert.hpp>
00041 #include <boost/concept/requires.hpp>
00042 
00043 #include "DGtal/kernel/images/CValue.h"
00044 
00045 namespace DGtal
00046 {
00047 
00049   // struct CImageContainer
00123   template <typename ImageContainer>
00124   struct CImageContainer
00125   {
00126 
00127   public:
00128     typedef typename ImageContainer::Value Value;
00129     typedef typename ImageContainer::Iterator Iterator;
00130     typedef typename ImageContainer::ConstIterator ConstIterator;
00131     typedef typename ImageContainer::Point Point;
00132 
00133  
00134     BOOST_CONCEPT_ASSERT((CValue<Value>));
00135 
00136     BOOST_CONCEPT_USAGE(CImageContainer)
00137     {
00138       //Iterators
00139       it = i.begin();
00140       itconst = i.begin();
00141       ++it;
00142       same_type(++itconst,itconst);
00143       --it;
00144       same_type(--itconst, itconst);
00145 
00146       it = i.end();
00147       itconst = i.end();
00148       
00149       
00150       //Accessors
00151       same_type(i(a), v);
00152       same_type(i(it), v);
00153       same_type(i(itconst), v);
00154       
00155       //API
00156       same_type(i.extent(), a); //get the extent
00157       i.setValue(a, v);  //set a value at a Point
00158       i.setValue(it, v); //set a value at an Iterator
00159       same_type(i.operator()(itconst), v);       // get the value from a ConstIterator
00160       same_type(i.operator()(it), v);       // get the value from a ConstIterator
00161       same_type(i.operator()(a), v);       //get the value from a point
00162 
00163     }
00164 
00165   private:
00166     ImageContainer i;
00167     Iterator it;
00168     ConstIterator itconst;
00169     Value v;
00170     Point a, b;
00171 
00172     //  deduction will fail unless the arguments have the same type.
00173     template <typename T>
00174     void same_type(T const&, T const&);
00175   };
00176 } // namespace DGtal
00177 
00178 //                                                                           //
00180 
00181 #endif // !defined CImageContainer_h
00182 
00183 #undef CImageContainerRECURSES
00184 #endif // else defined(CImageContainerRECURSES)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines