timemory 3.3.0
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
tim::component::data_tracker< InpT, Tag > Struct Template Reference

This component is provided to facilitate data tracking. The first template parameter is the type of data to be tracked, the second is a custom tag for differentiating trackers which handle the same data types but record different high-level data. More...

#include "timemory/components/data_tracker/components.hpp"

+ Collaboration diagram for tim::component::data_tracker< InpT, Tag >:

Classes

class  vector_map
 

Public Types

using value_type = InpT
 
using this_type = data_tracker< InpT, Tag >
 
using base_type = base< this_type, value_type >
 
using handler_type = data::handler< InpT, Tag >
 
using storage_type = empty_storage
 

Public Member Functions

void start ()
 
void stop ()
 
auto get () const
 get the data in the final form after unit conversion More...
 
auto get_display () const
 get the data in a form suitable for display More...
 
auto get_secondary () const
 map of the secondary entries. When TIMEMORY_ADD_SECONDARY is enabled contents of this map will be added as direct children of the current node in the call-graph. More...
 
template<typename T >
void store (T &&val, enable_if_acceptable_t< T, int >=0)
 store some data. Uses tim::data::handler for the type. More...
 
template<typename T >
void store (handler_type &&, T &&val, enable_if_acceptable_t< T, int >=0)
 overload which takes a handler to ensure proper overload resolution More...
 
template<typename FuncT , typename T >
auto store (FuncT &&f, T &&val, enable_if_acceptable_t< T, int >=0) -> decltype(std::declval< handler_type >().store(*this, std::forward< FuncT >(f), std::forward< T >(val)), void())
 overload which uses a lambda to bypass the default behavior of how the handler updates the values More...
 
template<typename FuncT , typename T >
auto store (handler_type &&, FuncT &&f, T &&val, enable_if_acceptable_t< T, int >=0) -> decltype(std::declval< handler_type >().store(*this, std::forward< FuncT >(f), std::forward< T >(val)), void())
 overload which uses a lambda to bypass the default behavior of how the handler updates the values and takes a handler to ensure proper overload resolution More...
 
template<typename T >
void mark_begin (T &&val, enable_if_acceptable_t< T, int >=0)
 The combination of mark_begin(...) and mark_end(...) can be used to store some initial data which may be needed later. When mark_end(...) is called, the value is updated with the difference of the value provided to mark_end and the temporary stored during mark_begin. More...
 
template<typename T >
void mark_begin (handler_type &&, T &&val, enable_if_acceptable_t< T, int >=0)
 overload which takes a handler to ensure proper overload resolution More...
 
template<typename FuncT , typename T >
void mark_begin (FuncT &&f, T &&val, enable_if_acceptable_t< T, int >=0)
 overload which uses a lambda to bypass the default behavior of how the handler updates the values More...
 
template<typename FuncT , typename T >
void mark_begin (handler_type &&, FuncT &&f, T &&val, enable_if_acceptable_t< T, int >=0)
 overload which uses a lambda to bypass the default behavior of how the handler updates the values and takes a handler to ensure proper overload resolution More...
 
template<typename T >
void mark_end (T &&val, enable_if_acceptable_t< T, int >=0)
 The combination of mark_begin(...) and mark_end(...) can be used to store some initial data which may be needed later. When mark_end(...) is called, the value is updated with the difference of the value provided to mark_end and the temporary stored during mark_begin. It may be valid to call mark_end without calling mark_begin but the result will effectively be a more expensive version of calling store. More...
 
template<typename T >
void mark_end (handler_type &&, T &&val, enable_if_acceptable_t< T, int >=0)
 overload which takes a handler to ensure proper overload resolution More...
 
template<typename FuncT , typename T >
void mark_end (FuncT &&f, T &&val, enable_if_acceptable_t< T, int >=0)
 overload which uses a lambda to bypass the default behavior of how the handler updates the values More...
 
