Fix the boiler plate codes
[platform/framework/native/appfw.git] / src / base / inc / FBase_NativeError.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                FBaseNativeError.h
19  * @brief               This is the header file for handling Native errors.
20  */
21
22 #ifndef _FBASE_NATIVE_ERROR_H_
23 #define _FBASE_NATIVE_ERROR_H_
24
25 #include <FBaseResult.h>
26
27
28 #define __FUNCX__ __PRETTY_FUNCTION__
29
30 #ifdef _OSP_DEBUG_
31 #define __ConvertNativeErrorToResult(errNo)  _NativeError::ConvertNativeErrorToResult(errNo, __FILE__, __LINE__, __FUNCX__)
32 #define __ConvertNativeErrorToMessage(errNo) _NativeError::ConvertNativeErrorToMessage(errNo, __FILE__, __LINE__, __FUNCX__)
33 #else
34 #define __ConvertNativeErrorToResult(errNo)  _NativeError::ConvertNativeErrorToResult(errNo)
35 #define __ConvertNativeErrorToMessage(errNo) _NativeError::ConvertNativeErrorToMessage(errNo)
36 #endif
37
38 #define __ConvertNativeSystemErrorToResult(errNo)       _NativeError::ConvertNativeSystemErrorToResult(errNo)
39 #define __ConvertNativeDeviceErrorToResult(errNo)       _NativeError::ConvertNativeDeviceErrorToResult(errNo)
40 #define __ConvertNativePowerErrorToResult(errNo)        _NativeError::ConvertNativePowerErrorToResult(errNo)
41 #define __ConvertNativeAlarmErrorToResult(errNo)        _NativeError::ConvertNativeAlarmErrorToResult(errNo)
42 #define __ConvertNativeHapticErrorToResult(errNo)       _NativeError::ConvertNativeHapticErrorToResult(errNo)
43 #define __ConvertNativeTelephonyErrorToResult(errNo)    _NativeError::ConvertNativeTelephonyErrorToResult(errNo)
44 #define __ConvertNativeSoundManagerErrorToResult(errNo) _NativeError::ConvertNativeSoundManagerErrorToResult(errNo)
45 #define __ConvertNativeSqliteErrorToResult(errNo)       _NativeError::ConvertNativeSqliteErrorToResult(errNo)
46 #define __ConvertNativeSqliteErrorToDetailResult(errNo) _NativeError::ConvertNativeSqliteErrorToDetailResult(errNo)
47
48 /**
49  *      @class  _NativeError & FBaseNativeError.h
50  *      @brief  This is implemenatation of handling native errors.
51  *
52  */
53 class _NativeError
54 {
55 public:
56         //
57         // Convert Linux errno to Result type
58         //
59         static result ConvertNativeErrorToResult(int errNo, bool logNativeErr = false);
60
61         //
62         // Convert Linux errno to Result type
63         //
64         static result ConvertNativeErrorToResult(int errNo, const char* pFile, int line, const char* pFunction, bool logNativeErr = false);
65
66         //
67         // Convert Linux errno to Result type message
68         //
69         static const char* ConvertNativeErrorToMessage(int errNo);
70
71         //
72         // Convert Linux errno to Result type message
73         //
74         static const char* ConvertNativeErrorToMessage(int errNo, const char* pFile, int line, const char* pFunction);
75
76         //
77         // Convert SLP system_info error to Result type
78         //
79         static result ConvertNativeSystemErrorToResult(int err);
80
81         //
82         // Convert SLP device error to Result type
83         //
84         static result ConvertNativeDeviceErrorToResult(int err);
85
86         //
87         // Convert SLP power error to Result type
88         //
89         static result ConvertNativePowerErrorToResult(int err);
90
91         //
92         // Convert SLP alarm error to Result type
93         //
94         static result ConvertNativeAlarmErrorToResult(int err);
95
96         //
97         // Convert SLP haptic error to Result type
98         //
99         static result ConvertNativeHapticErrorToResult(int err);
100
101         //
102         // Convert SLP Telephony error to Result type
103         //
104         static result ConvertNativeTelephonyErrorToResult(int err);
105
106         //
107         // Convert SLP Telephony error to Result type
108         //
109         static result ConvertNativeSoundManagerErrorToResult(int err);
110
111         //
112         // Converts SQLite error to Result type for OSP 2.0
113         //
114         static result ConvertNativeSqliteErrorToResult(int err);
115
116         //
117         // Converts SQLite error to Result type for OSP 3.0
118         //
119         static result ConvertNativeSqliteErrorToDetailResult(int err);
120
121 }; // _NativeError
122
123 #endif //_FBASE_NATIVE_ERROR_H_
124