Empirical
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
emp::TypeTracker< TYPES > Struct Template Reference

#include <TypeTracker.h>

Public Types

using this_t = TypeTracker< TYPES... >
 
template<typename REAL_T >
using wrap_t = TypeTracker_Class< REAL_T, get_type_index< REAL_T, TYPES... >() >
 

Public Member Functions

 TypeTracker ()
 
 TypeTracker (const TypeTracker &)=default
 
 TypeTracker (TypeTracker &&)=default
 
TypeTrackeroperator= (const TypeTracker &)=default
 
TypeTrackeroperator= (TypeTracker &&)=default
 
 ~TypeTracker ()
 
template<typename REAL_T >
wrap_t< REAL_T > Wrap (REAL_T &&val)
 Convert an input value into a TypeTracker_Class maintaining the value (universal version) More...
 
template<typename REAL_T >
wrap_t< REAL_T > * New (REAL_T &val)
 Create an input value in a TypeTracker_Class maintaining the value (reference version) More...
 
template<typename REAL_T >
wrap_t< REAL_T > * New (REAL_T &&val)
 Create an input value in a TypeTracker_Class maintaining the value (move version) More...
 
template<typename TEST_T >
bool IsType (TrackedType &tt)
 Test if the tracked type is TEST_T. More...
 
template<typename TEST_T >
bool IsType (TrackedType *tt)
 Test if the tracked type points to TEST_T. More...
 
template<typename REAL_T >
REAL_T ToType (TrackedType &tt)
 Convert the tracked type back to REAL_T. Assert that this is type safe! More...
 
template<typename REAL_T >
REAL_T ToType (TrackedType *tt)
 Convert the tracked type pointer back to REAL_T. Assert that this is type safe! More...
 
template<typename OUT_T >
OUT_T Cast (TrackedType &tt)
 Cast the tracked type to OUT_T. Try to do so even if NOT original type! More...
 
template<typename OUT_T >
OUT_T Cast (TrackedType *tt)
 Cast the tracked type pointer to OUT_T. Try to do so even if NOT original type! More...
 
template<typename... Ts>
this_tAddFunction (std::function< void(Ts...)> fun)
 
template<typename... Ts>
this_tAddFunction (void(*fun)(Ts...))
 
template<typename... Ts>
void RunFunction (Ts...args)
 Run the appropriate function based on the argument types received. More...
 
template<typename... Ts>
void operator() (Ts...args)
 Call TypeTracker as a function (refers call to RunFunction) More...
 

Static Public Member Functions

static constexpr size_t GetNumTypes ()
 How many types are we working with? More...
 
static constexpr size_t GetNumCombos (size_t vals=2)
 How many combinations of V types are there? More...
 
static constexpr size_t GetCumCombos (size_t vals=2)
 How many combinations are the of the given number of types OR FEWER? More...
 
template<typename T >
static constexpr size_t GetID ()
 Each type should have a unique ID. More...
 
template<typename T1 , typename T2 , typename... Ts>
static constexpr size_t GetID ()
 Each set of types should have an ID unique within that number of types. More...
 
template<typename... Ts>
static constexpr size_t GetComboID ()
 A ComboID should be unique across all size combinations. More...
 
static size_t GetTrackedID (const TrackedType &tt)
 A Tracked ID is simply the unique ID of the type being tracked. More...
 
template<typename... Ts>
static size_t GetTrackedID (const TrackedType &tt1, const TrackedType &tt2, const Ts &...ARGS)
 Or set of types being tracked... More...
 
static size_t GetTrackedID (TrackedType *tt)
 We should also about able to use a pointer to access tracked IDs. More...
 
template<typename... Ts>
static size_t GetTrackedID (TrackedType *tt1, TrackedType *tt2, Ts *...ARGS)
 A set of pointers to access tracked IDs. More...
 
template<typename... Ts>
static constexpr size_t GetTrackedComboID (Ts...ARGS)
 

Public Attributes

std::unordered_map< size_t, emp::GenericFunction * > fun_map
 fun_map is a hash table that maps a set of inputs to the appropriate function. More...
 

Detailed Description

template<typename... TYPES>
struct emp::TypeTracker< TYPES >

Dynamic functions that are indexed by parameter types; calls lookup the correct function to forward arguments into.

Member Typedef Documentation

template<typename... TYPES>
using emp::TypeTracker< TYPES >::this_t = TypeTracker<TYPES...>
template<typename... TYPES>
template<typename REAL_T >
using emp::TypeTracker< TYPES >::wrap_t = TypeTracker_Class< REAL_T, get_type_index<REAL_T,TYPES...>() >

Constructor & Destructor Documentation

template<typename... TYPES>
emp::TypeTracker< TYPES >::TypeTracker ( )
inline
template<typename... TYPES>
emp::TypeTracker< TYPES >::TypeTracker ( const TypeTracker< TYPES > &  )
default
template<typename... TYPES>
emp::TypeTracker< TYPES >::TypeTracker ( TypeTracker< TYPES > &&  )
default
template<typename... TYPES>
emp::TypeTracker< TYPES >::~TypeTracker ( )
inline

Member Function Documentation

template<typename... TYPES>
template<typename... Ts>
this_t& emp::TypeTracker< TYPES >::AddFunction ( std::function< void(Ts...)>  fun)
inline

Add a new std::function that this TypeTracker should call if the appropriate types are passed in.

