IHistogram.hpp
1 #pragma once
2 
3 #include "DM/config.hpp"
4 #include "DM/Handle.hpp"
5 #include "DM/ObjectBase.hpp"
6 #include "DM/Iterator.hpp"
7 #include "DM/ColumnTypes.hpp"
8 
9 DM_NAMESPACE_BEGIN
10 
11 /// \brief Class for representing a histogram
12 ///
13 /// Although all DM column types are internally supported, the interface provides access to a reduced list types only (to keep the interface as simple as possible).
14 /// The corresponding conversion are implicitly performed when accessing the values.
15 class DM_API IHistogram : public ObjectBase
16 {
17 public:
18  /// \brief Histogram entry
19  template<typename T>
20  struct IEntry : public ObjectBase {
21  virtual ~IEntry() {};
22 
23  virtual T value() const = 0; ///< value
24  virtual int64_t count() const = 0; ///< absolute frequency
25  };
26 
27  // Iterator typedefs ============================================================================
28  typedef ConstIterator< IEntry<int64_t> > const_iterator_integral; ///< integral histogram iterator
29  typedef ConstIterator< IEntry<double> > const_iterator_real; ///< real histogram iterator
30  typedef ConstIterator< IEntry<bool> > const_iterator_bool; ///< boolean histogram iterator
31  typedef ConstIterator< IEntry<const char*> > const_iterator_string; ///< string histogram iterator
32 
33  virtual ~IHistogram() {}
34 
35  virtual ColumnType type() const = 0; ///< internal type of the histogram
36  virtual bool isIntegral() const = 0; ///< is an integral data type
37  virtual bool isReal() const = 0; ///< is a real (double or float) data type
38  virtual bool isBool() const = 0; ///< is a boolean type
39  virtual bool isString() const = 0; ///< is a string data type
40 
41  virtual int64_t size() const = 0; ///< number of histogram value (number of distinct data values)
42 
43  virtual int64_t sizeData() const = 0; ///< number of data values that were used to build the histogram
44  virtual int64_t sizeNull() const = 0; ///< number of null values occurred in the corresponding data set
45 
46  virtual bool complete() const = 0; ///< flag if histogram covers the full data set
47 
48  // Iterator function ============================================================================
49  virtual const_iterator_integral beginIntegral() const = 0; ///< only allowed if isIntegral() == true
50  virtual const_iterator_integral endIntegral() const = 0;
51 
52  virtual const_iterator_real beginReal() const = 0;
53  virtual const_iterator_real endReal() const = 0;
54 
55  virtual const_iterator_bool beginBool() const = 0;
56  virtual const_iterator_bool endBool() const = 0;
57 
58  virtual const_iterator_string beginString() const = 0;
59  virtual const_iterator_string endString() const = 0;
60 };
61 
62 typedef Handle< IHistogram > HistogramHandle;
63 
64 
65 DM_NAMESPACE_END
66 
ConstIterator< IEntry< double > > const_iterator_real
real histogram iterator
Definition: IHistogram.hpp:29
Definition: Iterator.hpp:96
Histogram entry.
Definition: IHistogram.hpp:20
ConstIterator< IEntry< const char * > > const_iterator_string
string histogram iterator
Definition: IHistogram.hpp:31
ConstIterator< IEntry< int64_t > > const_iterator_integral
integral histogram iterator
Definition: IHistogram.hpp:28
Class for representing a histogram.
Definition: IHistogram.hpp:15
ColumnType
Supported attribute type.
Definition: ColumnTypes.hpp:8
@ count
always last element
ConstIterator< IEntry< bool > > const_iterator_bool
boolean histogram iterator
Definition: IHistogram.hpp:30
Definition: M/c++_api/inc/DM/ObjectBase.hpp:8