GME  13
GMEOLEError.h
Go to the documentation of this file.
00001 
00002 #if !defined(_GMEOLEERROR_H_)
00003 #define _GMEOLEERROR_H_
00004 
00005 #define ID_ERROR_FIRST                          100
00006 #define ID_ERROR_PROJECT_NOT_OPEN       (ID_ERROR_FIRST + 1)
00007 #define ID_ERROR_MGAPROJECT_NOT_OPEN (ID_ERROR_FIRST + 2)
00008 #define ID_ERROR_PROJECT_OPEN           (ID_ERROR_FIRST + 3)
00009 #define ID_ERROR_NO_CONSTMGR            (ID_ERROR_FIRST + 4)
00010 #define ID_ERROR_MODEL_INVALID          (ID_ERROR_FIRST + 5)
00011 #define ID_ERROR_ASPECT_INVALID         (ID_ERROR_FIRST + 6)
00012 #define ID_ERROR_PANEL_INVALID          (ID_ERROR_FIRST + 7)
00013 #define ID_ERROR_PTR_INVALID            (ID_ERROR_FIRST + 8)
00014 #define ID_ERROR_NOT_FOUND                      (ID_ERROR_FIRST + 9)
00015 
00016 #define PRECONDITION_ACTIVE_PROJECT \
00017         if (theApp.guiMetaProject == NULL) { \
00018                 AfxThrowOleDispatchException(ID_ERROR_PROJECT_NOT_OPEN, \
00019                         _T("GUI has no active MGA project.")); \
00020         } 
00021 
00022 #define PRECONDITION_ACTIVE_REAL_MGA_PROJECT    \
00023         if ((theApp.mgaProject == NULL) || (!theApp.proj_type_is_mga)) { \
00024                 AfxThrowOleDispatchException(ID_ERROR_MGAPROJECT_NOT_OPEN, \
00025                         _T("GUI has no active (valid) MGA project.")); \
00026         }
00027 
00028 #define PRECONDITION_NO_PROJECT \
00029 if (theApp.guiMetaProject != NULL) { \
00030                 AfxThrowOleDispatchException(ID_ERROR_PROJECT_OPEN, \
00031                         _T("GUI has active MGA project.")); \
00032         }
00033 
00034 #define PRECONDITION_ACTIVE_CONSTMGR \
00035         if (theApp.mgaConstMgr == NULL) { \
00036                 AfxThrowOleDispatchException(ID_ERROR_NO_CONSTMGR, \
00037                         _T("GUI has no active Constraint Manager.")); \
00038         }
00039 
00040 #define PRECONDITION_VALID_MODEL \
00041         if (!AmIValid()) { \
00042                 AfxThrowOleDispatchException(ID_ERROR_MODEL_INVALID, \
00043                         _T("Model window is invalid. Probably it is closed.")); \
00044         } 
00045 
00046 #define PRECONDITION_VALID_ASPECT \
00047         if (!AmIValid()) { \
00048                 AfxThrowOleDispatchException(ID_ERROR_ASPECT_INVALID, \
00049                         _T("Aspect is invalid. Probably its model window is closed.")); \
00050         } 
00051 
00052 #define PRECONDITION_VALID_PANEL \
00053         if ((!m_control) || (!m_control->GetSafeHwnd())) { \
00054                 AfxThrowOleDispatchException(ID_ERROR_PANEL_INVALID, \
00055                         _T("GUI panel is invalid.")); \
00056         } 
00057 
00058 #define PRECONDITION_VALID_PTR( x, y) \
00059         if ( (!x)) { \
00060                 AfxThrowOleDispatchException(ID_ERROR_PTR_INVALID, \
00061                         _T(y)); \
00062         } 
00063 
00064 #define SHOW_ERROR( z) \
00065         { \
00066                 AfxThrowOleDispatchException(ID_ERROR_NOT_FOUND, \
00067                         (z)); \
00068         } 
00069 
00070 #define THROW_IF_NULL( x, y) \
00071         if ( (!x)) { \
00072                 throw y; \
00073         } 
00074 
00075 #define THROW_IF_BOOL( x, y) \
00076         if ( (x)) { \
00077                 throw y; \
00078         } 
00079 
00080 #endif // !defined(_GMEOLEERROR_H_)