template<typename... TYPES>
template<typename... Ts>
this_t& emp::TypeTracker< TYPES >::AddFunction ( void(*)(Ts...)  fun)
inline

Add a new function pointer that this TypeTracker should call if the appropriate types are passed in.

template<typename... TYPES>
template<typename OUT_T >
OUT_T emp::TypeTracker< TYPES >::Cast ( TrackedType tt)
inline

Cast the tracked type to OUT_T. Try to do so even if NOT original type!

template<typename... TYPES>
template<typename OUT_T >
OUT_T emp::TypeTracker< TYPES >::Cast ( TrackedType tt)
inline

Cast the tracked type pointer to OUT_T. Try to do so even if NOT original type!

template<typename... TYPES>
template<typename... Ts>
static constexpr size_t emp::TypeTracker< TYPES >::GetComboID ( )
inlinestatic

A ComboID should be unique across all size combinations.

template<typename... TYPES>
static constexpr size_t emp::TypeTracker< TYPES >::GetCumCombos ( size_t  vals = 2)
inlinestatic

How many combinations are the of the given number of types OR FEWER?

template<typename... TYPES>
template<typename T >
static constexpr size_t emp::TypeTracker< TYPES >::GetID ( )
inlinestatic

Each type should have a unique ID.

template<typename... TYPES>
template<typename T1 , typename T2 , typename... Ts>
static constexpr size_t emp::TypeTracker< TYPES >::GetID ( )
inlinestatic

Each set of types should have an ID unique within that number of types.

template<typename... TYPES>
static constexpr size_t emp::TypeTracker< TYPES >::GetNumCombos ( size_t  vals = 2)
inlinestatic

How many combinations of V types are there?

template<typename... TYPES>
static constexpr size_t emp::TypeTracker< TYPES >::GetNumTypes ( )
inlinestatic

How many types are we working with?

template<typename... TYPES>
template<typename... Ts>
static constexpr size_t emp::TypeTracker< TYPES >::GetTrackedComboID ( Ts...  ARGS)
inlinestatic

A tracked COMBO ID, is an ID for this combination of types, unique among all possible type combinations. Consistent with GetComboID with the same underlying types.

template<typename... TYPES>
static size_t emp::TypeTracker< TYPES >::GetTrackedID ( const TrackedType tt)
inlinestatic

A Tracked ID is simply the unique ID of the type being tracked.

template<typename... TYPES>
template<typename... Ts>
static size_t emp::TypeTracker< TYPES >::GetTrackedID ( const TrackedType tt1,
const TrackedType tt2,
const Ts &...  ARGS 
)
inlinestatic

Or set of types being tracked...

template<typename... TYPES>
static size_t emp::TypeTracker< TYPES >::GetTrackedID ( TrackedType tt)
inlinestatic

We should also about able to use a pointer to access tracked IDs.

template<typename... TYPES>
template<typename... Ts>
static size_t emp::TypeTracker< TYPES >::GetTrackedID ( TrackedType tt1,
TrackedType tt2,
Ts *...  ARGS 
)
inlinestatic

A set of pointers to access tracked IDs.

template<typename... TYPES>
template<typename TEST_T >
bool emp::TypeTracker< TYPES >::IsType ( TrackedType tt)
inline

Test if the tracked type is TEST_T.

template<typename... TYPES>
template<typename TEST_T >
bool emp::TypeTracker< TYPES >::IsType ( TrackedType tt)
inline

Test if the tracked type points to TEST_T.

template<typename... TYPES>
template<typename REAL_T >
wrap_t<REAL_T>* emp::TypeTracker< TYPES >::New ( REAL_T &  val)
inline

Create an input value in a TypeTracker_Class maintaining the value (reference version)

template<typename... TYPES>
template<typename REAL_T >
wrap_t<REAL_T>* emp::TypeTracker< TYPES >::New ( REAL_T &&  val)
inline

Create an input value in a TypeTracker_Class maintaining the value (move version)

template<typename... TYPES>
template<typename... Ts>
void emp::TypeTracker< TYPES >::operator() ( Ts...  args)
inline

Call TypeTracker as a function (refers call to RunFunction)

template<typename... TYPES>
TypeTracker& emp::TypeTracker< TYPES >::operator= ( const TypeTracker< TYPES > &  )
default
template<typename... TYPES>
TypeTracker& emp::TypeTracker< TYPES >::operator= ( TypeTracker< TYPES > &&  )
default
template<typename... TYPES>
template<typename... Ts>
void emp::TypeTracker< TYPES >::RunFunction ( Ts...  args)
inline

Run the appropriate function based on the argument types received.

template<typename... TYPES>
template<typename REAL_T >
REAL_T emp::TypeTracker< TYPES >::ToType ( TrackedType tt)
inline

Convert the tracked type back to REAL_T. Assert that this is type safe!

template<typename... TYPES>
template<typename REAL_T >
REAL_T emp::TypeTracker< TYPES >::ToType ( TrackedType tt)
inline

Convert the tracked type pointer back to REAL_T. Assert that this is type safe!

template<typename... TYPES>
template<typename REAL_T >
wrap_t<REAL_T> emp::TypeTracker< TYPES >::Wrap ( REAL_T &&  val)
inline

Convert an input value into a TypeTracker_Class maintaining the value (universal version)

Member Data Documentation

template<typename... TYPES>
std::unordered_map<size_t, emp::GenericFunction *> emp::TypeTracker< TYPES >::fun_map

fun_map is a hash table that maps a set of inputs to the appropriate function.


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