Public Types | Static Public Member Functions | Static Protected Member Functions | List of all members
ana::LoadFromRegistry< BaseClass > Class Template Reference

Mechanism for derived classes to register their LoadFrom functions. More...

#include "/cvmfs/nova.opensciencegrid.org/externals/cafanacore/v01.11/src/CAFAna/Core/LoadFromRegistry.h"

Public Types

template<class T >
using FuncAny_t = std::function< std::unique_ptr< T >(TDirectory *, const std::string &)>
 
using Func_t = FuncAny_t< BaseClass >
 

Static Public Member Functions

template<class T >
static void Register (const std::string &tag, FuncAny_t< T > func)
 
static Func_t Get (const std::string &tag)
 

Static Protected Member Functions

static std::map< std::string, Func_t > & Map ()
 

Detailed Description

template<typename BaseClass>
class ana::LoadFromRegistry< BaseClass >

Mechanism for derived classes to register their LoadFrom functions.

Definition at line 14 of file LoadFromRegistry.h.

Member Typedef Documentation

template<typename BaseClass >
using ana::LoadFromRegistry< BaseClass >::Func_t = FuncAny_t<BaseClass>

Definition at line 21 of file LoadFromRegistry.h.

template<typename BaseClass >
template<class T >
using ana::LoadFromRegistry< BaseClass >::FuncAny_t = std::function<std::unique_ptr<T>(TDirectory*, const std::string&)>

Definition at line 18 of file LoadFromRegistry.h.

Member Function Documentation

template<typename BaseClass >
static Func_t ana::LoadFromRegistry< BaseClass >::Get ( const std::string tag)
inlinestatic

Definition at line 33 of file LoadFromRegistry.h.

References febshutoff_auto::end, it, and ana::LoadFromRegistry< BaseClass >::Map().

Referenced by ana::LoadFrom< IDecomp >(), ana::LoadFrom< IExperiment >(), ana::LoadFrom< IExtrap >(), and ana::LoadFrom< IPrediction >().

34  {
35  auto it = Map().find(tag);
36  if(it == Map().end()) return 0;
37  return it->second;
38  }
set< int >::iterator it
static std::map< std::string, Func_t > & Map()
template<typename BaseClass >
static std::map<std::string, Func_t>& ana::LoadFromRegistry< BaseClass >::Map ( void  )
inlinestaticprotected

Definition at line 41 of file LoadFromRegistry.h.

References m.

Referenced by ana::LoadFromRegistry< BaseClass >::Get(), and ana::LoadFromRegistry< BaseClass >::Register().

42  {
43  // https://isocpp.org/wiki/faq/ctors#static-init-order
44  static auto m = new std::map<std::string, Func_t>;
45  return *m;
46  }
template<typename BaseClass >
template<class T >
static void ana::LoadFromRegistry< BaseClass >::Register ( const std::string tag,
FuncAny_t< T func 
)
inlinestatic

Definition at line 23 of file LoadFromRegistry.h.

References d, func(), ana::LoadFromRegistry< BaseClass >::Map(), getGoodRuns4SAM::n, string, and getGoodRuns4SAM::tag.

25  {
26  Map()[tag] = [func](TDirectory* d, const std::string& n)
27  {
28  // Convert the user's type
29  return std::unique_ptr<BaseClass>(func(d, n).release());
30  };
31  }
Float_t d
Definition: plot.C:236
double func(double x, double y)
static std::map< std::string, Func_t > & Map()
enum BeamMode string

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