home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Multimedia / k3d-setup-0.7.11.0.exe / include / k3d / k3dsdk / result.h < prev    next >
C/C++ Source or Header  |  2008-01-23  |  3KB  |  108 lines

  1. #ifndef K3DSDK_RESULT_H
  2. #define K3DSDK_RESULT_H
  3.  
  4. // K-3D
  5. // Copyright (c) 1995-2004, Timothy M. Shead
  6. //
  7. // Contact: tshead@k-3d.com
  8. //
  9. // This program is free software; you can redistribute it and/or
  10. // modify it under the terms of the GNU General Public
  11. // License as published by the Free Software Foundation; either
  12. // version 2 of the License, or (at your option) any later version.
  13. //
  14. // This program is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17. // General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU General Public
  20. // License along with this program; if not, write to the Free Software
  21. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  22.  
  23. /** \file
  24.         \brief Declares void and Glib-like assert/return functions
  25.         \author Romain Behar (romainbehar@yahoo.com)
  26.         \author Tim Shead (tshead@k-3d.com)
  27. */
  28.  
  29. #include "log.h"
  30. #include <iostream>
  31.  
  32. #define assert_not_reached() \
  33.     do \
  34.         { \
  35.             k3d::log() << k3d::error << k3d_file_reference << ": should not be reached" << std::endl; \
  36.         } \
  37.     while(0)
  38.  
  39. #define assert_not_implemented() \
  40.     do \
  41.         { \
  42.             k3d::log() << k3d::error << k3d_file_reference << ": is not implemented" << std::endl; \
  43.         } \
  44.     while(0)
  45.  
  46. #define assert_deprecated() \
  47.     do \
  48.         { \
  49.             k3d::log() << k3d::warning << k3d_file_reference << ": is deprecated" << std::endl; \
  50.         } \
  51.     while(0)
  52.  
  53. #define assert_critical(expr) \
  54.     do \
  55.         { \
  56.             if(!(expr)) \
  57.                 { \
  58.                     k3d::log() << k3d::critical << k3d_file_reference << ": assertion `" << #expr << "' failed" << std::endl; \
  59.                 } \
  60.         } \
  61.     while(0)
  62.  
  63. #define assert_error(expr) \
  64.     do \
  65.         { \
  66.             if(!(expr)) \
  67.                 { \
  68.                     k3d::log() << k3d::error << k3d_file_reference << ": assertion `" << #expr << "' failed" << std::endl; \
  69.                 } \
  70.         } \
  71.     while(0)
  72.  
  73. #define assert_warning(expr) \
  74.     do \
  75.         { \
  76.             if(!(expr)) \
  77.                 { \
  78.                     k3d::log() << k3d::warning << k3d_file_reference << ": assertion `" << #expr << "' failed" << std::endl; \
  79.                 } \
  80.         } \
  81.     while(0)
  82.  
  83. #define return_if_fail(expr) \
  84.     do \
  85.         { \
  86.             if(!(expr)) \
  87.                 { \
  88.                     k3d::log() << k3d::error << k3d_file_reference << ": assertion `" << #expr << "' failed" << std::endl; \
  89.                     return; \
  90.                 } \
  91.         } \
  92.     while(0)
  93.  
  94. #define return_val_if_fail(expr, val) \
  95.     do \
  96.         { \
  97.             if(!(expr)) \
  98.                 { \
  99.                     k3d::log() << k3d::error << k3d_file_reference << ": assertion `" << #expr << "' failed" << std::endl; \
  100.                     return val; \
  101.                 } \
  102.         } \
  103.     while(0)
  104.  
  105. #endif // !K3DSDK_RESULT_H
  106.  
  107.  
  108.