template<typename FuncT , typename T >
void mark_end (handler_type &&, FuncT &&f, T &&val, enable_if_acceptable_t< T, int >=0)
 overload which uses a lambda to bypass the default behavior of how the handler updates the values and takes a handler to ensure proper overload resolution More...
 
template<typename T >
this_typeadd_secondary (const std::string &_key, T &&val, enable_if_acceptable_t< T, int >=0)
 add a secondary value to the current node in the call-graph. When TIMEMORY_ADD_SECONDARY is enabled contents of this map will be added as direct children of the current node in the call-graph. This is useful for finer-grained details that might not always be desirable to display More...
 
template<typename T >
this_typeadd_secondary (const std::string &_key, handler_type &&h, T &&val, enable_if_acceptable_t< T, int >=0)
 overload which takes a handler to ensure proper overload resolution More...
 
template<typename FuncT , typename T >
this_typeadd_secondary (const std::string &_key, FuncT &&f, T &&val, enable_if_acceptable_t< T, int >=0)
 overload which uses a lambda to bypass the default behavior of how the handler updates the values More...
 
template<typename FuncT , typename T >
this_typeadd_secondary (const std::string &_key, handler_type &&h, FuncT &&f, T &&val, enable_if_acceptable_t< T, int >=0)
 overload which uses a lambda to bypass the default behavior of how the handler updates the values and takes a handler to ensure proper overload resolution More...
 
void set_value (const value_type &v)
 set the current value More...
 
void set_value (value_type &&v)
 set the current value via move More...
 
void set_last (value_type &&_v)
 
void set_last (value_type &_v)
 
value_type get_last () const
 
template<typename T >
data_tracker< InpT, Tag > * add_secondary (const std::string &_key, T &&val, enable_if_acceptable_t< T, int >)
 
template<typename T >
data_tracker< InpT, Tag > * add_secondary (const std::string &_key, handler_type &&h, T &&val, enable_if_acceptable_t< T, int >)
 
template<typename FuncT , typename T >
data_tracker< InpT, Tag > * add_secondary (const std::string &_key, FuncT &&f, T &&val, enable_if_acceptable_t< T, int >)
 
template<typename FuncT , typename T >
data_tracker< InpT, Tag > * add_secondary (const std::string &_key, handler_type &&h, FuncT &&f, T &&val, enable_if_acceptable_t< T, int >)
 

Static Public Member Functions

static std::string & label ()
 a reference is returned here so that it can be easily updated More...
 
static std::string & description ()
 a reference is returned here so that it can be easily updated More...
 
static auto & get_unit ()
 this returns a reference so that it can be easily modified More...
 
template<typename... Args>
static opaque get_opaque (Args &&...)
 

Friends

struct operation::record< this_type >
 
struct operation::start< this_type >
 
struct operation::stop< this_type >
 
struct operation::set_started< this_type >
 
struct operation::set_stopped< this_type >
 

Detailed Description

template<typename InpT, typename Tag>
struct tim::component::data_tracker< InpT, Tag >

This component is provided to facilitate data tracking. The first template parameter is the type of data to be tracked, the second is a custom tag for differentiating trackers which handle the same data types but record different high-level data.

Usage:

