00001 // OSB library ************************************************ -*- C++ -*- 00006 /* 00007 AUTHOR(S): Stephan Broennimann (vb) 00008 00009 RCS information 00010 $Name: OSB_060808 $ 00011 $Revision: 1.2 $ 00012 00013 License 00014 OSB rating and billing library for communication networks 00015 Copyright (C) 2004, 2005, 2006 OSB systems 00016 00017 This file may be distributed and/or modify under the terms of the 00018 GNU General Public License (GPL) as published by the Free Software 00019 Foundation which is provided in the file LICENSE.GPL included in the 00020 packaging of this file. 00021 00022 The file is distributed in the hope that it will be useful, but WITHOUT 00023 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00024 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00025 for more details. 00026 00027 Holders of a OSB Commercial License may use this file under the terms 00028 and conditions of this commercial license. 00029 */ 00030 #ifndef _APPERROR_H_ 00031 #define _APPERROR_H_ 00032 00033 // ************************************************************************ 00034 // included header files 00035 // + standard includes 00036 00037 // + libraries 00038 00039 // + local headers 00040 #include "osberror.h" 00041 00042 // + class declarations 00043 00044 // ************************************************************************ 00045 // namespace extensions 00046 namespace OSB_APP { 00047 00048 // ************************************************************************ 00049 // forward declarations 00050 00051 // ************************************************************************ 00052 // type definitions 00053 00054 // ************************************************************************ 00055 // class definitions 00056 00064 class AppBaseError : public OSB_LIB::BaseError { 00065 public: 00067 explicit AppBaseError(ErrorNo e); 00069 AppBaseError( 00070 ErrorNo no, 00071 const Args& args 00072 ); 00073 00075 virtual ~AppBaseError() = 0; 00076 00077 protected: 00079 AppBaseError(const AppBaseError& rhs); 00081 AppBaseError& operator=(const AppBaseError& rhs); 00082 00083 private: 00085 static const std::string fileName_; 00086 // doc from base 00087 const std::string& fileName() const; 00088 }; // class AppBaseError 00089 00095 class AppException : public AppBaseError { 00096 public: 00098 AppException(ErrorNo e); 00100 AppException( 00101 ErrorNo no, 00102 const Args& args 00103 ); 00104 00106 const char* const prefix() const; 00107 00108 public: 00121 template<typename T> 00122 AppException& operator<<(const T& t); 00123 00124 private: 00126 static const char* const prefix_; 00127 }; 00128 00135 class AppError : public AppBaseError { 00136 public: 00138 AppError(); 00140 explicit AppError(ErrorNo e); 00142 AppError( 00143 ErrorNo no, 00144 const Args& args 00145 ); 00146 00148 const char* const prefix() const; 00149 00150 private: 00152 static const char* const prefix_; 00153 }; 00154 00155 } // namespace OSB_APP 00156 00157 // ************************************************************************ 00158 // inline definitions 00159 namespace OSB_APP { 00160 00161 // ******************************************************************** 00162 // class AppBaseError 00163 inline AppBaseError::AppBaseError(ErrorNo e) 00164 : BaseError(e) 00165 { 00166 // empty 00167 } 00168 00169 inline AppBaseError::AppBaseError( 00170 ErrorNo no, 00171 const Args& args 00172 ) : BaseError(no, args) 00173 { 00174 // empty 00175 } 00176 00177 inline AppBaseError& AppBaseError::operator=(const AppBaseError& rhs) 00178 { 00179 BaseError::operator=(rhs); 00180 return *this; 00181 } 00182 00183 inline AppBaseError::AppBaseError(const AppBaseError& rhs) 00184 : BaseError(rhs) 00185 { 00186 // empty 00187 } 00188 00189 inline AppBaseError::~AppBaseError() 00190 { 00191 // empty 00192 } 00193 00194 // ******************************************************************** 00195 // class AppException 00196 inline AppException::AppException(ErrorNo e) 00197 : AppBaseError(e) 00198 { 00199 // empty 00200 } 00201 00202 inline AppException::AppException( 00203 ErrorNo no, 00204 const Args& args 00205 ) : AppBaseError(no, args) 00206 { 00207 // empty 00208 } 00209 00210 inline const char* const AppException::prefix() const 00211 { 00212 return prefix_; 00213 } 00214 00215 template<typename T> 00216 inline AppException& AppException::operator<<(const T& t) 00217 { 00218 BaseError::operator<<(t); 00219 return *this; 00220 } 00221 00222 // ******************************************************************** 00223 // class AppError 00224 inline AppError::AppError() 00225 : AppBaseError(noError_) 00226 { 00227 // empty 00228 } 00229 00230 inline AppError::AppError(ErrorNo e) 00231 : AppBaseError(e) 00232 { 00233 // empty 00234 } 00235 00236 inline AppError::AppError( 00237 ErrorNo no, 00238 const Args& args 00239 ) : AppBaseError(no, args) 00240 { 00241 // empty 00242 } 00243 00244 inline const char* const AppError::prefix() const 00245 { 00246 return prefix_; 00247 } 00248 } // namespace OSB_APP 00249 #endif // #ifndef _APPERROR_H_