C++ API Reference for Intel® Data Analytics Acceleration Library 2020 Update 1

algorithm_base_mode.h
1 /* file: algorithm_base_mode.h */
2 /*******************************************************************************
3 * Copyright 2014-2020 Intel Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *******************************************************************************/
17 
18 /*
19 //++
20 // Implementation of base classes defining algorithm interface.
21 //--
22 */
23 
24 #ifndef __ALGORITHM_BASE_MODE_H__
25 #define __ALGORITHM_BASE_MODE_H__
26 
27 #include "services/daal_memory.h"
28 #include "services/daal_kernel_defines.h"
29 #include "services/error_handling.h"
30 #include "services/env_detect.h"
31 #include "algorithms/algorithm_types.h"
32 #include "algorithms/algorithm_base_common.h"
33 
34 namespace daal
35 {
36 namespace algorithms
37 {
38 namespace interface1
39 {
40 
52 template<ComputeMode mode> class Algorithm : public AlgorithmIfaceImpl
53 {
54 public:
56  Algorithm() : _ac(0), _in(0), _pres(0), _res(0), _par(0) { }
57 
58  virtual ~Algorithm()
59  {
60  if(_ac)
61  {
62  delete _ac;
63  }
64  }
65 
66  virtual void clean() {}
67 
71  virtual services::Status checkPartialResult() = 0;
72 
76  virtual services::Status checkFinalizeComputeParams() = 0;
77 
78 protected:
79  PartialResult *allocatePartialResultMemory()
80  {
81  if(_pres == 0)
82  {
83  allocatePartialResult();
84  }
85 
86  return _pres;
87  }
88 
89  virtual void setParameter() {}
90 
91  services::Status allocateResultMemory()
92  {
93  if(_res == 0)
94  return allocateResult();
95  return services::Status();
96  }
97 
98  services::Status initPartialResult()
99  {
100  return initializePartialResult();
101  }
102 
103  virtual services::Status allocatePartialResult() = 0;
104  virtual services::Status allocateResult() = 0;
105 
106  virtual services::Status initializePartialResult() = 0;
107  virtual Algorithm<mode> *cloneImpl() const = 0;
108 
109  bool getInitFlag() { return _pres->getInitFlag(); }
110  void setInitFlag(bool flag) { _pres->setInitFlag(flag); }
111 
112  AlgorithmContainerImpl<mode> *_ac;
113 
114  Input *_in;
115  PartialResult *_pres;
116  Result *_res;
117  Parameter *_par;
118 };
119 
126 template<> class Algorithm<batch> : public AlgorithmIfaceImpl
127 {
128 public:
130  Algorithm() : _ac(0), _par(0), _in(0), _res(0) { }
131 
132  virtual ~Algorithm()
133  {
134  if(_ac)
135  {
136  delete _ac;
137  }
138  }
139 
143  virtual services::Status checkComputeParams() = 0;
144 
145  Parameter * getBaseParameter() { return _par; }
146 
147 protected:
148  services::Status allocateResultMemory()
149  {
150  if(_res == 0)
151  return allocateResult();
152  return services::Status();
153  }
154 
155  virtual void setParameter() {}
156 
157  virtual services::Status allocateResult() = 0;
158 
159  virtual Algorithm<batch> *cloneImpl() const = 0;
160 
161  daal::algorithms::AlgorithmContainerImpl<batch> *_ac;
162 
163  Parameter *_par;
164  Input *_in;
165  Result *_res;
166 };
167 
169 } // namespace interface1
170 using interface1::Algorithm;
171 
172 }
173 }
174 #endif
daal::algorithms::interface1::AlgorithmIfaceImpl
Implements the abstract interface AlgorithmIface. AlgorithmIfaceImpl is, in turn, the base class for ...
Definition: algorithm_base_common.h:87
daal::batch
Definition: daal_defines.h:112
daal::algorithms::interface1::Algorithm
Implements the abstract interface AlgorithmIface. Algorithm is, in turn, the base class for the class...
Definition: algorithm_base_mode.h:52
daal::algorithms::interface1::Algorithm::checkFinalizeComputeParams
virtual services::Status checkFinalizeComputeParams()=0
daal::algorithms::interface1::Algorithm< batch >::Algorithm
Algorithm()
Definition: algorithm_base_mode.h:130
daal::algorithms::interface1::PartialResult::setInitFlag
void setInitFlag(bool flag)
Definition: algorithm_types.h:260
daal::algorithms::interface1::Algorithm::checkPartialResult
virtual services::Status checkPartialResult()=0
daal::algorithms::interface1::PartialResult::getInitFlag
bool getInitFlag()
Definition: algorithm_types.h:254
daal::algorithms::interface1::Algorithm::Algorithm
Algorithm()
Definition: algorithm_base_mode.h:56
daal::algorithms::interface1::AlgorithmIface::checkComputeParams
virtual services::Status checkComputeParams()=0
daal_kernel_defines.h

For more complete information about compiler optimizations, see our Optimization Notice.