Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

L2_assert.h

Go to the documentation of this file.
00001 // L2_assert.h 
00002 // this class defines a template assert class which throws exceptions for L2
00003 
00004 // types of exceptions::
00005 
00006 #ifndef L2_ASSERT_H_
00007 #define L2_ASSERT_H_
00008 
00009 #include <mba_utils/MBA_string.h>
00010 
00011 #define EXPR_OUT(x) #x
00012 
00013 
00014 
00015 // exception class for L2
00016 
00017 class L2_error
00018 {
00019 public:
00020         MBA_string error_string;
00021 
00022         L2_error(); // intentionally undefined so that a descriptive 
00023                                 // string must be provided
00024         L2_error(char * error_description) : error_string(error_description) {};
00025 };
00026 
00027 // exception class specific to out-of-bounds-errors
00028 class L2_bounds_error : public L2_error 
00029 {
00030 public:
00031         L2_bounds_error();
00032         L2_bounds_error(char *error_desc) : L2_error(error_desc) {};
00033 };
00034 
00035 // exception class for model reading errors
00036 class L2_reader_error : public L2_error 
00037 {
00038 public:
00039         L2_reader_error();
00040         L2_reader_error(char *error_desc) : L2_error(error_desc) {};
00041 };
00042 
00043 // exception class specific to bad runtime function arguments
00044 class L2_argument_error : public L2_error 
00045 {
00046 public:
00047         L2_argument_error();
00048 
00049         L2_argument_error(char *error_desc) : L2_error(error_desc) {};
00050 };
00051 
00052 // exception class specialized to resource allocation errors
00053 class L2_resource_error : public L2_error 
00054 {
00055 public:
00056         L2_resource_error();
00057         L2_resource_error(char *error_desc) : L2_error(error_desc) {};
00058 };
00059 
00060 
00061 // this is the function which replaces 'assert'
00062 template<class T, class Exc> inline void L2_assert( T expr, Exc exception )
00063 {
00064         if (!expr) throw exception;
00065 };
00066 
00067 #endif

Generated at Wed Sep 20 10:10:24 2000 for livingstone by doxygen 1.1.3 written by Dimitri van Heesch, © 1997-2000