OpenWalnut  1.5.0dev
WDataSetHistogram1D.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WDATASETHISTOGRAM1D_H
26 #define WDATASETHISTOGRAM1D_H
27 
28 #include <memory>
29 #include <string>
30 #include <vector>
31 
32 #include "../common/WColor.h"
33 #include "../common/WHistogramBasic.h"
34 #include "WDataSet.h"
35 
36 /**
37  * This data set type contains a 1D histogram.
38  * \ingroup dataHandler
39  */
40 class WDataSetHistogram1D : public WDataSet // NOLINT
41 {
42 public:
43  /**
44  * shared_ptr abbreviation
45  */
46  typedef std::shared_ptr< WDataSetHistogram1D > SPtr;
47 
48  /**
49  * const shared_ptr abbreviation
50  */
51  typedef std::shared_ptr< const WDataSetHistogram1D > ConstSPtr;
52 
53  /**
54  * Creates a dataset encapsulating a histogram.
55  * The histogram will be copied in order to prevent changes to the data.
56  *
57  * \param histo The histogram to use.
58  */
59  explicit WDataSetHistogram1D( std::shared_ptr< WHistogramBasic const > const& histo );
60 
61  /**
62  * Construct a histogram and allows to set an array of colors used for the bins.
63  *
64  * \param histo The histogram.
65  * \param colors An array of one color per bin.
66  */
67  WDataSetHistogram1D( std::shared_ptr< WHistogramBasic const > const& histo, std::shared_ptr< std::vector< WColor > const > const& colors );
68 
69  /**
70  * Construct an empty and unusable instance. This is needed for the prototype mechanism.
71  */
73 
74  /**
75  * Destroys this DataSet instance
76  */
77  virtual ~WDataSetHistogram1D();
78 
79  /**
80  * Gets the name of this prototype.
81  *
82  * \return the name.
83  */
84  virtual const std::string getName() const;
85 
86  /**
87  * Gets the description for this prototype.
88  *
89  * \return the description
90  */
91  virtual const std::string getDescription() const;
92 
93  /**
94  * Returns the histogram.
95  *
96  * \return A const ref pointer to the histogram.
97  */
98  std::shared_ptr< WHistogramBasic const > const& getHistogram() const;
99 
100  /**
101  * Returns a prototype instantiated with the true type of the deriving class.
102  *
103  * \return the prototype.
104  */
105  static std::shared_ptr< WPrototyped > getPrototype();
106 
107  /**
108  * Whether this dataset has colors associated with the bins.
109  *
110  * \return true, if this dataset has colors.
111  */
112  bool hasColors() const;
113 
114  /**
115  * Get the color of a bin.
116  *
117  * \param bin The index of the bin to get the color from.
118  *
119  * \return The color of the bin.
120  */
121  WColor getColor( std::size_t bin ) const;
122 
123 protected:
124  /**
125  * The prototype as singleton.
126  */
127  static std::shared_ptr< WPrototyped > m_prototype;
128 
129 private:
130  //! The histogram.
131  std::shared_ptr< WHistogramBasic const > const m_histogram;
132 
133  //! The colors for the bins.
134  std::shared_ptr< std::vector< WColor > const > const m_colors;
135 };
136 
137 #endif // WDATASETHISTOGRAM1D_H
138 
This data set type contains a 1D histogram.
virtual const std::string getDescription() const
Gets the description for this prototype.
static std::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
bool hasColors() const
Whether this dataset has colors associated with the bins.
std::shared_ptr< std::vector< WColor > const > const m_colors
The colors for the bins.
WColor getColor(std::size_t bin) const
Get the color of a bin.
virtual const std::string getName() const
Gets the name of this prototype.
virtual ~WDataSetHistogram1D()
Destroys this DataSet instance.
static std::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
std::shared_ptr< const WDataSetHistogram1D > ConstSPtr
const shared_ptr abbreviation
std::shared_ptr< WDataSetHistogram1D > SPtr
shared_ptr abbreviation
WDataSetHistogram1D()
Construct an empty and unusable instance.
std::shared_ptr< WHistogramBasic const > const & getHistogram() const
Returns the histogram.
std::shared_ptr< WHistogramBasic const > const m_histogram
The histogram.
Base class for all data set types.
Definition: WDataSet.h:50