[363] | 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 | * ä¸è¨èä½æ¨©è
|
---|
| 10 | ã¯ï¼ä»¥ä¸ã® (1)ã(4) ã®æ¡ä»¶ãï¼Free Software Foundation
|
---|
| 11 | * ã«ãã£ã¦å
|
---|
| 12 | ¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
|
---|
| 13 | * è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
|
---|
| 14 | * ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹å¤ã»åé
|
---|
| 15 | å¸ï¼ä»¥ä¸ï¼
|
---|
| 16 | * å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
| 17 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
| 18 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
| 19 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
| 20 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 21 | * ç¨ã§ããå½¢ã§åé
|
---|
| 22 | å¸ããå ´åã«ã¯ï¼åé
|
---|
| 23 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
| 24 | * è
|
---|
| 25 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
| 26 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 27 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 28 | * ç¨ã§ããªãå½¢ã§åé
|
---|
| 29 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
| 30 | * ã¨ï¼
|
---|
| 31 | * (a) åé
|
---|
| 32 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
| 33 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
| 34 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 35 | * (b) åé
|
---|
| 36 | å¸ã®å½¢æ
|
---|
| 37 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
| 38 | * å ±åãããã¨ï¼
|
---|
| 39 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
| 40 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
| 41 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
| 42 | 責ãããã¨ï¼
|
---|
| 43 | *
|
---|
| 44 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
| 45 | ã
|
---|
| 46 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
|
---|
| 47 | * å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
|
---|
| 48 | * æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
|
---|
| 49 | *
|
---|
| 50 | * @(#) $Id: except.h,v 1.9 2003/12/20 06:51:58 takayuki Exp $
|
---|
| 51 | */
|
---|
| 52 |
|
---|
| 53 | // $Header: /home/CVS/configurator/base/except.h,v 1.9 2003/12/20 06:51:58 takayuki Exp $
|
---|
| 54 |
|
---|
| 55 | #ifndef EXCEPT_H
|
---|
| 56 | #define EXCEPT_H
|
---|
| 57 |
|
---|
| 58 | #ifdef _MSC_VER
|
---|
| 59 | # pragma warning(disable:4290) //C++ ã®ä¾å¤ã®æå®ã¯ç¡è¦ããã¾ããé¢æ°ã __declspec(nothrow) ã§ãªããã¨ã®ã¿è¡¨ç¤ºããã¾ãã
|
---|
| 60 | #endif
|
---|
| 61 |
|
---|
| 62 | //#include "testsuite.h"
|
---|
| 63 |
|
---|
| 64 | #include <string>
|
---|
| 65 | #include <typeinfo>
|
---|
| 66 |
|
---|
| 67 | //ä¾å¤åºåºã¯ã©ã¹
|
---|
| 68 | class Exception
|
---|
| 69 | {
|
---|
| 70 | private:
|
---|
| 71 | static bool is_throwable;
|
---|
| 72 |
|
---|
| 73 | protected:
|
---|
| 74 | int code; //ä¾å¤ã³ã¼ã
|
---|
| 75 | std::string classname; //ãã®ä¾å¤ãçæããã¯ã©ã¹ã®åå (èå¥ç¨)
|
---|
| 76 | std::string details; //ä¾å¤ã®èª¬æ
|
---|
| 77 |
|
---|
| 78 | //ã³ã³ã¹ãã©ã¯ã¿
|
---|
| 79 | Exception(std::string classname = "Exception", int code = 0, std::string details = "") throw();
|
---|
| 80 | Exception(std::string classname, std::string details) throw();
|
---|
| 81 |
|
---|
| 82 | //ãã¹ãã©ã¯ã¿
|
---|
| 83 | public:
|
---|
| 84 | Exception(const Exception & src) throw();
|
---|
| 85 |
|
---|
| 86 | virtual ~Exception(void) throw();
|
---|
| 87 |
|
---|
| 88 | //is-an-instance-ofé¢ä¿ã®è©ä¾¡
|
---|
| 89 | inline bool isInstanceOf(const char * _classname) const throw()
|
---|
| 90 | { return classname.compare(_classname) == 0; }
|
---|
| 91 |
|
---|
| 92 | //ä¾å¤ã³ã¼ããåå¾ãã
|
---|
| 93 | inline int getCode(void) const throw()
|
---|
| 94 | { return code; }
|
---|
| 95 |
|
---|
| 96 | //ä¾å¤ã®èª¬æãåå¾ãã
|
---|
| 97 | inline std::string getDetails(void) const throw()
|
---|
| 98 | { return details; }
|
---|
| 99 |
|
---|
| 100 | //ç¾å¨ã®ä¾å¤å¶å¾¡ãã©ã°ã®ç¶æ
|
---|
| 101 | ã«å¾ã£ã¦ä¾å¤ãçºè¡ãã
|
---|
| 102 | inline bool throwException(void)
|
---|
| 103 | {
|
---|
| 104 | if(is_throwable)
|
---|
| 105 | throw *this;
|
---|
| 106 | return is_throwable;
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | //is_throwableã®ã¢ã¯ã»ãµ
|
---|
| 110 | static void setThrowControl(bool _throwable) throw()
|
---|
| 111 | { is_throwable = _throwable; }
|
---|
| 112 |
|
---|
| 113 | static bool getThrowControl(void) throw()
|
---|
| 114 | { return is_throwable; }
|
---|
| 115 |
|
---|
| 116 |
|
---|
| 117 | // TESTSUITE_PROTOTYPE(main)
|
---|
| 118 | };
|
---|
| 119 |
|
---|
| 120 |
|
---|
| 121 | #define EXCEPTION(x) class x : public Exception { public: x(void) throw() : Exception(#x) {} };
|
---|
| 122 | #define EXCEPTION_(x,y) class x : public Exception { public: x(void) throw() : Exception(#x, y) {} };
|
---|
| 123 | #define EXCEPTION__(x,y,z) class x : public Exception { public: x(void) throw() : Exception(#x, y, z) {} };
|
---|
| 124 |
|
---|
| 125 | #endif
|
---|
| 126 |
|
---|
| 127 |
|
---|
| 128 |
|
---|