]> Creatis software - bbtk.git/blob - kernel/src/bbtkException.h
Recreated the complete cvs tree because the project architecture deeply changed
[bbtk.git] / kernel / src / bbtkException.h
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbtkException.h,v $
5   Language:  C++
6   Date:      $Date: 2008/01/22 15:02:00 $
7   Version:   $Revision: 1.1.1.1 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19
20 /**
21  *  \file 
22  *  \brief  class Exception:generic class for throwing any exception (header) 
23  *
24  *    Long description:
25  */
26
27 /**
28  *  \class bbtk::Exception 
29  *  \brief  class Exception : generic class for throwing any exception 
30  *
31  *    Long description:
32  */
33  
34 #ifndef __bbtkException_h__
35 #define __bbtkException_h__
36
37 #include "bbtkSystem.h"
38 #include <exception>
39
40 namespace bbtk
41 {
42
43   inline std::string bbGetObjectDescription() { return(""); }
44
45   class BBTK_EXPORT Exception : public std::exception
46   {
47   public:
48     Exception(const std::string& object,
49               const std::string& file,
50               const std::string& message) throw()
51       : mObject(object),
52         mFile(file),
53         mMessage(message)
54     {}
55     ~Exception() throw() {}
56     void Print() throw()
57     {
58       std::cerr << "* ERROR  : " << mMessage <<std::endl; 
59       int lev = bbtk::MessageManager::GetMessageLevel("Error");
60       if (lev > 0) {
61         std::cerr << "* OBJECT : " <<mObject<<std::endl;
62         std::cerr << "* FILE   : " <<mFile<<std::endl;
63       }
64     }
65     const std::string& GetObject() const { return mObject; }
66     const std::string& GetFile() const { return mFile; }
67     const std::string& GetMessage() const { return mMessage; }
68   private:
69     std::string mObject;
70     std::string mFile;
71     std::string mMessage;
72   };
73
74 }//namespace
75
76 #endif