// declarations
struct myproject {};
using itr_tracker_type = data_tracker<uint64_t, myproject>;
using err_tracker_type = data_tracker<double, myproject>;
// add statistics capabilities
TIMEMORY_STATISTICS_TYPE(itr_tracker_type, int64_t)
TIMEMORY_STATISTICS_TYPE(err_tracker_type, double)
// set the label and descriptions
itr_tracker_type, "myproject_iterations", "short desc", "long description")
err_tracker_type, "myproject_convergence", "short desc", "long description")
// this is the generic bundle pairing a timer with an iteration tracker
// using this and not updating the iteration tracker will create entries
// in the call-graph with zero iterations.
using bundle_t = tim::auto_tuple<wall_clock, itr_tracker_type>;
// this is a dedicated bundle for adding data-tracker entries. This style
// can also be used with the iteration tracker or you can bundle
// both trackers together. The auto_tuple will call start on construction
// and stop on destruction so once can construct a nameless temporary of the
// this bundle type and call store(...) on the nameless tmp. This will
// ensure that the statistics are updated for each entry
//
using err_bundle_t = tim::auto_tuple<err_tracker_type>;
// usage in a function is implied below
double err = std::numeric_limits<double>::max();
const double tolerance = 1.0e-6;
bundle_t t("iteration_time");
while(err > tolerance)
{
// store the starting error
double initial_err = err;
// add 1 for each iteration. Stats only updated when t is destroyed or t.stop() is
// called t.store(std::plus<uint64_t>{}, 1);
// ... do something ...
// construct a nameless temporary which records the change in the error and
// update the statistics <-- "foo" will have mean/min/max/stddev of the
// error
err_bundle_t{ "foo" }.store(err - initial_err);
// NOTE: std::plus is used with t above bc it has multiple components so std::plus
// helps ensure 1 doesn't get added to some other component with `store(int)`
// In above err_bundle_t, there is only one component so there is not concern.
}
#define TIMEMORY_METADATA_SPECIALIZATION(TYPE, LABEL, BASIC_DESC,...)
Specialization of the property specialization.
Definition: macros.hpp:288
#define TIMEMORY_STATISTICS_TYPE(COMPONENT, TYPE)
Definition: macros.hpp:207
STL namespace.
::tim::statistics< Tp > max(::tim::statistics< Tp > lhs, const Tp &rhs)
Definition: statistics.hpp:320
Definition: kokkosp.cpp:39
while(exe_name.find('\\') !=std::string::npos) exe_name
static std::string & description()
a reference is returned here so that it can be easily updated
Definition: components.hpp:478

When creating new data trackers, it is recommended to have this in header:

TIMEMORY_DECLARE_EXTERN_COMPONENT(custom_data_tracker_t, true, data_type)
#define TIMEMORY_DECLARE_EXTERN_COMPONENT(NAME, HAS_DATA,...)
Definition: macros.hpp:720
base_data_t< data_tracker< InpT, Tag >, InpT > data_type

And this in one source file (preferably one that is not re-compiled often)

TIMEMORY_INSTANTIATE_EXTERN_COMPONENT(custom_data_tracker_t, true, data_type)
TIMEMORY_INITIALIZE_STORAGE(custom_data_tracker_t)
#define TIMEMORY_INITIALIZE_STORAGE(...)
Definition: macros.hpp:362
#define TIMEMORY_INSTANTIATE_EXTERN_COMPONENT(NAME, HAS_DATA,...)
Definition: macros.hpp:731

where custom_data_tracker_t is the custom data tracker type (or an alias to the type) and data_type is the data type being tracked.

Definition at line 147 of file components.hpp.

Member Typedef Documentation

◆ base_type

template<typename InpT , typename Tag >
using tim::component::data_tracker< InpT, Tag >::base_type = base<this_type, value_type>

Definition at line 151 of file components.hpp.

◆ handler_type

template<typename InpT , typename Tag >
using tim::component::data_tracker< InpT, Tag >::handler_type = data::handler<InpT, Tag>

Definition at line 152 of file components.hpp.

◆ storage_type

Definition at line 66 of file declaration.hpp.

◆ this_type

template<typename InpT , typename Tag >
using tim::component::data_tracker< InpT, Tag >::this_type = data_tracker<InpT, Tag>

Definition at line 150 of file components.hpp.

◆ value_type

template<typename InpT , typename Tag >
using tim::component::data_tracker< InpT, Tag >::value_type = InpT

Definition at line 149 of file components.hpp.

Member Function Documentation

◆ add_secondary() [1/8]

