FEDEM Solver  R8.0
Source code of the dynamics solver
FFrReadOp.H
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2023 SAP SE
2 //
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 // This file is part of FEDEM - https://openfedem.org
7 
8 #ifndef FFR_READ_OP_H
9 #define FFR_READ_OP_H
10 
11 #ifdef FFA_DEBUG
12 #include <iostream>
13 #endif
14 
17 #ifdef FT_USE_MEMPOOL
18 #include "FFaLib/FFaPatterns/FFaMemPool.H"
19 #endif
20 
22 
23 
25 {
26 public:
27  ReadOpCreatorType(const std::string& t, int s = -1) : dataType(t), dataSize(s) {}
28 
29  friend bool operator< (const ReadOpCreatorType& op1, const ReadOpCreatorType& op2)
30  {
31  if (op1.dataType == op2.dataType)
32  return op1.dataSize < op2.dataSize;
33  else
34  return op1.dataType < op2.dataType;
35  }
36 
37 #ifdef FFA_DEBUG
38  friend std::ostream& operator<< (std::ostream& os, const ReadOpCreatorType& op)
39  {
40  return os << op.dataType <<":"<< op.dataSize;
41  }
42 #endif
43 
44 private:
45  std::string dataType;
46  int dataSize;
47 };
48 
49 
50 template <class RetType>
51 class FFrReadOp : public FFaOperation<RetType>
52 {
53 public:
55 
56  static void create(FFrVariableReference* rdbVar, FFaOperationBase*& created)
57  {
58  created = new FFrReadOp<RetType>(rdbVar);
59  }
60 
61  virtual bool hasData() const;
62  virtual bool evaluate(RetType& value);
63 
64 protected:
65  virtual ~FFrReadOp() {}
66 
67 private:
69 
70 #ifdef FT_USE_MEMPOOL
71  FFA_MAKE_MEMPOOL;
72 #endif
73 };
74 
75 #ifdef FT_USE_MEMPOOL
77 template <class RetType>
78 FFaMemPool FFrReadOp<RetType>::ourMemPool = FFaMemPool(sizeof(FFrReadOp<RetType>),
79  FFaOperationBase::getMemPoolMgr());
81 #endif
82 
83 
85 
86 #endif
Classes that make up the core of a operation/transformation system.
FFaGenericFactory< FFaOperationBase, ReadOpCreatorType, FFrVariableReference * > OperationFactory
Definition: FFrReadOp.H:84
Definition: FFaGenericFactory.H:24
Base class for all operations.
Definition: FFaOperation.H:38
The base class used as argument in other operations.
Definition: FFaOperation.H:76
Definition: FFrReadOp.H:52
static void create(FFrVariableReference *rdbVar, FFaOperationBase *&created)
Definition: FFrReadOp.H:56
virtual ~FFrReadOp()
Definition: FFrReadOp.H:65
virtual bool hasData() const
Checks if this operation will return any data.
Definition: FFrReadOpImpl.C:84
FFrVariableReference * myRdbVar
Definition: FFrReadOp.H:68
virtual bool evaluate(RetType &value)
Invokes the actual operation.
Definition: FFrReadOpImpl.C:77
FFrReadOp(FFrVariableReference *vr)
Definition: FFrReadOp.H:54
Definition: FFrVariableReference.H:18
Definition: FFrReadOp.H:25
friend bool operator<(const ReadOpCreatorType &op1, const ReadOpCreatorType &op2)
Definition: FFrReadOp.H:29
ReadOpCreatorType(const std::string &t, int s=-1)
Definition: FFrReadOp.H:27
int dataSize
Definition: FFrReadOp.H:46
std::string dataType
Definition: FFrReadOp.H:45
std::ostream & operator<<(std::ostream &os, const Case &c)
Global stream operator to print out a Case instance.
Definition: test_solver.C:70