• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015-2019 Hans Dembinski
2 //
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt
5 // or copy at http://www.boost.org/LICENSE_1_0.txt)
6 
7 #ifndef BOOST_HISTOGRAM_FWD_HPP
8 #define BOOST_HISTOGRAM_FWD_HPP
9 
10 /**
11   \file boost/histogram/fwd.hpp
12   Forward declarations, tag types and type aliases.
13 */
14 
15 #include <boost/config.hpp> // BOOST_ATTRIBUTE_NODISCARD
16 #include <boost/core/use_default.hpp>
17 #include <tuple>
18 #include <type_traits>
19 #include <vector>
20 
21 namespace boost {
22 namespace histogram {
23 
24 /// Tag type to indicate use of a default type
25 using boost::use_default;
26 
27 namespace axis {
28 
29 /// Integral type for axis indices
30 using index_type = int;
31 
32 /// Real type for axis indices
33 using real_index_type = double;
34 
35 /// Empty metadata type
36 struct null_type {
37   template <class Archive>
serializeboost::histogram::axis::null_type38   void serialize(Archive&, unsigned /* version */) {}
39 };
40 
41 /// Another alias for an empty metadata type
42 using empty_type = null_type;
43 
44 // some forward declarations must be hidden from doxygen to fix the reference docu :(
45 #ifndef BOOST_HISTOGRAM_DOXYGEN_INVOKED
46 
47 namespace transform {
48 
49 struct id;
50 
51 struct log;
52 
53 struct sqrt;
54 
55 struct pow;
56 
57 } // namespace transform
58 
59 template <class Value = double, class Transform = use_default,
60           class MetaData = use_default, class Options = use_default>
61 class regular;
62 
63 template <class Value = int, class MetaData = use_default, class Options = use_default>
64 class integer;
65 
66 template <class Value = double, class MetaData = use_default, class Options = use_default,
67           class Allocator = std::allocator<Value>>
68 class variable;
69 
70 template <class Value = int, class MetaData = use_default, class Options = use_default,
71           class Allocator = std::allocator<Value>>
72 class category;
73 
74 template <class MetaData = use_default>
75 class boolean;
76 
77 template <class... Ts>
78 class variant;
79 
80 #endif // BOOST_HISTOGRAM_DOXYGEN_INVOKED
81 
82 } // namespace axis
83 
84 #ifndef BOOST_HISTOGRAM_DOXYGEN_INVOKED
85 
86 template <class T>
87 struct weight_type;
88 
89 template <class T>
90 struct sample_type;
91 
92 namespace accumulators {
93 
94 template <class ValueType = double>
95 class count;
96 
97 template <class ValueType = double>
98 class sum;
99 
100 template <class ValueType = double>
101 class weighted_sum;
102 
103 template <class ValueType = double>
104 class mean;
105 
106 template <class ValueType = double>
107 class weighted_mean;
108 
109 template <class T>
110 class thread_safe;
111 
112 template <class T>
113 struct is_thread_safe : std::false_type {};
114 template <class T>
115 struct is_thread_safe<thread_safe<T>> : std::true_type {};
116 
117 } // namespace accumulators
118 
119 struct unsafe_access;
120 
121 template <class Allocator = std::allocator<char>>
122 class unlimited_storage;
123 
124 template <class T>
125 class storage_adaptor;
126 
127 #endif // BOOST_HISTOGRAM_DOXYGEN_INVOKED
128 
129 /// Vector-like storage for fast zero-overhead access to cells.
130 template <class T, class A = std::allocator<T>>
131 using dense_storage = storage_adaptor<std::vector<T, A>>;
132 
133 /// Default storage, optimized for unweighted histograms
134 using default_storage = unlimited_storage<>;
135 
136 /// Dense storage which tracks sums of weights and a variance estimate.
137 using weight_storage = dense_storage<accumulators::weighted_sum<>>;
138 
139 /// Dense storage which tracks means of samples in each cell.
140 using profile_storage = dense_storage<accumulators::mean<>>;
141 
142 /// Dense storage which tracks means of weighted samples in each cell.
143 using weighted_profile_storage = dense_storage<accumulators::weighted_mean<>>;
144 
145 // some forward declarations must be hidden from doxygen to fix the reference docu :(
146 #ifndef BOOST_HISTOGRAM_DOXYGEN_INVOKED
147 
148 template <class Axes, class Storage = default_storage>
149 class BOOST_ATTRIBUTE_NODISCARD histogram;
150 
151 #endif // BOOST_HISTOGRAM_DOXYGEN_INVOKED
152 
153 namespace detail {
154 
155 /* Most of the histogram code is generic and works for any number of axes. Buffers with a
156  * fixed maximum capacity are used in some places, which have a size equal to the rank of
157  * a histogram. The buffers are statically allocated to improve performance, which means
158  * that they need a preset maximum capacity. 32 seems like a safe upper limit for the rank
159  * (you can nevertheless increase it here if necessary): the simplest non-trivial axis has
160  * 2 bins; even if counters are used which need only a byte of storage per bin, 32 axes
161  * would generate of 4 GB.
162  */
163 #ifndef BOOST_HISTOGRAM_DETAIL_AXES_LIMIT
164 #define BOOST_HISTOGRAM_DETAIL_AXES_LIMIT 32
165 #endif
166 
167 template <class T>
168 struct buffer_size_impl
169     : std::integral_constant<std::size_t, BOOST_HISTOGRAM_DETAIL_AXES_LIMIT> {};
170 
171 template <class... Ts>
172 struct buffer_size_impl<std::tuple<Ts...>>
173     : std::integral_constant<std::size_t, sizeof...(Ts)> {};
174 
175 template <class T>
176 using buffer_size = typename buffer_size_impl<T>::type;
177 
178 } // namespace detail
179 
180 } // namespace histogram
181 } // namespace boost
182 
183 #endif
184