Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.4 KiB

  1. /*****************************************************************/
  2. /** Microsoft Windows for Workgroups **/
  3. /** Copyright (C) Microsoft Corp., 1991-1992 **/
  4. /*****************************************************************/
  5. /*
  6. base.h
  7. Universal base class for error cascading and debugging information
  8. FILE HISTORY
  9. beng 09-Jul-1990 created
  10. beng 17-Jul-1990 added standard comment header to BASE
  11. beng 31-Jul-1991 added FORWARDING_BASE
  12. rustanl 11-Sep-1991 Added DECLARE_OUTLINE_NEWBASE,
  13. DECLARE_MI_NEWBASE, DEFINE_MI2_NEWBASE,
  14. DEFINE_MI3_NEWBASE, and DEFINE_MI4_NEWBASE
  15. gregj 22-Mar-1993 Ported to Chicago environment
  16. */
  17. #ifndef _BASE_HXX_
  18. #define _BASE_HXX_
  19. /*************************************************************************
  20. NAME: BASE (base)
  21. SYNOPSIS: Universal base object, root of every class.
  22. It contains universal error status and debugging
  23. support.
  24. INTERFACE: ReportError() - report an error on the object from
  25. within the object.
  26. QueryError() - return the current error state,
  27. or 0 if no error outstanding.
  28. operator!() - return TRUE if an error is outstanding.
  29. Typically means that construction failed.
  30. CAVEATS: This sort of error reporting is safe enough in a single-
  31. threaded system, but loses robustness when multiple threads
  32. access shared objects. Use it for constructor-time error
  33. handling primarily.
  34. NOTES: A class which inherits BASE through a private class should
  35. use the NEWBASE macro (q.v.) in its definition; otherwise
  36. its clients will lose the use of ! and QueryError.
  37. HISTORY:
  38. rustanl 07-Jun-1990 Created as part of LMOD
  39. beng 09-Jul-1990 Gutted, removing LMOD methods
  40. beng 17-Jul-1990 Added USHORT error methods
  41. beng 19-Oct-1990 Finally, removed BOOL error methods
  42. johnl 14-Nov-1990 Changed QueryError to be a const method
  43. beng 25-Jan-1991 Added the ! Boolean operator and NEWBASE
  44. beng 31-Jul-1991 Made FORWARDING_BASE a friend
  45. gregj 22-Mar-1993 Ported to Chicago (removed excess baggage)
  46. *************************************************************************/
  47. class BASE
  48. {
  49. private:
  50. UINT _err;
  51. protected:
  52. BASE() { _err = 0; }
  53. VOID ReportError( WORD err ) { _err = err; }
  54. public:
  55. UINT QueryError() const { return _err; }
  56. BOOL operator!() const { return (_err != 0); }
  57. };
  58. #endif // _BASE_HXX_