iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nrt::LookupCache Class Reference

#include <nrt/PointCloud2/details/LookupCache.H>

A class for caching arbitrary templated function call results.

This class is used internally to cache results of expensive lookup operations that occur when iterators are created such as: Checking if any one of a set of fields is sparse Looking up the pointers for a set of dense fields

We keep track of a map (implementation may vary) between a hashed value computed from the previous function signatures and store the result of the computation and whether we can consider it to be dirty or not.

We also keep a single LRU cache for the least recently used item placed into the cache.

The dirty flag is set by the point cloud whenever the structure of its maps changes; that is if we add or delete fields or relevant records.

Definition at line 60 of file LookupCache.H.

Public Member Functions

 LookupCache ()
 Creates an empty cache.
 LookupCache (LookupCache const &other)=default
 Copy construction.
 LookupCache (LookupCache &&other)=default
 Move construction.
LookupCacheoperator= (LookupCache const &other)=default
LookupCacheoperator= (LookupCache &&other)=default
 Move assignment.
void markDirty ()
 Marks all data as dirty.
template<class FuncType , class OutputType , class... ParamTypes>
OutputType lookup (ParamTypes &&...params)


class cereal::access

Member Function Documentation

template<class FuncType , class OutputType , class... ParamTypes>
OutputType nrt::LookupCache::lookup ( ParamTypes &&...  params)

I'll lookup the value at a given hash and return if it I have it. If I don't have it or it is dirty, I'll run the function and update the value

Template Parameters
FuncTypeThe functor type, must have an apply static member that will be passing in the parameters and returning output type.
OutputTypeThe return type of the apply function in the functor
ParamTypesparameter types
paramsParameters passed to the apply function
The result of the computation

Example use (checking if we have sparse fields of type <int, bool>):

bool hasSparse = someCache.lookup<sparseExistHelper<int, bool>, bool>( itsData->itsSparseData );

Definition at line 56 of file LookupCacheImpl.H.

The documentation for this class was generated from the following files: