Loading [MathJax]/jax/output/HTML-CSS/config.js
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 #include "DM/IText.hpp"
9 
10 DM_NAMESPACE_BEGIN
11 
12 /// \brief Class for representing a histogram
13 ///
14 /// 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).
15 /// The corresponding conversion are implicitly performed when accessing the values.
16 class DM_API IHistogram : public ObjectBase
17 {
18 public:
19  static IHistogram* New(const char *);
20 
21  /// \brief Histogram entry
22  template<typename T>
23  struct IEntry : public ObjectBase {
24  virtual ~IEntry() {};
25 
26  virtual T value() const = 0; ///< value
27  virtual int64_t count() const = 0; ///< absolute frequency
28  };
29 
30  // Iterator typedefs ============================================================================
31  typedef ConstIterator< IEntry<int64_t> > const_iterator_integral; ///< integral histogram iterator
32  typedef ConstIterator< IEntry<double> > const_iterator_real; ///< real histogram iterator
33  typedef ConstIterator< IEntry<bool> > const_iterator_bool; ///< boolean histogram iterator
34  typedef ConstIterator< IEntry<const char*> > const_iterator_string; ///< string histogram iterator
35 
36  virtual ~IHistogram() {}
37 
38  // General member functions ====================================================================
39  virtual ColumnType type() const = 0; ///< internal type of the histogram
40  virtual bool isIntegral() const = 0; ///< is an integral data type
41  virtual bool isReal() const = 0; ///< is a real (double or float) data type
42  virtual bool isBool() const = 0; ///< is a boolean type
43  virtual bool isString() const = 0; ///< is a string data type
44 
45  virtual int64_t size() const = 0; ///< number of histogram value (number of distinct data values)
46 
47  virtual int64_t sizeData() const = 0; ///< number of data values that were used to build the histogram
48  virtual int64_t sizeNull() const = 0; ///< number of null values occurred in the corresponding data set
49 
50  virtual bool complete() const = 0; ///< flag if histogram covers the full data set
51 
52  virtual TextHandle toString(int precision = 3) const = 0;
53  virtual void fromString(const char *) = 0;
54 
55  virtual void merge(const IHistogram &other) = 0;
56 
57  // Iterator function ============================================================================
58  virtual const_iterator_integral beginIntegral() const = 0; ///< only allowed if isIntegral() == true
59  virtual const_iterator_integral endIntegral() const = 0;
60 
61  virtual const_iterator_real beginReal() const = 0;
62  virtual const_iterator_real endReal() const = 0;
63 
64  virtual const_iterator_bool beginBool() const = 0;
65  virtual const_iterator_bool endBool() const = 0;
66 
67  virtual const_iterator_string beginString() const = 0;
68  virtual const_iterator_string endString() const = 0;
69 
70 
71 };
72 
73 typedef Handle< IHistogram > HistogramHandle;
74 
75 
76 DM_NAMESPACE_END
77 
const DM_API char * toString(ExportError error)
get a textual description of an export error (this function is not thread safe)
ConstIterator< IEntry< double > > const_iterator_real
real histogram iterator
Definition: IHistogram.hpp:32
Definition: Iterator.hpp:96
Histogram entry.
Definition: IHistogram.hpp:23
ConstIterator< IEntry< const char * > > const_iterator_string
string histogram iterator
Definition: IHistogram.hpp:34
ConstIterator< IEntry< int64_t > > const_iterator_integral
integral histogram iterator
Definition: IHistogram.hpp:31
Class for representing a histogram.
Definition: IHistogram.hpp:16
ColumnType
Supported attribute type.
Definition: ColumnTypes.hpp:8
@ count
always last element
ConstIterator< IEntry< bool > > const_iterator_bool
boolean histogram iterator
Definition: IHistogram.hpp:33
Smart pointer class using reference counting with support for DM objects (see ObjectBase)
Definition: Handle.hpp:75
Definition: M/c++_api/inc/DM/ObjectBase.hpp:8