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

algorithm_base_common.h
1 /* file: algorithm_base_common.h */
2 /*******************************************************************************
3 * Copyright 2014-2017 Intel Corporation
4 * All Rights Reserved.
5 *
6 * If this software was obtained under the Intel Simplified Software License,
7 * the following terms apply:
8 *
9 * The source code, information and material ("Material") contained herein is
10 * owned by Intel Corporation or its suppliers or licensors, and title to such
11 * Material remains with Intel Corporation or its suppliers or licensors. The
12 * Material contains proprietary information of Intel or its suppliers and
13 * licensors. The Material is protected by worldwide copyright laws and treaty
14 * provisions. No part of the Material may be used, copied, reproduced,
15 * modified, published, uploaded, posted, transmitted, distributed or disclosed
16 * in any way without Intel's prior express written permission. No license under
17 * any patent, copyright or other intellectual property rights in the Material
18 * is granted to or conferred upon you, either expressly, by implication,
19 * inducement, estoppel or otherwise. Any license under such intellectual
20 * property rights must be express and approved by Intel in writing.
21 *
22 * Unless otherwise agreed by Intel in writing, you may not remove or alter this
23 * notice or any other notice embedded in Materials by Intel or Intel's
24 * suppliers or licensors in any way.
25 *
26 *
27 * If this software was obtained under the Apache License, Version 2.0 (the
28 * "License"), the following terms apply:
29 *
30 * You may not use this file except in compliance with the License. You may
31 * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
32 *
33 *
34 * Unless required by applicable law or agreed to in writing, software
35 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
36 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37 *
38 * See the License for the specific language governing permissions and
39 * limitations under the License.
40 *******************************************************************************/
41 
42 /*
43 //++
44 // Implementation of base classes defining algorithm interface.
45 //--
46 */
47 
48 #ifndef __ALGORITHM_BASE_COMMON_H__
49 #define __ALGORITHM_BASE_COMMON_H__
50 
51 #include "services/daal_memory.h"
52 #include "services/daal_kernel_defines.h"
53 #include "services/error_handling.h"
54 #include "services/env_detect.h"
55 #include "algorithms/algorithm_types.h"
56 
57 namespace daal
58 {
59 namespace algorithms
60 {
61 namespace interface1
62 {
63 
75 class AlgorithmIface
76 {
77 public:
78  DAAL_NEW_DELETE();
79 
80  virtual ~AlgorithmIface() {}
81 
85  virtual services::Status checkComputeParams() = 0;
86 
90  virtual services::Status checkResult() = 0;
91 
96  virtual int getMethod() const = 0;
97 
103  virtual services::SharedPtr<services::ErrorCollection> getErrors() = 0;
104 };
105 
111 class AlgorithmIfaceImpl : public AlgorithmIface
112 {
113 public:
115  AlgorithmIfaceImpl() : _enableChecks(true)
116  {
117  getEnvironment();
118  }
119 
120  virtual ~AlgorithmIfaceImpl() {}
121 
126  void enableChecks(bool enableChecksFlag)
127  {
128  _enableChecks = enableChecksFlag;
129  }
130 
135  bool isChecksEnabled() const
136  {
137  return _enableChecks;
138  }
139 
145  services::SharedPtr<services::ErrorCollection> getErrors()
146  {
147  return _status.getCollection();
148  }
149 
150 private:
151  bool _enableChecks;
152 
153 protected:
154  services::Status getEnvironment()
155  {
156  int cpuid = (int)daal::services::Environment::getInstance()->getCpuId();
157  if(cpuid < 0)
158  return services::Status(services::ErrorCpuNotSupported);
159  _env.cpuid = cpuid;
160  _env.cpuid_init_flag = true;
161  return services::Status();
162  }
163 
164  daal::services::Environment::env _env;
165  services::Status _status;
166 };
167 
169 } // namespace interface1
170 using interface1::AlgorithmIface;
171 using interface1::AlgorithmIfaceImpl;
172 
173 }
174 }
175 #endif
daal::services::ErrorCpuNotSupported
Definition: error_indexes.h:169
daal
Definition: algorithm_base_common.h:57
daal::algorithms::interface1::AlgorithmIface
Abstract class which defines interface for the library component related to data processing involving...
Definition: algorithm_base_common.h:75
daal::algorithms::interface1::AlgorithmIfaceImpl::AlgorithmIfaceImpl
AlgorithmIfaceImpl()
Definition: algorithm_base_common.h:115
daal::algorithms::interface1::AlgorithmIfaceImpl::isChecksEnabled
bool isChecksEnabled() const
Definition: algorithm_base_common.h:135
daal::algorithms::interface1::AlgorithmIfaceImpl
Implements the abstract interface AlgorithmIface. AlgorithmIfaceImpl is, in turn, the base class for ...
Definition: algorithm_base_common.h:111
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:145
daal::algorithms::interface1::AlgorithmIfaceImpl::enableChecks
void enableChecks(bool enableChecksFlag)
Definition: algorithm_base_common.h:126
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.