template<typename InpT , typename Tag >
template<typename FuncT , typename T >
data_tracker< InpT, Tag > * tim::component::data_tracker< InpT, Tag >::add_secondary ( const std::string &  _key,
FuncT &&  f,
T &&  val,
enable_if_acceptable_t< T, int >   
)

Definition at line 671 of file components.hpp.

673{
674 this_type _tmp{};
675 if(get_is_running())
676 start_t{ _tmp };
677 _tmp.store(std::forward<FuncT>(f), std::forward<T>(val));
678 if(get_is_running())
679 stop_t{ _tmp };
680 auto& _map = *get_secondary_map();
681 if(_map.empty())
682 _map.reserve(20);
683 _map.emplace(_key, std::move(_tmp));
684 return &(_map[_key]);
685}
data_tracker< InpT, Tag > this_type
Definition: components.hpp:150

◆ add_secondary() [2/8]

template<typename InpT , typename Tag >
template<typename FuncT , typename T >
this_type * tim::component::data_tracker< InpT, Tag >::add_secondary ( const std::string &  _key,
FuncT &&  f,
T &&  val,
enable_if_acceptable_t< T, int >  = 0 
)

overload which uses a lambda to bypass the default behavior of how the handler updates the values

◆ add_secondary() [3/8]

template<typename InpT , typename Tag >
template<typename FuncT , typename T >
data_tracker< InpT, Tag > * tim::component::data_tracker< InpT, Tag >::add_secondary ( const std::string &  _key,
handler_type &&  h,
FuncT &&  f,
T &&  val,
enable_if_acceptable_t< T, int >   
)

Definition at line 690 of file components.hpp.

692{
693 this_type _tmp{};
694 if(get_is_running())
695 start_t{ _tmp };
696 _tmp.store(std::forward<handler_type>(h), std::forward<FuncT>(f),
697 std::forward<T>(val));
698 if(get_is_running())
699 stop_t{ _tmp };
700 auto& _map = *get_secondary_map();
701 if(_map.empty())
702 _map.reserve(20);
703 _map.emplace(_key, std::move(_tmp));
704 return &(_map[_key]);
705}

◆ add_secondary() [4/8]

template<typename InpT , typename Tag >
template<typename FuncT , typename T >
this_type * tim::component::data_tracker< InpT, Tag >::add_secondary ( const std::string &  _key,
handler_type &&  h,
FuncT &&  f,
T &&  val,
enable_if_acceptable_t< T, int >  = 0 
)

overload which uses a lambda to bypass the default behavior of how the handler updates the values and takes a handler to ensure proper overload resolution

◆ add_secondary() [5/8]

template<typename InpT , typename Tag >
template<typename T >
data_tracker< InpT, Tag > * tim::component::data_tracker< InpT, Tag >::add_secondary ( const std::string &  _key,
handler_type &&  h,
T &&  val,
enable_if_acceptable_t< T, int >   
)

Definition at line 652 of file components.hpp.

654{
655 this_type _tmp{};
656 if(get_is_running())
657 start_t{ _tmp };
658 _tmp.store(std::forward<handler_type>(h), std::forward<T>(val));
659 if(get_is_running())
660 stop_t{ _tmp };
661 auto& _map = *get_secondary_map();
662 if(_map.empty())
663 _map.reserve(20);
664 _map.emplace(_key, std::move(_tmp));
665 return &(_map[_key]);
666}

◆ add_secondary() [6/8]

template<typename InpT , typename Tag >
template<typename T >
this_type * tim::component::data_tracker< InpT, Tag >::add_secondary ( const std::string &  _key,
handler_type &&  h,
T &&  val,
enable_if_acceptable_t< T, int >  = 0 
)

overload which takes a handler to ensure proper overload resolution

◆ add_secondary() [7/8]

template<typename InpT , typename Tag >
template<typename T >
data_tracker< InpT, Tag > * tim::component::data_tracker< InpT, Tag >::add_secondary ( const std::string &  _key,
T &&  val,
enable_if_acceptable_t< T, int >   
)

