bioprocessing  5.1.2
coustystream.h
Go to the documentation of this file.
1 /* Copyright (C) 2000-2013 CEA
2  *
3  * This software and supporting documentation were developed by
4  * bioPICSEL
5  * CEA/DSV/I²BM/MIRCen/LMN, Batiment 61,
6  * 18, route du Panorama
7  * 92265 Fontenay-aux-Roses
8  * France
9  */
10 
11 #ifndef BIOPROCESSING_WATERSHED_COUSTYSTREAM
12 #define BIOPROCESSING_WATERSHED_COUSTYSTREAM
13 
15 
16 namespace bio {
17 
18  template <typename V> class CoustyStream;
19  template <typename V> class CoustyStreamRef;
20 
21  //==========================================================================
22  // STREAM
23  //==========================================================================
29  template <typename V>
30  class CoustyStream: public std::set<V>, public carto::RCObject
31  {
32  //--- typedef ------------------------------------------------------------
33  protected:
34  typedef typename std::set<V> Base;
35  public:
36  typedef V Vertex;
37 
38  //--- constructor --------------------------------------------------------
39  public:
42  {
43  Base::insert(x);
44  }
46 
47  //--- accessors ----------------------------------------------------------
48  public:
49  void reset( Vertex x )
50  {
51  Base::clear();
52  Base::insert( x );
53  }
54  };
55 
56  //==========================================================================
57  // STREAM REF
58  //==========================================================================
63  template <typename V>
64  class CoustyStreamRef: public carto::rc_ptr<CoustyStream<V> >
65  {
66  //--- typedef ------------------------------------------------------------
67  protected:
69  typedef carto::rc_ptr<Pointed> Base;
70  public:
71  typedef typename Pointed::Vertex Vertex;
72  typedef typename Pointed::iterator iterator;
73  typedef typename Pointed::const_iterator const_iterator;
74 
75  //--- constructor --------------------------------------------------------
76  public:
77  CoustyStreamRef(): Base( new Pointed() ) {}
78  CoustyStreamRef( Vertex x ): Base( new Pointed(x) ) {}
80 
81  //--- accessors ----------------------------------------------------------
82  public:
83  void reset( Vertex x ) { return (*this)->reset(x); }
84 
85  //--- set methods --------------------------------------------------------
86  public:
87  const_iterator begin() const { return (*this)->begin(); }
88  const_iterator end() const { return (*this)->end(); }
89  iterator begin() { return (*this)->begin(); }
90  iterator end() { return (*this)->end(); }
91  std::pair<iterator,bool> insert( const Vertex & v ) { return (*this)->insert(v); }
92  void erase( const Vertex & v ) { (*this)->erase(v); }
93  void erase( iterator v ) { (*this)->erase(v); }
94  bool empty() const { return (*this)->empty(); }
95  size_t count(const Vertex & v) const { return (*this)->count(v); }
96 
97  };
98 
99 } // namespace bio
100 
101 #endif // BIOPROCESSING_WATERSHED_COUSTYSTREAM
Reference counting pointer to a CoustyStream.
Definition: coustystream.h:65
Pointed::Vertex Vertex
Definition: coustystream.h:71
void erase(const Vertex &v)
Definition: coustystream.h:92
const_iterator end() const
Definition: coustystream.h:88
Pointed::iterator iterator
Definition: coustystream.h:72
std::pair< iterator, bool > insert(const Vertex &v)
Definition: coustystream.h:91
void erase(iterator v)
Definition: coustystream.h:93
bool empty() const
Definition: coustystream.h:94
const_iterator begin() const
Definition: coustystream.h:87
void reset(Vertex x)
Definition: coustystream.h:83
Pointed::const_iterator const_iterator
Definition: coustystream.h:73
CoustyStreamRef(Vertex x)
Definition: coustystream.h:78
size_t count(const Vertex &v) const
Definition: coustystream.h:95
carto::rc_ptr< Pointed > Base
Definition: coustystream.h:69
CoustyStream< V > Pointed
Definition: coustystream.h:68
Streams represent a descent path in a graph.
Definition: coustystream.h:31
void reset(Vertex x)
Definition: coustystream.h:49
std::set< V > Base
Definition: coustystream.h:34
CoustyStream(Vertex x)
Definition: coustystream.h:41