EvolvingObjects
|
Base class for the 4 algorithm functors. More...
#include <eoMpi.h>
Public Member Functions | |
SharedDataFunction (Wrapped *w=0) | |
Default constructor. | |
virtual | ~SharedDataFunction () |
Destructor. | |
void | wrapped (Wrapped *w) |
Setter for the wrapped function. | |
void | data (JobData *d) |
Setter for the data present in the functor. | |
bool | needDelete () |
Returns true if we need to use operator delete on this wrapper, false otherwise. | |
void | needDelete (bool b) |
Protected Attributes | |
JobData * | _data |
Wrapped * | _wrapped |
bool | _needDelete |
Base class for the 4 algorithm functors.
This class can embed a data (JobData) and a wrapper, so as to make all the 4 functors wrappable. We can add a wrapper at initialization or at any time when executing the program.
According to RAII, the boolean needDelete helps to know if we have to use the operator delete on the wrapper or not. Hence, if any functor is wrapped, user has just to put this boolean to true, to indicate to wrapper that it should call delete. This allows to mix wrapper initialized in the heap (with new) or in the stack.
JobData | a Data type, which can have any form. It can a struct, a single int, anything. |
Wrapped | the type of the functor, which will be stored as a pointer under the name _wrapped. This allows to wrap directly the functor in functors of the same type here, instead of dealing with SharedDataFunction* that we would have to cast all the time. Doing also allows to handle the wrapped functor as the functor we're writing, when coding the wrappers, instead of doing some static_cast. For instance, if there are 2 functors subclasses, fA and fB, fA implementing doFa() and fB implementing doFb(), we could have the following code: struct fA_wrapper { // some code void doFa() { _wrapped->doFa(); std::cout << "I'm a fA wrapper!" << std::endl; // if we didn't have the second template parameter, but a SharedDataFunction, we would have to do this: static_cast<fA*>(_wrapped)->doFa(); // do other things (it's a wrapper) } }; struct fB_wrapper { // some code void doFb() { _wrapped->doFb(); // and not: static_cast<fB*>(_wrapped)->doFb(); } }; |
eo::mpi::SharedDataFunction< JobData, Wrapped >::SharedDataFunction | ( | Wrapped * | w = 0 | ) | [inline] |
virtual eo::mpi::SharedDataFunction< JobData, Wrapped >::~SharedDataFunction | ( | ) | [inline, virtual] |
void eo::mpi::SharedDataFunction< JobData, Wrapped >::wrapped | ( | Wrapped * | w | ) | [inline] |
void eo::mpi::SharedDataFunction< JobData, Wrapped >::data | ( | JobData * | d | ) | [inline] |
bool eo::mpi::SharedDataFunction< JobData, Wrapped >::needDelete | ( | ) | [inline] |
Returns true if we need to use operator delete on this wrapper, false otherwise.
Allows the user to reject delete responsability to the framework, by setting this value to true.
Definition at line 272 of file eoMpi.h.
Referenced by eo::mpi::ParallelApplyStore< EOT >::ParallelApplyStore().