OpendTect  6.6
odset.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: Bert
8  Date: Feb 2009
9  RCS: $Id$
10 ________________________________________________________________________
11 
12 -*/
13 
14 # include "gendefs.h"
15 
16 
17 namespace OD
18 {
19 
32 mExpClass(Basic) Set
33 {
34 public:
35 
36  virtual Set* clone() const = 0;
37  virtual ~Set() {}
38 
39  virtual od_int64 nrItems() const = 0;
40  virtual bool validIdx(od_int64) const = 0;
41  virtual void swapItems(od_int64,od_int64) = 0;
42  virtual void erase() = 0;
43  virtual void reverse() = 0;
44 
45  inline bool isEmpty() const { return nrItems() <= 0; }
46  inline void setEmpty() { erase(); }
47 
48  static inline od_int32 maxIdx32() { return 2147483647; }
49  static inline od_int64 maxIdx64() { return 9223372036854775807LL;}
50 };
51 
52 } // namespace
53 
54 
55 
58 template <class ODSET,class size_type>
59 inline void removeRange( ODSET& inst, size_type start, size_type stop )
60 {
61  inst.removeRange( start, stop );
62 }
63 
64 
68 template <class ODSET,class SET>
69 inline void addNames( const ODSET& inp, SET& setwithadd )
70 {
71  for ( auto obj : inp )
72  if ( obj )
73  setwithadd.add( obj->name() );
74 }
75 
76 
77 #ifdef __msvc__
78 # define mTypeName
79 #else
80 # define mTypeName typename
81 #endif
82 
83 #define mIsContainer( clss, typ, memb ) \
84 protected: \
85  \
86  typedef typ impl_type; \
87  impl_type memb; \
88  \
89 public: \
90  \
91  typedef mTypeName impl_type::size_type size_type; \
92  typedef mTypeName impl_type::idx_type idx_type; \
93  typedef mTypeName impl_type::object_type object_type; \
94  typedef mTypeName impl_type::value_type value_type; \
95  typedef mTypeName impl_type::iterator iterator; \
96  typedef mTypeName impl_type::const_iterator const_iterator; \
97  typedef mTypeName impl_type::difference_type difference_type; \
98  typedef mTypeName impl_type::reference reference; \
99  typedef mTypeName impl_type::const_reference const_reference; \
100  \
101  iterator begin() { return memb.begin(); } \
102  const_iterator begin() const { return memb.cbegin(); } \
103  const_iterator cbegin() const { return memb.cbegin(); } \
104  iterator end() { return memb.end(); } \
105  const_iterator end() const { return memb.cend(); } \
106  const_iterator cend() const { return memb.cend(); } \
107  inline size_type max_size() const { return memb.max_size(); } \
108  inline bool empty() const { return memb.empty(); } \
109  inline void swap( clss& oth ) { memb.swap(oth.memb); } \
110  \
111  size_type getIdx( iterator it ) const { return memb.getIdx(it); } \
112  size_type getIdx( const_iterator it ) const { return memb.getIdx(it); }
113 
114 
115 #define mDefContainerSwapFunction( mod, clss ) \
116 mGlobal(mod) inline void swap( clss& o1, clss& o2 ) \
117 { \
118  o1.swap( o2 ); \
119 }
120 
121 
122 #define mODSetApplyToAll( itp, os, op ) \
123  for ( itp idx=(itp) os.nrItems()-1; idx>=0; idx-- ) \
124  { \
125  op; \
126  }
127 
128 
OD::Set::swapItems
virtual void swapItems(int64_t, int64_t)=0
OD::Set::validIdx
virtual bool validIdx(int64_t) const =0
OD::Set::clone
virtual Set * clone() const =0
od_int64
#define od_int64
Definition: plftypes.h:35
OD
OpendTect.
Definition: commontypes.h:28
mExpClass
#define mExpClass(module)
Definition: commondefs.h:177
OD::Set::maxIdx64
static int64_t maxIdx64()
Definition: odset.h:49
OD::Set::isEmpty
bool isEmpty() const
Definition: odset.h:45
OD::Set::nrItems
virtual int64_t nrItems() const =0
OD::Set::erase
virtual void erase()=0
OD::Set::maxIdx32
static int maxIdx32()
Definition: odset.h:48
OD::Set::reverse
virtual void reverse()=0
gendefs.h
od_int32
#define od_int32
Definition: plftypes.h:30
addNames
void addNames(const ODSET &inp, SET &setwithadd)
Adds all names from a set to another set with an add() function (typically a BufferStringSet)
Definition: odset.h:69
OD::Set::~Set
virtual ~Set()
Definition: odset.h:37
OD::Set::setEmpty
void setEmpty()
Definition: odset.h:46
removeRange
void removeRange(ODSET &inst, size_type start, size_type stop)
Removes a range from the set.
Definition: odset.h:59
OD::Set
Base class for all sets used in OpendTect.
Definition: odset.h:33

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2021