source: XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/Functions/reduction.cpp @ 2196

Last change on this file since 2196 was 2196, checked in by jderouillat, 3 years ago

Backporting commit 1852 : Compiler fix for recent version of GCCfor optimised mode > O1

File size: 2.0 KB
Line 
1#include "reduction.hpp"
2#include "sum_reduction.hpp"
3#include "min_reduction.hpp"
4#include "max_reduction.hpp"
5#include "extract.hpp"
6#include "average_reduction.hpp"
7
8namespace xios {
9
10CReductionAlgorithm::CallBackMap* CReductionAlgorithm::reductionCreationCallBacks_ = 0;
11std::map<StdString,EReductionType> CReductionAlgorithm::ReductionOperations = std::map<StdString,EReductionType>();
12bool CReductionAlgorithm::initReductionOperation(std::map<StdString,EReductionType>& m)
13{
14  // So so stupid way to intialize operation but it works ...
15  m["sum"] = TRANS_REDUCE_SUM;
16  CSumReductionAlgorithm::registerTrans();
17
18  m["min"] = TRANS_REDUCE_MIN;
19  CMinReductionAlgorithm::registerTrans();
20
21  m["max"] = TRANS_REDUCE_MAX;
22  CMaxReductionAlgorithm::registerTrans();
23
24  m["extract"] = TRANS_REDUCE_EXTRACT;
25  CExtractReductionAlgorithm::registerTrans();
26
27  m["average"] = TRANS_REDUCE_AVERAGE;
28  CAverageReductionAlgorithm::registerTrans();
29  return true;
30}
31
32bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation(CReductionAlgorithm::ReductionOperations);
33
34CReductionAlgorithm* CReductionAlgorithm::createOperation(EReductionType reduceType)
35{
36  int reduceTypeInt = reduceType;
37  CallBackMap::const_iterator it = (*reductionCreationCallBacks_).find(reduceType);
38  if ((*reductionCreationCallBacks_).end() == it)
39  {
40     ERROR("CReductionAlgorithm::createOperation(EReductionType reduceType)",
41           << "Operation type " << reduceType
42           << "doesn't exist. Please define.");
43  }
44  return (it->second)();
45}
46
47bool CReductionAlgorithm::registerOperation(EReductionType reduceType, CreateOperationCallBack createFn)
48{
49  if (0 == reductionCreationCallBacks_)
50    reductionCreationCallBacks_ = new CallBackMap();
51
52  return (*reductionCreationCallBacks_).insert(make_pair(reduceType, createFn)).second;
53}
54
55bool CReductionAlgorithm::unregisterOperation(EReductionType reduceType)
56{
57  int reduceTypeInt = reduceType;
58  return (1 == (*reductionCreationCallBacks_).erase(reduceType));
59}
60
61
62}
Note: See TracBrowser for help on using the repository browser.