Definition at line 635 of file components.hpp.

637{
638 this_type _tmp{};
639 if(get_is_running())
640 start_t{ _tmp };
641 _tmp.store(std::forward<T>(val));
642 if(get_is_running())
643 stop_t{ _tmp };
644 auto& _map = *get_secondary_map();
645 _map.emplace(_key, std::move(_tmp));
646 return &(_map[_key]);
647}

◆ add_secondary() [8/8]

template<typename InpT , typename Tag >
template<typename T >
this_type * tim::component::data_tracker< InpT, Tag >::add_secondary ( const std::string &  _key,
T &&  val,
enable_if_acceptable_t< T, int >  = 0 
)

add a secondary value to the current node in the call-graph. When TIMEMORY_ADD_SECONDARY is enabled contents of this map will be added as direct children of the current node in the call-graph. This is useful for finer-grained details that might not always be desirable to display

◆ description()

template<typename InpT , typename Tag >
std::string & tim::component::data_tracker< InpT, Tag >::description
static

a reference is returned here so that it can be easily updated

Definition at line 478 of file components.hpp.

479{
480 static std::string _instance = []() {
482 {
483 auto meta_desc = metadata<this_type>::description();
485 {
486 auto meta_extra_desc = metadata<this_type>::extra_description();
487 meta_desc += ". ";
488 meta_desc += meta_extra_desc;
489 }
490 return meta_desc;
491 }
492 std::stringstream ss;
493 ss << "Data tracker for data of type " << demangle<InpT>() << " for "
494 << demangle<Tag>();
495 return ss.str();
496 }();
497 return _instance;
498}
tim::mpl::apply< std::string > string
Definition: macros.hpp:53
static std::string extra_description()
Definition: metadata.hpp:51
static constexpr bool specialized()
Definition: metadata.hpp:52
static std::string description()
Definition: metadata.hpp:77

References tim::debug, tim::component::metadata< Tp >::description(), tim::component::metadata< Tp >::extra_description(), and tim::verbose.

Referenced by tim::invoke_preinit< kokkosp::memory_tracker >().

◆ get()

template<typename InpT , typename Tag >
auto tim::component::data_tracker< InpT, Tag >::get ( ) const
inline

get the data in the final form after unit conversion

Definition at line 252 of file components.hpp.

252{ return handler_type::get(*this); }
static decltype(auto) get(const T &obj)
this function is returns the current value
Definition: handler.hpp:60

References tim::data::handler< V, Tag >::get().

◆ get_display()

template<typename InpT , typename Tag >
auto tim::component::data_tracker< InpT, Tag >::get_display ( ) const
inline

get the data in a form suitable for display

Definition at line 255 of file components.hpp.

255{ return handler_type::get_display(*this); }
static decltype(auto) get_display(const T &obj)
this function is returns the current value in a form suitable for display. It may be necessary to spe...
Definition: handler.hpp:68

References tim::data::handler< V, Tag >::get_display().

◆ get_last()

template<typename InpT , typename Tag >
value_type tim::component::data_tracker< InpT, Tag >::get_last ( ) const
inline

Definition at line 409 of file components.hpp.

409{ return m_last_value; }

◆ get_opaque()

template<typename... Args>
static opaque tim::component::empty_base::get_opaque ( Args &&  ...)
inlinestaticinherited

Definition at line 72 of file declaration.hpp.

73 {
74 return opaque{};
75 }

◆ get_secondary()

template<typename InpT , typename Tag >
auto tim::component::data_tracker< InpT, Tag >::get_secondary ( ) const
inline

map of the secondary entries. When TIMEMORY_ADD_SECONDARY is enabled contents of this map will be added as direct children of the current node in the call-graph.

Definition at line 260 of file components.hpp.

261 {
262 return (m_secondary) ? *m_secondary : secondary_map_t{};
263 }

