gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
Gambit::dep_bucket< TYPE > Class Template Reference

An interface class for module dependencies. More...

#include <safety_bucket.hpp>

Inheritance diagram for Gambit::dep_bucket< TYPE >:
Collaboration diagram for Gambit::dep_bucket< TYPE >:

Public Member Functions

 dep_bucket (str mym, str myf, str me, module_functor< TYPE > *functor_ptr_in=NULL, module_functor_common *dependent_functor_ptr_in=NULL)
 Constructor for dep_bucket. More...
 
void initialize (module_functor< TYPE > *functor_ptr_in, module_functor_common *dependent_functor_ptr_in)
 Initialize this bucket with a depedency functor pointer. More...
 
str module ()
 Get module name. More...
 
const TYPE & operator* () const
 Dereference the dependency pointer stored as a safe_ptr. More...
 
const TYPE * operator-> () const
 Access is allowed to const member functions only. More...
 
safe_ptr< TYPE > & safe_pointer ()
 Get the safe_ptr. More...
 
- Public Member Functions inherited from Gambit::safety_bucket_base
 safety_bucket_base (str myinfo)
 Master constructor. More...
 
str name ()
 Get capability name. More...
 
str origin ()
 Get name of origin (module/backend). More...
 

Static Public Member Functions

static bool use_thread_index (module_functor< TYPE > *f1, module_functor_common *f2)
 Check if the thread index needs to be used to access the functor's result. More...
 

Protected Attributes

module_functor< TYPE > * _functor_ptr
 
safe_ptr< TYPE > _sptr
 
module_functor_common_dependent_functor_ptr
 
- Protected Attributes inherited from Gambit::safety_bucket_base
functor_functor_base_ptr
 
bool _initialized
 
const str whoami
 

Additional Inherited Members

- Protected Member Functions inherited from Gambit::safety_bucket_base
void dieGracefully () const
 Failure message invoked when the user tries to access the object before it is initialized. More...
 

Detailed Description

template<typename TYPE>
class Gambit::dep_bucket< TYPE >

An interface class for module dependencies.

Definition at line 88 of file safety_bucket.hpp.

Constructor & Destructor Documentation

◆ dep_bucket()

template<typename TYPE>
Gambit::dep_bucket< TYPE >::dep_bucket ( str  mym,
str  myf,
str  me,
module_functor< TYPE > *  functor_ptr_in = NULL,
module_functor_common dependent_functor_ptr_in = NULL 
)
inline

Constructor for dep_bucket.

Definition at line 94 of file safety_bucket.hpp.

95  : safety_bucket_base(mym+"::Pipes::"+myf+"::Dep::"+me)
96  {
97  initialize(functor_ptr_in, dependent_functor_ptr_in);
98  }
safety_bucket_base(str myinfo)
Master constructor.
void initialize(module_functor< TYPE > *functor_ptr_in, module_functor_common *dependent_functor_ptr_in)
Initialize this bucket with a depedency functor pointer.

Member Function Documentation

◆ initialize()

template<typename TYPE>
void Gambit::dep_bucket< TYPE >::initialize ( module_functor< TYPE > *  functor_ptr_in,
module_functor_common dependent_functor_ptr_in 
)
inline

Initialize this bucket with a depedency functor pointer.

Definition at line 101 of file safety_bucket.hpp.

References Gambit::safety_bucket_base::_functor_base_ptr, and Gambit::safety_bucket_base::_initialized.

102  {
103  _functor_ptr = functor_ptr_in;
104  _functor_base_ptr = functor_ptr_in;
105  _dependent_functor_ptr = dependent_functor_ptr_in;
106 
107  // Extract pointer to dependency from functor and store as a safe_ptr.
108  if (functor_ptr_in == NULL)
109  {
110  _sptr.set(NULL);
111  _initialized = false;
112  }
113  else
114  {
115  _sptr = _functor_ptr->valuePtr();
116  _initialized = true;
117  }
118  }
module_functor_common * _dependent_functor_ptr
module_functor< TYPE > * _functor_ptr
safe_ptr< TYPE > _sptr

◆ module()

template<typename TYPE>
str Gambit::dep_bucket< TYPE >::module ( )
inline

Get module name.

Definition at line 121 of file safety_bucket.hpp.

References Gambit::safety_bucket_base::origin().

122  {
123  return origin();
124  }
str origin()
Get name of origin (module/backend).
Here is the call graph for this function:

