Tizen 2.4.0 rev3 SDK Public Release
[framework/web/wrt-installer.git] / src / jobs / job_exception_base.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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  * @file    job_exception_base.h
18  * @author  Pawel Sikorski (p.sikorski@samgsung.com)
19  * @version
20  * @brief
21  */
22
23 #include <dpl/exception.h>
24
25 #ifndef SRC_INSTALLER_CORE_JOBS_JOB_EXCEPTION_BASE_H_
26 #define SRC_INSTALLER_CORE_JOBS_JOB_EXCEPTION_BASE_H_
27
28 #define DECLARE_JOB_EXCEPTION_BASE(Base, Class, Param)                       \
29     class Class :                                                                    \
30         public Base {                                                       \
31       public:                                                                  \
32         Class(const char *path,                                              \
33               const char *function,                                          \
34               int line,                                                      \
35               const std::string & message = std::string()) :                                                                  \
36             Base(path, function, line, message)                              \
37         {                                                                    \
38             m_className = #Class;                                            \
39             m_param = Param;                                                   \
40         }                                                                    \
41                                                                              \
42         Class(const char *path,                                              \
43               const char *function,                                          \
44               int line,                                                      \
45               const Exception &reason,                                       \
46               const std::string & message = std::string()) :                                                                  \
47             Base(path, function, line, reason, message)                      \
48         {                                                                    \
49             m_className = #Class;                                            \
50             m_param = Param;                                                   \
51         }                                                                    \
52                                                                              \
53         virtual int getParam() const                                         \
54         {                                                                    \
55             return m_param;                                                  \
56         }                                                                    \
57       protected:                                                               \
58         int m_param;                                                         \
59     };
60
61 #define DECLARE_JOB_EXCEPTION(Base, Class, Param)                            \
62     class Class :                                                                    \
63         public Base {                                                       \
64       public:                                                                  \
65         Class(const char *path,                                              \
66               const char *function,                                          \
67               int line,                                                      \
68               const std::string & message = std::string()) :                                                                  \
69             Base(path, function, line, message)                              \
70         {                                                                    \
71             m_className = #Class;                                            \
72             m_param = Param;                                                   \
73         }                                                                    \
74                                                                              \
75         Class(const char *path,                                              \
76               const char *function,                                          \
77               int line,                                                      \
78               const Exception &reason,                                       \
79               const std::string & message = std::string()) :                                                                  \
80             Base(path, function, line, reason, message)                      \
81         {                                                                    \
82             m_className = #Class;                                            \
83             m_param = Param;                                                   \
84         }                                                                    \
85                                                                              \
86         virtual int getParam() const                                         \
87         {                                                                    \
88             return m_param;                                                  \
89         }                                                                    \
90     };
91
92 namespace Jobs {
93 DECLARE_JOB_EXCEPTION_BASE(DPL::Exception, JobExceptionBase, 0)
94 }
95
96 #endif /* SRC_INSTALLER_CORE_JOBS_JOB_EXCEPTION_BASE_H_ */