DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CDigitalSet.h
1 
17 #pragma once
18 
35 #if defined(CDigitalSet_RECURSES)
36 #error Recursive header files inclusion detected in CDigitalSet.h
37 #else // defined(CDigitalSet_RECURSES)
38 
39 #define CDigitalSet_RECURSES
40 
41 #if !defined CDigitalSet_h
42 
43 #define CDigitalSet_h
44 
46 // Inclusions
47 #include <iostream>
48 #include "boost/concept_check.hpp"
49 #include "DGtal/base/Common.h"
51 
52 namespace DGtal
53 {
54 
56  // class CDigitalSet
58  // class CDigitalSet
112  template <typename T>
113  struct CDigitalSet :
114  boost::CopyConstructible< T >,
115  boost::Assignable< T >
116  {
117  // ----------------------- Concept checks ------------------------------
118  public:
119  // 1. define first provided types (i.e. inner types), like
120  typedef typename T::Domain Domain;
121  typedef typename T::Point Point;
122  typedef typename T::Size Size;
123  typedef typename T::Iterator Iterator;
124  typedef typename T::ConstIterator ConstIterator;
125 
126  //BOOST_CONCEPT_ASSERT(( boost::BidirectionalIterator< Iterator > ));
127  // BOOST_CONCEPT_ASSERT(( boost_concepts::LvalueIteratorConcept<Iterator > ));
128  BOOST_CONCEPT_ASSERT(( boost_concepts::ReadableIteratorConcept<Iterator > ));
129 //DigitalSetFromMap cannot be a model of CDigitalSet if lvalue is required because
130 //in STL maps, in pairs <const key, value>, key is const...
131  BOOST_CONCEPT_ASSERT(( boost_concepts::BidirectionalTraversalConcept<Iterator > ));
132 
133  //BOOST_CONCEPT_ASSERT(( boost::BidirectionalIterator<ConstIterator > ));
134  BOOST_CONCEPT_ASSERT(( boost_concepts::ReadableIteratorConcept<ConstIterator > ));
135  BOOST_CONCEPT_ASSERT(( boost_concepts::BidirectionalTraversalConcept<ConstIterator > ));
136 
137  // To test if two types A and Y are equals, use
138  // BOOST_STATIC_ASSERT( ConceptUtils::sameType<A,X>::value );
139 
140  // 2. then check the presence of data members, operators and methods with
142  {
143  ConceptUtils::sameType( myDomain, myX.domain() );
144  ConceptUtils::sameType( mySize, myX.size() );
145  ConceptUtils::sameType( myBool, myX.empty() );
146  myX.insert( myPoint );
147  // template <typename PointInputIterator>
148  // BOOST_CONCEPT_REQUIRES
149  // ( ((boost::InputIterator<PointInputIterator>)),
150  // (void) )
151  // myX.insert( PointInputIterator, PointInputIterator );
152  myX.insertNew( myPoint );
154  myX.erase( myIterator );
155  myX.erase( myIterator, myIterator );
156  myX.clear();
159  ConceptUtils::sameType( myX, myX.operator+=( myX ) );
160  myX.computeComplement( myOutputIt );
161  myX.assignFromComplement( myX );
162  myX.computeBoundingBox( myPoint, myPoint );
165  // look at CInteger.h for testing tags.
166  }
171  {
175  }
176 
181  {
185  }
186 
187  // ------------------------- Private Datas --------------------------------
188  private:
189  T myX; // only if T is default constructible.
192  bool myBool;
197  // ------------------------- Internals ------------------------------------
198  private:
199 
200  }; // end of concept CDigitalSet
201 
202 } // namespace DGtal
203 
204 
206 // Includes inline functions.
207 #include "DGtal/kernel/sets/CDigitalSet.ih"
208 
209 // //
211 
212 #endif // !defined CDigitalSet_h
213 
214 #undef CDigitalSet_RECURSES
215 #endif // else defined(CDigitalSet_RECURSES)