2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2012-12-28 20:21:05 +00:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup freestyle
|
|
|
|
|
* \brief Classes defining the basic "Iterator" design pattern
|
2012-12-28 20:21:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <iterator>
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2024-11-13 13:39:49 +01:00
|
|
|
#include "MEM_guardedalloc.h"
|
2013-05-13 22:58:27 +00:00
|
|
|
|
2013-04-09 00:46:49 +00:00
|
|
|
namespace Freestyle {
|
|
|
|
|
|
2019-07-31 14:25:09 +02:00
|
|
|
// use for iterators definitions
|
2008-04-30 15:41:54 +00:00
|
|
|
template<class Element> class Nonconst_traits;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-04-30 15:41:54 +00:00
|
|
|
template<class Element> class Const_traits {
|
|
|
|
|
public:
|
2012-12-28 20:21:05 +00:00
|
|
|
typedef Element value_type;
|
|
|
|
|
typedef const Element &reference;
|
|
|
|
|
typedef const Element *pointer;
|
|
|
|
|
typedef ptrdiff_t difference_type;
|
|
|
|
|
typedef Nonconst_traits<Element> Non_const_traits;
|
2013-05-13 22:58:27 +00:00
|
|
|
|
|
|
|
|
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Const_traits")
|
2008-04-30 15:41:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template<class Element> class Nonconst_traits {
|
|
|
|
|
public:
|
2012-12-28 20:21:05 +00:00
|
|
|
typedef Element value_type;
|
|
|
|
|
typedef Element &reference;
|
|
|
|
|
typedef Element *pointer;
|
|
|
|
|
typedef ptrdiff_t difference_type;
|
|
|
|
|
typedef Nonconst_traits<Element> Non_const_traits;
|
2013-05-13 22:58:27 +00:00
|
|
|
|
|
|
|
|
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Nonconst_traits")
|
2008-04-30 15:41:54 +00:00
|
|
|
};
|
|
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
class InputIteratorTag_Traits {
|
2008-04-30 15:41:54 +00:00
|
|
|
public:
|
2012-12-28 20:21:05 +00:00
|
|
|
typedef std::input_iterator_tag iterator_category;
|
2013-05-13 22:58:27 +00:00
|
|
|
|
|
|
|
|
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:InputIteratorTag_Traits")
|
2008-04-30 15:41:54 +00:00
|
|
|
};
|
|
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
class BidirectionalIteratorTag_Traits {
|
2008-04-30 15:41:54 +00:00
|
|
|
public:
|
2012-12-28 20:21:05 +00:00
|
|
|
typedef std::bidirectional_iterator_tag iterator_category;
|
2013-05-13 22:58:27 +00:00
|
|
|
|
|
|
|
|
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:BidirectionalIteratorTag_Traits")
|
2008-04-30 15:41:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template<class Traits, class IteratorTagTraits> class IteratorBase {
|
|
|
|
|
public:
|
2023-03-29 16:50:54 +02:00
|
|
|
virtual ~IteratorBase() {}
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
virtual bool begin() const = 0;
|
|
|
|
|
virtual bool end() const = 0;
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
typedef typename IteratorTagTraits::iterator_category iterator_category;
|
|
|
|
|
typedef typename Traits::value_type value_type;
|
|
|
|
|
typedef typename Traits::difference_type difference_type;
|
|
|
|
|
typedef typename Traits::pointer pointer;
|
|
|
|
|
typedef typename Traits::reference reference;
|
2008-04-30 15:41:54 +00:00
|
|
|
|
|
|
|
|
protected:
|
2023-03-29 16:50:54 +02:00
|
|
|
IteratorBase() {}
|
2013-05-13 22:58:27 +00:00
|
|
|
|
|
|
|
|
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:IteratorBase")
|
2008-04-30 15:41:54 +00:00
|
|
|
};
|
|
|
|
|
|
2013-04-09 00:46:49 +00:00
|
|
|
} /* namespace Freestyle */
|