◆ get_unit()

template<typename InpT , typename Tag >
static auto & tim::component::data_tracker< InpT, Tag >::get_unit ( )
inlinestatic

this returns a reference so that it can be easily modified

Definition at line 239 of file components.hpp.

240 {
241 static auto _unit = base_type::get_unit();
242 return _unit;
243 }
static int64_t get_unit()

References tim::component::base< Tp, Value >::get_unit().

◆ label()

template<typename InpT , typename Tag >
std::string & tim::component::data_tracker< InpT, Tag >::label
inlinestatic

a reference is returned here so that it can be easily updated

Definition at line 466 of file components.hpp.

467{
468 static std::string _instance = []() {
471 return TIMEMORY_JOIN("_", typeid(Tag).name(), typeid(InpT).name());
472 }();
473 return _instance;
474}
static std::string label()
Definition: metadata.hpp:68
#define TIMEMORY_JOIN(delim,...)
Definition: macros.hpp:90

References TIMEMORY_JOIN.

Referenced by tim::invoke_preinit< kokkosp::memory_tracker >().

◆ mark_begin() [1/4]

template<typename InpT , typename Tag >
template<typename FuncT , typename T >
void tim::component::data_tracker< InpT, Tag >::mark_begin ( FuncT &&  f,
T &&  val,
enable_if_acceptable_t< T, int >  = 0 
)

overload which uses a lambda to bypass the default behavior of how the handler updates the values

Definition at line 593 of file components.hpp.

594{
595 handler_type::begin(get_temporary(), std::forward<FuncT>(f),
596 compute_type::divide(std::forward<T>(val), get_unit()));
597}
static auto & get_unit()
this returns a reference so that it can be easily modified
Definition: components.hpp:239
static void begin(value_type &obj, const value_type &v)
this function sets the value of the temporary in mark_begin.
Definition: handler.hpp:94
static decltype(auto) divide(type &_l, const V &_r)
Definition: compute.hpp:111

References tim::math::divide().

◆ mark_begin() [2/4]

template<typename InpT , typename Tag >
template<typename FuncT , typename T >
void tim::component::data_tracker< InpT, Tag >::mark_begin ( handler_type &&  ,
FuncT &&  f,
T &&  val,
enable_if_acceptable_t< T, int >  = 0 
)

overload which uses a lambda to bypass the default behavior of how the handler updates the values and takes a handler to ensure proper overload resolution

Definition at line 613 of file components.hpp.

615{
616 handler_type::begin(get_temporary(), std::forward<FuncT>(f),
617 compute_type::divide(std::forward<T>(val), get_unit()));
618}

References tim::math::divide().

◆ mark_begin() [3/4]

template<typename InpT , typename Tag >
template<typename T >
void tim::component::data_tracker< InpT, Tag >::mark_begin ( handler_type &&  ,
T &&  val,
enable_if_acceptable_t< T, int >  = 0 
)

overload which takes a handler to ensure proper overload resolution

Definition at line 573 of file components.hpp.

575{
576 handler_type::begin(get_temporary(),
577 compute_type::divide(std::forward<T>(val), get_unit()));
578}

References tim::math::divide().

◆ mark_begin() [4/4]

template<typename InpT , typename Tag >
template<typename T >
void tim::component::data_tracker< InpT, Tag >::mark_begin ( T &&  val,
enable_if_acceptable_t< T, int >  = 0 
)

The combination of mark_begin(...) and mark_end(...) can be used to store some initial data which may be needed later. When mark_end(...) is called, the value is updated with the difference of the value provided to mark_end and the temporary stored during mark_begin.

Definition at line 554 of file components.hpp.

555{
556 handler_type::begin(get_temporary(),
557 compute_type::divide(std::forward<T>(val), get_unit()));
558}

References tim::math::divide().

◆ mark_end() [1/4]

