OSDN Git Service

Sメーター周りを修正
[trx-305dsp/dsp.git] / hirado / kernel / cfg / base / except.h
1 /*
2  *  TOPPERS/JSP Kernel
3  *      Toyohashi Open Platform for Embedded Real-Time Systems/
4  *      Just Standard Profile Kernel
5  * 
6  *  Copyright (C) 2003 by Embedded and Real-Time Systems Laboratory
7  *                              Toyohashi Univ. of Technology, JAPAN
8  * 
9  *  上記著作権者は,以下の (1)〜(4) の条件か,Free Software Foundation 
10  *  によって公表されている GNU General Public License の Version 2 に記
11  *  述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア
12  *  を改変したものを含む.以下同じ)を使用・複製・改変・再配布(以下,
13  *  利用と呼ぶ)することを無償で許諾する.
14  *  (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
15  *      権表示,この利用条件および下記の無保証規定が,そのままの形でソー
16  *      スコード中に含まれていること.
17  *  (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
18  *      用できる形で再配布する場合には,再配布に伴うドキュメント(利用
19  *      者マニュアルなど)に,上記の著作権表示,この利用条件および下記
20  *      の無保証規定を掲載すること.
21  *  (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
22  *      用できない形で再配布する場合には,次のいずれかの条件を満たすこ
23  *      と.
24  *    (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
25  *        作権表示,この利用条件および下記の無保証規定を掲載すること.
26  *    (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
27  *        報告すること.
28  *  (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
29  *      害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
30  * 
31  *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
32  *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も
33  *  含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直
34  *  接的または間接的に生じたいかなる損害に関しても,その責任を負わない.
35  * 
36  *  @(#) $Id: except.h,v 1.1 2009/01/31 05:27:37 suikan Exp $
37  */
38
39 // $Header: /cvsroot/toppersjsp4bf/jsp/cfg/base/except.h,v 1.1 2009/01/31 05:27:37 suikan Exp $
40
41 #ifndef EXCEPT_H
42 #define EXCEPT_H
43
44 #ifdef _MSC_VER
45 #  pragma warning(disable:4290) //C++ の例外の指定は無視されます。関数が __declspec(nothrow) でないことのみ表示されます。
46 #endif
47
48 //#include "testsuite.h"
49
50 #include <string>
51 #include <typeinfo>
52
53     //例外基底クラス
54 class Exception
55 {
56 private:
57     static bool is_throwable;
58
59 protected:
60     int         code;       //例外コード
61     std::string classname;  //この例外を生成したクラスの名前 (識別用)
62     std::string details;    //例外の説明
63
64         //コンストラクタ
65     Exception(std::string classname = "Exception", int code = 0, std::string details = "") throw();
66     Exception(std::string classname, std::string details) throw();
67
68         //デストラクタ
69 public:
70     Exception(const Exception & src) throw();
71
72     virtual ~Exception(void) throw();
73
74         //is-an-instance-of関係の評価
75     inline bool isInstanceOf(const char * _classname) const throw()
76     {   return classname.compare(_classname) == 0;   }
77
78         //例外コードを取得する
79     inline int getCode(void) const throw()
80     {   return code;   }
81
82         //例外の説明を取得する
83     inline std::string getDetails(void) const throw()
84     {   return details;   }
85
86         //現在の例外制御フラグの状態に従って例外を発行する
87     inline bool throwException(void)
88     {
89         if(is_throwable)
90             throw *this;
91         return is_throwable;
92     }
93
94         //is_throwableのアクセサ
95     static void setThrowControl(bool _throwable) throw()
96     {   is_throwable = _throwable;   }
97
98     static bool getThrowControl(void) throw()
99     {   return is_throwable;   }
100
101
102 //  TESTSUITE_PROTOTYPE(main)
103 };
104
105
106 #define EXCEPTION(x)       class x : public Exception { public: x(void) throw() : Exception(#x)       {} };
107 #define EXCEPTION_(x,y)    class x : public Exception { public: x(void) throw() : Exception(#x, y)    {} };
108 #define EXCEPTION__(x,y,z) class x : public Exception { public: x(void) throw() : Exception(#x, y, z) {} };
109
110 #endif
111
112
113