18 #ifndef FFA_OPERATION_H
19 #define FFA_OPERATION_H
27 #include "FFaLib/FFaPatterns/FFaMemPool.H"
53 static void freeMemPools() { getMemPoolMgr()->freeMemPools(); }
55 static FFaMemPoolMgr* getMemPoolMgr()
57 static FFaMemPoolMgr memPools;
74 template <
class RetType>
133 template <
class OperationCB>
141 static void addOperation(
const std::string& name, OperationCB operation)
143 static std::map<std::string,OperationCB> ops;
144 ops[name] = operation;
155 for (
const typename OperCBMap::value_type& oper : *
ourOperations)
156 names.push_back(oper.first);
177 typename OperCBMap::const_iterator it =
ourOperations->find(name);
198 template <
class OperationCB>
201 template <
class OperationCB>
209 template <
class RetType,
class PrmType = RetType>
263 #ifdef FT_USE_MEMPOOL
268 #ifdef FT_USE_MEMPOOL
270 template <
class RetType,
class PrmType>
272 FFaOperationBase::getMemPoolMgr());
281 template <
class RetType>
288 const std::string& name =
"")
303 if (p) p->invalidate();
312 if (p && p->hasData())
324 std::vector<RetType> pVals(
myParams.size());
325 for (
size_t i = 0; i <
myParams.size(); i++)
327 ok &=
myParams[i]->invoke(pVals[i]);
346 #ifdef FT_USE_MEMPOOL
351 #ifdef FT_USE_MEMPOOL
353 template <
class RetType>
355 FFaOperationBase::getMemPoolMgr());
Macros for definition of dynamic callback objects.
A class for vector operations.
Definition: FFaOperation.H:284
virtual ~FFaNToOneOp()
The destructor deletes the child operations, if any.
Definition: FFaOperation.H:337
std::vector< FFaOperation< RetType > * > myParams
Parameter child operations.
Definition: FFaOperation.H:344
virtual void invalidate()
Invalidates the cached value of this operation.
Definition: FFaOperation.H:299
virtual bool evaluate(RetType &value)
Invokes the actual operation.
Definition: FFaOperation.H:319
virtual bool hasData() const
Checks if this operation will return any data.
Definition: FFaOperation.H:309
FFaNToOneOp(const std::vector< FFaOperation< RetType > * > ¶ms, const std::string &name="")
The constructor selects the actual operation to use from name.
Definition: FFaOperation.H:287
Base class for all operations.
Definition: FFaOperation.H:38
virtual ~FFaOperationBase()
Empty destructor.
Definition: FFaOperation.H:43
short int myRefCount
Reference counter.
Definition: FFaOperation.H:66
void ref()
Increments the reference counter.
Definition: FFaOperation.H:47
FFaOperationBase()
Default constructor.
Definition: FFaOperation.H:41
static void freeMemPools()
Dummy method doing nothing.
Definition: FFaOperation.H:62
void unref()
Decrements the reference counter, and deletes *this if zero.
Definition: FFaOperation.H:49
A class used to manage and store callbacks of a certain type.
Definition: FFaOperation.H:135
static std::string ourDefaultOper
Name of the default operation type OperationCB.
Definition: FFaOperation.H:195
static const std::string & getDefaultOperation()
Returns the default operation of type OperationCB.
Definition: FFaOperation.H:163
OperationCB myOperationCB
The selected operation.
Definition: FFaOperation.H:189
static void getOperations(std::vector< std::string > &names)
Returns a list of all operations of type OperationCB.
Definition: FFaOperation.H:149
std::map< std::string, OperationCB > OperCBMap
Convenience type definition, name-to-operation mapping.
Definition: FFaOperation.H:137
void selectOperation(const std::string &name)
Selects the named operation to use.
Definition: FFaOperation.H:173
static std::map< std::string, OperationCB > * ourOperations
Static container for operations of type OperationCB.
Definition: FFaOperation.H:193
FFaOperationContainer()
The default constructor defines the default operation.
Definition: FFaOperation.H:167
static void setDefaultOperation(const std::string &o)
Defines the default operation of type OperationCB.
Definition: FFaOperation.H:161
static void addOperation(const std::string &name, OperationCB operation)
Adds a named operation to the OperationCB container.
Definition: FFaOperation.H:141
The base class used as argument in other operations.
Definition: FFaOperation.H:76
virtual bool evaluate(RetType &value)=0
Invokes the actual operation.
bool IAmEvaluated
If true, the cached value will be used.
Definition: FFaOperation.H:112
virtual void invalidate()
Invalidates the cached value of this operation.
Definition: FFaOperation.H:101
FFaOperation()
Default constructor.
Definition: FFaOperation.H:79
RetType myCachedValue
Cached operation value, to avoid re-evaluation.
Definition: FFaOperation.H:109
virtual bool hasData() const =0
Checks if this operation will return any data.
bool invoke(RetType &value)
Returns current value of this operation.
Definition: FFaOperation.H:85
virtual ~FFaOperation()
Empty destructor.
Definition: FFaOperation.H:81
A class for scalar operations.
Definition: FFaOperation.H:212
virtual ~FFaUnaryOp()
The destructor deletes the child operation, if any.
Definition: FFaOperation.H:255
FFaUnaryOp(FFaOperation< PrmType > *param, const std::string &name="")
The constructor selects the actual operation to use from name.
Definition: FFaOperation.H:215
virtual bool evaluate(RetType &value)
Invokes the actual operation.
Definition: FFaOperation.H:240
virtual bool hasData() const
Checks if this operation will return any data.
Definition: FFaOperation.H:234
FFaOperation< PrmType > * myParam
Parameter child operation.
Definition: FFaOperation.H:261
virtual void invalidate()
Invalidates the cached value of this operation.
Definition: FFaOperation.H:225
Various math utilities.
Definition: FFaMath.H:52
void setSpecialResultValue(double value, double equiv)
Defines a special result value and its associated equivalent value.
Definition: FFaBasicOperations.C:352