template<typename InpT , typename Tag >
template<typename FuncT , typename T >
void tim::component::data_tracker< InpT, Tag >::mark_end ( FuncT &&  f,
T &&  val,
enable_if_acceptable_t< T, int >  = 0 
)

overload which uses a lambda to bypass the default behavior of how the handler updates the values

Definition at line 602 of file components.hpp.

603{
604 handler_type::end(*this, std::forward<FuncT>(f),
605 compute_type::divide(std::forward<T>(val), get_unit()));
606 if(!get_is_running())
607 ++laps;
608}
static void end(T &obj, const value_type &v)
this function computes the difference between the provided value and the temporary from mark_begin an...
Definition: handler.hpp:106

References tim::math::divide().

◆ mark_end() [2/4]

template<typename InpT , typename Tag >
template<typename FuncT , typename T >
void tim::component::data_tracker< InpT, Tag >::mark_end ( handler_type &&  ,
FuncT &&  f,
T &&  val,
enable_if_acceptable_t< T, int >  = 0 
)

overload which uses a lambda to bypass the default behavior of how the handler updates the values and takes a handler to ensure proper overload resolution

Definition at line 623 of file components.hpp.

625{
626 handler_type::end(*this, std::forward<FuncT>(f),
627 compute_type::divide(std::forward<T>(val), get_unit()));
628 if(!get_is_running())
629 ++laps;
630}

References tim::math::divide().

◆ mark_end() [3/4]

template<typename InpT , typename Tag >
template<typename T >
void tim::component::data_tracker< InpT, Tag >::mark_end ( handler_type &&  ,
T &&  val,
enable_if_acceptable_t< T, int >  = 0 
)

overload which takes a handler to ensure proper overload resolution

Definition at line 583 of file components.hpp.

584{
585 handler_type::end(*this, compute_type::divide(std::forward<T>(val), get_unit()));
586 if(!get_is_running())
587 ++laps;
588}

References tim::math::divide().

◆ mark_end() [4/4]

template<typename InpT , typename Tag >
template<typename T >
void tim::component::data_tracker< InpT, Tag >::mark_end ( T &&  val,
enable_if_acceptable_t< T, int >  = 0 
)

The combination of mark_begin(...) and mark_end(...) can be used to store some initial data which may be needed later. When mark_end(...) is called, the value is updated with the difference of the value provided to mark_end and the temporary stored during mark_begin. It may be valid to call mark_end without calling mark_begin but the result will effectively be a more expensive version of calling store.

Definition at line 563 of file components.hpp.

564{
565 handler_type::end(*this, compute_type::divide(std::forward<T>(val), get_unit()));
566 if(!get_is_running())
567 ++laps;
568}

References tim::math::divide().

◆ set_last() [1/2]

template<typename InpT , typename Tag >
void tim::component::data_tracker< InpT, Tag >::set_last ( value_type &&  _v)
inline

Definition at line 407 of file components.hpp.

407{ m_last_value = std::move(_v); }

◆ set_last() [2/2]

template<typename InpT , typename Tag >
void tim::component::data_tracker< InpT, Tag >::set_last ( value_type _v)
inline

Definition at line 408 of file components.hpp.

408{ m_last_value = _v; }

◆ set_value() [1/2]

template<typename InpT , typename Tag >
void tim::component::data_tracker< InpT, Tag >::set_value ( const value_type v)
inline

set the current value

Definition at line 400 of file components.hpp.

400{ value = v; }

◆ set_value() [2/2]

template<typename InpT , typename Tag >
void tim::component::data_tracker< InpT, Tag >::set_value ( value_type &&  v)
inline

set the current value via move

Definition at line 403 of file components.hpp.

403{ value = std::move(v); }

◆ start()

template<typename InpT , typename Tag >
void tim::component::data_tracker< InpT, Tag >::start ( )
inline

Definition at line 248 of file components.hpp.

248{}

◆ stop()

