C++ API Reference for Intel® Data Analytics Acceleration Library 2019 Update 4

algorithm_base_common.h
1 /* file: algorithm_base_common.h */
2 /*******************************************************************************
3 * Copyright 2014-2019 Intel Corporation.
4 *
5 * This software and the related documents are Intel copyrighted materials, and
6 * your use of them is governed by the express license under which they were
7 * provided to you (License). Unless the License provides otherwise, you may not
8 * use, modify, copy, publish, distribute, disclose or transmit this software or
9 * the related documents without Intel's prior written permission.
10 *
11 * This software and the related documents are provided as is, with no express
12 * or implied warranties, other than those that are expressly stated in the
13 * License.
14 *******************************************************************************/
15 
16 /*
17 //++
18 // Implementation of base classes defining algorithm interface.
19 //--
20 */
21 
22 #ifndef __ALGORITHM_BASE_COMMON_H__
23 #define __ALGORITHM_BASE_COMMON_H__
24 
25 #include "services/daal_memory.h"
26 #include "services/daal_kernel_defines.h"
27 #include "services/error_handling.h"
28 #include "services/env_detect.h"
29 #include "algorithms/algorithm_types.h"
30 
31 namespace daal
32 {
33 namespace algorithms
34 {
35 namespace interface1
36 {
37 
49 class AlgorithmIface
50 {
51 public:
52  DAAL_NEW_DELETE();
53 
54  virtual ~AlgorithmIface() {}
55 
59  virtual services::Status checkComputeParams() = 0;
60 
64  virtual services::Status checkResult() = 0;
65 
70  virtual int getMethod() const = 0;
71 
77  virtual services::SharedPtr<services::ErrorCollection> getErrors() = 0;
78 };
79 
85 class AlgorithmIfaceImpl : public AlgorithmIface
86 {
87 public:
89  AlgorithmIfaceImpl() : _enableChecks(true)
90  {
91  getEnvironment();
92  }
93 
94  virtual ~AlgorithmIfaceImpl() {}
95 
100  void enableChecks(bool enableChecksFlag)
101  {
102  _enableChecks = enableChecksFlag;
103  }
104 
109  bool isChecksEnabled() const
110  {
111  return _enableChecks;
112  }
113 
119  services::SharedPtr<services::ErrorCollection> getErrors()
120  {
121  return _status.getCollection();
122  }
123 
124 private:
125  bool _enableChecks;
126 
127 protected:
128  services::Status getEnvironment()
129  {
130  int cpuid = (int)daal::services::Environment::getInstance()->getCpuId();
131  if(cpuid < 0)
132  return services::Status(services::ErrorCpuNotSupported);
133  _env.cpuid = cpuid;
134  _env.cpuid_init_flag = true;
135  return services::Status();
136  }
137 
138  daal::services::Environment::env _env;
139  services::Status _status;
140 };
141 
143 } // namespace interface1
144 using interface1::AlgorithmIface;
145 using interface1::AlgorithmIfaceImpl;
146 
147 }
148 }
149 #endif
daal::services::ErrorCpuNotSupported
Definition: error_indexes.h:145
daal
Definition: algorithm_base_common.h:31
daal::algorithms::interface1::AlgorithmIface
Abstract class which defines interface for the library component related to data processing involving...
Definition: algorithm_base_common.h:49
daal::algorithms::interface1::AlgorithmIfaceImpl::AlgorithmIfaceImpl
AlgorithmIfaceImpl()
Definition: algorithm_base_common.h:89
daal::algorithms::interface1::AlgorithmIfaceImpl::isChecksEnabled
bool isChecksEnabled() const
Definition: algorithm_base_common.h:109
daal::algorithms::interface1::AlgorithmIfaceImpl
Implements the abstract interface AlgorithmIface. AlgorithmIfaceImpl is, in turn, the base class for ...
Definition: algorithm_base_common.h:85
daal::algorithms::interface1::AlgorithmIface::checkResult
virtual services::Status checkResult()=0
daal::algorithms::interface1::AlgorithmIface::getErrors
virtual services::SharedPtr< services::ErrorCollection > getErrors()=0
daal::algorithms::interface1::AlgorithmIfaceImpl::getErrors
services::SharedPtr< services::ErrorCollection > getErrors()
Definition: algorithm_base_common.h:119
daal::algorithms::interface1::AlgorithmIfaceImpl::enableChecks
void enableChecks(bool enableChecksFlag)
Definition: algorithm_base_common.h:100
daal::algorithms::interface1::AlgorithmIface::checkComputeParams
virtual services::Status checkComputeParams()=0
daal::algorithms::interface1::AlgorithmIface::getMethod
virtual int getMethod() const =0
daal_kernel_defines.h

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