Belle II Software development
VectorOfObservers< FilterType > Class Template Reference

this observer does simply collect other observers which are to be executed during the call of the corresponding notify function(s) More...

Inheritance diagram for VectorOfObservers< FilterType >:
VoidObserver

Public Types

typedef std::function< void(const typename FilterType::argumentType &, const typename FilterType::argumentType &, const FilterType &, typename FilterType::variableType)> observerFunction
 a typedef to make the stuff more readable
 
using CStyleFunctionPointer = void(*)(const typename FilterType::argumentType &, const typename FilterType::argumentType &, const FilterType &, typename FilterType::variableType)
 a typedef to make the c-style pointer more readable (can not be done with classic typedef)
 

Static Public Member Functions

template<typename ... otherTypes>
static void notify (const FilterType &filterType, typename FilterType::variableType fResult, const typename FilterType::argumentType &outerHit, const typename FilterType::argumentType &innerHit, otherTypes ...)
 iterate over all stored Observers and execute their notify-function
 
template<typename ObserverType >
static void addObserver (observerFunction newObserver)
 collects observers to be executed during notify (can not be used so far, but is long-term goal)
 
template<typename ... types>
static void notify (const types &...)
 static method used by the observed object to notify the observer.
 
template<typename ... types>
static bool initialize (const types &...)
 static method used by the observed object to initialize the observer it is called once usually from the user.
 
template<typename ... types>
static void prepare (const types &...)
 static method used by the observed object to prepare the observer it is called by the boolean filter operator.
 
template<typename ... types>
static void collect (const types &...)
 static method used by the observed object to prepare the observer it is called by the boolean filter operator.
 
template<typename ... types>
static void terminate (const types &...)
 static method used by the observed object to terminate the observer.
 

Static Public Attributes

static std::vector< observerFunctionsm_collectedObservers = {}
 collects observers with std::function to be executed during notify (variant A)
 
static std::vector< CStyleFunctionPointersm_collectedObserversCSTYLE = {}
 collects observers with c-style function pointers to be executed during notify (variant B)
 

Detailed Description

template<class FilterType>
class VXDTFtwoHitFilterTest::VectorOfObservers< FilterType >

this observer does simply collect other observers which are to be executed during the call of the corresponding notify function(s)

Definition at line 167 of file twoHitFilters.cc.

Member Typedef Documentation

◆ CStyleFunctionPointer

using CStyleFunctionPointer = void(*)(const typename FilterType::argumentType&, const typename FilterType::argumentType&, const FilterType&, typename FilterType::variableType)

a typedef to make the c-style pointer more readable (can not be done with classic typedef)

Definition at line 175 of file twoHitFilters.cc.

◆ observerFunction

typedef std::function< void (const typename FilterType::argumentType&, const typename FilterType::argumentType&, const FilterType&, typename FilterType::variableType)> observerFunction

a typedef to make the stuff more readable

Definition at line 172 of file twoHitFilters.cc.

Member Function Documentation

◆ addObserver()

static void addObserver ( observerFunction  newObserver)
inlinestatic

collects observers to be executed during notify (can not be used so far, but is long-term goal)

Definition at line 203 of file twoHitFilters.cc.

204 {
205 VectorOfObservers<FilterType>::sm_collectedObservers.push_back(std::bind(&newObserver, std::placeholders::_1, std::placeholders::_2,
206 FilterType(), std::placeholders::_3));
207 }
static std::vector< observerFunction > sm_collectedObservers
collects observers with std::function to be executed during notify (variant A)

◆ collect()

static void collect ( const types &  ...)
inlinestaticinherited

static method used by the observed object to prepare the observer it is called by the boolean filter operator.

Definition at line 55 of file VoidObserver.h.

55{};

◆ initialize()

static bool initialize ( const types &  ...)
inlinestaticinherited

static method used by the observed object to initialize the observer it is called once usually from the user.

Definition at line 43 of file VoidObserver.h.

43{ return true; };

◆ notify() [1/2]

static void notify ( const FilterType &  filterType,
typename FilterType::variableType  fResult,
const typename FilterType::argumentType &  outerHit,
const typename FilterType::argumentType &  innerHit,
otherTypes ...   
)
inlinestatic

iterate over all stored Observers and execute their notify-function

the idea of the following three lines have to work in the end (I basically want to loop over all attached observers and execute their notify function):

or

Definition at line 180 of file twoHitFilters.cc.

185 {
186 B2INFO(" Filter " << filterType.name() << " with Mag of outer-/innerHit " << outerHit.getPosition().Mag() << "/" <<
187 innerHit.getPosition().Mag() << " got result of " << fResult << " and Observer-Vector sm_collectedObservers got " <<
188 VectorOfObservers<FilterType>::sm_collectedObservers.size() << " observers collected");
189 B2INFO(" Filter " << filterType.name() << " with Mag of outer-/innerHit " << outerHit.getPosition().Mag() << "/" <<
190 innerHit.getPosition().Mag() << " got result of " << fResult << " and Observer-Vector sm_collectedObserversCSTYLE got " <<
191 VectorOfObservers<FilterType>::sm_collectedObserversCSTYLE.size() << " observers collected");
192
194 // for(auto& anObserver : CollectedObservers<FilterType>::collectedObservers) {
195 // anObserver(outerHit, innerHit, fResult);
196 // }
198 }
DataType Mag() const
The magnitude (rho in spherical coordinate system).
Definition: B2Vector3.h:159
static std::vector< CStyleFunctionPointer > sm_collectedObserversCSTYLE
collects observers with c-style function pointers to be executed during notify (variant B)
B2Vector3D outerHit(0, 0, 0)
testing out of range behavior

◆ notify() [2/2]

static void notify ( const types &  ...)
inlinestaticinherited

static method used by the observed object to notify the observer.

it is called at each accept.

Definition at line 37 of file VoidObserver.h.

37{};

◆ prepare()

static void prepare ( const types &  ...)
inlinestaticinherited

static method used by the observed object to prepare the observer it is called by the boolean filter operator.

Definition at line 49 of file VoidObserver.h.

49{};

◆ terminate()

static void terminate ( const types &  ...)
inlinestaticinherited

static method used by the observed object to terminate the observer.

Definition at line 67 of file VoidObserver.h.

67{};

Member Data Documentation

◆ sm_collectedObservers

std::vector< typename VectorOfObservers< FilterType >::observerFunction > sm_collectedObservers = {}
static

collects observers with std::function to be executed during notify (variant A)

initialize static member of variant A

Definition at line 211 of file twoHitFilters.cc.

◆ sm_collectedObserversCSTYLE

std::vector< typename VectorOfObservers< FilterType >::CStyleFunctionPointer > sm_collectedObserversCSTYLE = {}
static

collects observers with c-style function pointers to be executed during notify (variant B)

initialize static member of variant B

Definition at line 213 of file twoHitFilters.cc.


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