template<typename InpT , typename Tag >
void tim::component::data_tracker< InpT, Tag >::stop ( )
inline

Definition at line 249 of file components.hpp.

249{}

◆ store() [1/4]

template<typename InpT , typename Tag >
template<typename FuncT , typename T >
auto tim::component::data_tracker< InpT, Tag >::store ( FuncT &&  f,
T &&  val,
enable_if_acceptable_t< T, int >  = 0 
) -> decltype(std::declval<handler_type>().store(*this, std::forward<FuncT>(f), std::forward<T>(val)), void())

overload which uses a lambda to bypass the default behavior of how the handler updates the values

Definition at line 525 of file components.hpp.

529{
530 set_last(compute_type::divide(std::forward<T>(val), get_unit()));
531 handler_type::store(*this, std::forward<FuncT>(f), get_last());
532 if(!get_is_running())
533 ++laps;
534}
void set_last(value_type &&_v)
Definition: components.hpp:407
value_type get_last() const
Definition: components.hpp:409
static void store(T &obj, const value_type &v)
this function is used to store a value
Definition: handler.hpp:79

References tim::math::divide(), and tim::invoke::store().

◆ store() [2/4]

template<typename InpT , typename Tag >
template<typename FuncT , typename T >
auto tim::component::data_tracker< InpT, Tag >::store ( handler_type &&  ,
FuncT &&  f,
T &&  val,
enable_if_acceptable_t< T, int >  = 0 
) -> decltype(std::declval<handler_type>().store(*this, std::forward<FuncT>(f), std::forward<T>(val)), void())

overload which uses a lambda to bypass the default behavior of how the handler updates the values and takes a handler to ensure proper overload resolution

Definition at line 539 of file components.hpp.

544{
545 set_last(compute_type::divide(std::forward<T>(val), get_unit()));
546 handler_type::store(*this, std::forward<FuncT>(f), get_last());
547 if(!get_is_running())
548 ++laps;
549}

References tim::math::divide(), and tim::invoke::store().

◆ store() [3/4]

template<typename InpT , typename Tag >
template<typename T >
void tim::component::data_tracker< InpT, Tag >::store ( handler_type &&  ,
T &&  val,
enable_if_acceptable_t< T, int >  = 0 
)

overload which takes a handler to ensure proper overload resolution

Definition at line 514 of file components.hpp.

515{
516 set_last(compute_type::divide(std::forward<T>(val), get_unit()));
518 if(!get_is_running())
519 ++laps;
520}

References tim::math::divide(), and tim::invoke::store().

◆ store() [4/4]

template<typename InpT , typename Tag >
template<typename T >
void tim::component::data_tracker< InpT, Tag >::store ( T &&  val,
enable_if_acceptable_t< T, int >  = 0 
)

store some data. Uses tim::data::handler for the type.

Definition at line 503 of file components.hpp.

504{
505 set_last(compute_type::divide(std::forward<T>(val), get_unit()));
507 if(!get_is_running())
508 ++laps;
509}

References tim::math::divide(), and tim::invoke::store().

Friends And Related Function Documentation

◆ operation::record< this_type >

template<typename InpT , typename Tag >
friend struct operation::record< this_type >
friend

Definition at line 690 of file components.hpp.

◆ operation::set_started< this_type >

template<typename InpT , typename Tag >
friend struct operation::set_started< this_type >
friend

Definition at line 690 of file components.hpp.

◆ operation::set_stopped< this_type >

template<typename InpT , typename Tag >
friend struct operation::set_stopped< this_type >
friend

Definition at line 690 of file components.hpp.

◆ operation::start< this_type >

template<typename InpT , typename Tag >
friend struct operation::start< this_type >
friend

Definition at line 690 of file components.hpp.

◆ operation::stop< this_type >

template<typename InpT , typename Tag >
friend struct operation::stop< this_type >
friend

Definition at line 690 of file components.hpp.


The documentation for this struct was generated from the following file: