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  // General member functions ====================================================================
36  virtual ColumnType type() const = 0; ///< internal type of the histogram
37  virtual bool isIntegral() const = 0; ///< is an integral data type
38  virtual bool isReal() const = 0; ///< is a real (double or float) data type
39  virtual bool isBool() const = 0; ///< is a boolean type
40  virtual bool isString() const = 0; ///< is a string data type
41 
42  virtual int64_t size() const = 0; ///< number of histogram value (number of distinct data values)
43 
44  virtual int64_t sizeData() const = 0; ///< number of data values that were used to build the histogram
45  virtual int64_t sizeNull() const = 0; ///< number of null values occurred in the corresponding data set
46 
47  virtual bool complete() const = 0; ///< flag if histogram covers the full data set
48 
49  // Iterator function ============================================================================
50  virtual const_iterator_integral beginIntegral() const = 0; ///< only allowed if isIntegral() == true
51  virtual const_iterator_integral endIntegral() const = 0;
52 
53  virtual const_iterator_real beginReal() const = 0;
54  virtual const_iterator_real endReal() const = 0;
55 
56  virtual const_iterator_bool beginBool() const = 0;
57  virtual const_iterator_bool endBool() const = 0;
58 
59  virtual const_iterator_string beginString() const = 0;
60  virtual const_iterator_string endString() const = 0;
61 };
62 
63 typedef Handle< IHistogram > HistogramHandle;
64 
65 
66 DM_NAMESPACE_END
67 
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