◆ operator*()

template<typename TYPE>
const TYPE& Gambit::dep_bucket< TYPE >::operator* ( ) const
inline

Dereference the dependency pointer stored as a safe_ptr.

Definition at line 136 of file safety_bucket.hpp.

References Gambit::safety_bucket_base::_initialized, Gambit::safety_bucket_base::dieGracefully(), and combine_hdf5::index.

137  {
138  if (not _initialized) dieGracefully();
139  //Choose the index of the thread if the dependency and the dependent functor are running inside the same loop. If not, just access the first element.
140  int index = use_thread_index(_functor_ptr, _dependent_functor_ptr) ? omp_get_thread_num() : 0;
141  return _sptr[index];
142  }
void dieGracefully() const
Failure message invoked when the user tries to access the object before it is initialized.
static bool use_thread_index(module_functor< TYPE > *f1, module_functor_common *f2)
Check if the thread index needs to be used to access the functor&#39;s result.
module_functor_common * _dependent_functor_ptr
module_functor< TYPE > * _functor_ptr
safe_ptr< TYPE > _sptr
Here is the call graph for this function:

◆ operator->()

template<typename TYPE>
const TYPE* Gambit::dep_bucket< TYPE >::operator-> ( ) const
inline

Access is allowed to const member functions only.

Definition at line 146 of file safety_bucket.hpp.

References Gambit::safety_bucket_base::_initialized, Gambit::safety_bucket_base::dieGracefully(), and combine_hdf5::index.

147  {
148  if (not _initialized) this->dieGracefully();
149  //Choose the index of the thread if the dependency and the dependent functor are running inside the same loop. If not, just choose the first element.
150  int index = use_thread_index(_functor_ptr, _dependent_functor_ptr) ? omp_get_thread_num() : 0;
151  return _sptr.operator->() + index; //Call a const member function of the indexth element of the array pointed to by the safe pointer.
152  }
void dieGracefully() const
Failure message invoked when the user tries to access the object before it is initialized.
static bool use_thread_index(module_functor< TYPE > *f1, module_functor_common *f2)
Check if the thread index needs to be used to access the functor&#39;s result.
module_functor_common * _dependent_functor_ptr
module_functor< TYPE > * _functor_ptr
safe_ptr< TYPE > _sptr
Here is the call graph for this function:

◆ safe_pointer()

template<typename TYPE>
safe_ptr<TYPE>& Gambit::dep_bucket< TYPE >::safe_pointer ( )
inline

Get the safe_ptr.

Definition at line 155 of file safety_bucket.hpp.

References Gambit::safety_bucket_base::_initialized, and Gambit::safety_bucket_base::dieGracefully().

156  {
157  if (not _initialized) dieGracefully();
158  return _sptr;
159  }
void dieGracefully() const
Failure message invoked when the user tries to access the object before it is initialized.
safe_ptr< TYPE > _sptr
Here is the call graph for this function:

◆ use_thread_index()

template<typename TYPE>
static bool Gambit::dep_bucket< TYPE >::use_thread_index ( module_functor< TYPE > *  f1,
module_functor_common f2 
)
inlinestatic

Check if the thread index needs to be used to access the functor's result.

Definition at line 127 of file safety_bucket.hpp.

References Gambit::module_functor_common::loopManagerCapability(), Gambit::module_functor_common::loopManagerName(), and Gambit::module_functor_common::loopManagerOrigin().

128  {
129  return (f1->loopManagerCapability() != "none" and
130  f1->loopManagerCapability() == f2->loopManagerCapability() and
131  f1->loopManagerName() == f2->loopManagerName() and
132  f1->loopManagerOrigin() == f2->loopManagerOrigin() );
133  }
Here is the call graph for this function:

Member Data Documentation

◆ _dependent_functor_ptr

template<typename TYPE>
module_functor_common* Gambit::dep_bucket< TYPE >::_dependent_functor_ptr
protected

Definition at line 166 of file safety_bucket.hpp.

◆ _functor_ptr

template<typename TYPE>
module_functor<TYPE>* Gambit::dep_bucket< TYPE >::_functor_ptr
protected

Definition at line 164 of file safety_bucket.hpp.

◆ _sptr

template<typename TYPE>
safe_ptr<TYPE> Gambit::dep_bucket< TYPE >::_sptr
protected

Definition at line 165 of file safety_bucket.hpp.


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