00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef OH_HISTOGRAM_DATA_H
00010 #define OH_HISTOGRAM_DATA_H
00011
00012 #include <string>
00013 #include <oh/core/Histogram.h>
00014
00016
00023 namespace oh
00024 {
00025 template <typename T>
00026 class HistogramData : public Histogram
00027 {
00028 public:
00029 static const ISType & type() {
00030 static const ISType type_ = oh::HistogramData<T>( ).ISInfo::type();
00031 return type_;
00032 }
00033
00035 HistogramData( const std::string & cl = ClassName );
00036
00038 ~HistogramData( );
00039
00041 void set_dimension( oh::Histogram::Dimension d );
00042
00044 oh::Histogram::Dimension get_dimension( ) const;
00045
00047 std::string get_title( ) const;
00048
00050 void set_title( const std::string& title );
00051
00053 unsigned long get_number_of_axes( ) const;
00054
00056 void get_annotations( std::vector< std::pair< std::string, std::string > > & ann ) const;
00057
00059 void set_annotations( const std::vector< std::pair< std::string, std::string > > & ann );
00060
00062 const std::string & get_axis_title( oh::Axis::ID axis ) const;
00063
00065 void set_axis_title( oh::Axis::ID axis, const std::string & label );
00066
00068 std::vector<long> & indices( oh::Axis::ID axis );
00069
00071 const std::vector<long> & get_indices( oh::Axis::ID axis ) const;
00072
00074 std::vector<std::string> & labels( oh::Axis::ID axis );
00075
00077 const std::vector<std::string> & get_labels( oh::Axis::ID axis ) const;
00078
00080 oh::Axis::Kind get_axis_type( oh::Axis::ID axis ) const;
00081
00083 long get_bin_count( oh::Axis::ID axis ) const;
00084
00086 const std::vector<double> & get_axis_range( oh::Axis::ID axis ) const;
00087
00089 void get_axis_range( oh::Axis::ID axis, double & low, double & binwidth ) const;
00090
00092 void set_axis_range( oh::Axis::ID axis, const std::vector<double> & edges );
00093
00095 void set_axis_range( oh::Axis::ID axis, const double * edges, unsigned long size );
00096
00098 void set_axis_range( oh::Axis::ID axis, double low, double binwidth, unsigned long nbins );
00099
00101 double get_error( long x, long y, long z ) const;
00102
00104 const double * get_errors( ) const;
00105
00107 void set_errors( double * array, unsigned long size );
00108
00110 void set_error( long x, long y, long z, double error );
00111
00113 unsigned long get_entries( ) const;
00114
00116 void set_entries( unsigned long entries );
00117
00119 T get_bin_value( long x, long y, long z ) const;
00120
00122 void set_bin_value( long x, long y, long z, T height );
00123
00125 T * get_bins_array( bool orphan = false ) const;
00126
00128 size_t get_bins_size( ) const;
00129
00131 void set_bins_array( T * array, unsigned long size, bool release = false );
00132
00134 void set_bins_array( const T * array, unsigned long size );
00135
00136 protected:
00137 void publishGuts( ISostream & out ){
00138 Histogram::publishGuts( out );
00139 out.put( bins_, bins_size_ );
00140 }
00141
00142 void refreshGuts( ISistream & in ){
00143 Histogram::refreshGuts( in );
00144 if ( release_ )
00145 delete[] bins_;
00146 in.get( &bins_, bins_size_ );
00147 release_ = true;
00148 }
00149
00150 private:
00151
00152 long index( long indexX, long indexY, long indexZ ) const;
00153
00154
00155 void alloc_bins( );
00156
00157
00158 void alloc_errors( );
00159
00160 private:
00161
00162 T * bins_;
00163 size_t bins_size_;
00164 mutable bool release_;
00165
00166 static std::string ClassName;
00167 };
00168 }
00169
00170 #include <oh/core/HistogramData.i>
00171
00172 #endif // OH_HISTOGRAM_DATA_H