29#ifndef INCLUDED_MDDS_MULTI_TYPE_VECTOR_DIR_UTIL_HPP
30#define INCLUDED_MDDS_MULTI_TYPE_VECTOR_DIR_UTIL_HPP
32#include "./block_funcs.hpp"
36namespace mdds {
namespace mtv {
101#ifdef MDDS_MULTI_TYPE_VECTOR_DEBUG
103template<
typename T,
typename =
void>
104struct has_trace : std::false_type
109struct has_trace<T, decltype((void)T::trace)> : std::true_type
113template<
typename Traits>
118 call_trace(
int& _call_depth) : call_depth(_call_depth)
122 ~call_trace() noexcept
127 void call(std::false_type, const ::mdds::mtv::trace_method_properties_t&)
const
132 void call(std::true_type, const ::mdds::mtv::trace_method_properties_t& props)
const
136 Traits::trace(props);
139 void operator()(const ::mdds::mtv::trace_method_properties_t& props)
const
141 call(has_trace<Traits>{}, props);
147inline void throw_block_position_not_found(
148 const char* method_sig,
int line,
size_t pos,
size_t block_size,
size_t container_size)
150 std::ostringstream os;
151 os << method_sig <<
"#" << line <<
": block position not found! (logical pos=" << pos
152 <<
", block size=" << block_size <<
", logical size=" << container_size <<
")";
153 throw std::out_of_range(os.str());
174template<
typename _T,
typename _SizeT>
175std::pair<_SizeT, bool> calc_input_end_position(
const _T& it_begin,
const _T& it_end, _SizeT pos, _SizeT total_size)
177 using ret_type = std::pair<_SizeT, bool>;
179 _SizeT length = std::distance(it_begin, it_end);
182 return ret_type(0,
false);
184 _SizeT end_pos = pos + length - 1;
185 if (end_pos >= total_size)
186 throw std::out_of_range(
"Input data sequence is too long.");
188 return ret_type(end_pos,
true);
192T advance_position(
const T& pos,
int steps)
200 if (ret.second + steps < ret.first->size)
208 steps -=
static_cast<int>(ret.first->size - ret.second);
218 if (
static_cast<int>(ret.second) >= -steps)
225 steps +=
static_cast<int>(ret.second + 1);
227 ret.second = ret.first->size - 1;
239#ifdef MDDS_MULTI_TYPE_VECTOR_DEBUG
241#define MDDS_MTV_TRACE(method_type) \
242 ::mdds::mtv::detail::call_trace<Traits> mdds_mtv_ct(m_trace_call_depth); \
243 mdds_mtv_ct({trace_method_t::method_type, this, __func__, "", __FILE__, __LINE__})
245#define MDDS_MTV_TRACE_ARGS(method_type, stream) \
246 ::mdds::mtv::detail::call_trace<Traits> mdds_mtv_ct(m_trace_call_depth); \
249 std::ostringstream _os_; \
251 mdds_mtv_ct({trace_method_t::method_type, this, __func__, _os_.str(), __FILE__, __LINE__}); \
256#define MDDS_MTV_TRACE(...)
258#define MDDS_MTV_TRACE_ARGS(...)
Definition: types.hpp:160
static constexpr lu_factor_t loop_unrolling
Definition: util.hpp:86
Definition: block_funcs.hpp:65
void element_block_acquired(const base_element_block *block)
Definition: util.hpp:52
void element_block_released(const base_element_block *block)
Definition: util.hpp:65