home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 275 / DPCS0111DVD.ISO / Toolkit / Audio-Visual / VirtualDub / Source / VirtualDub-1.9.10-src.7z / src / h / vd2 / system / progress.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-09-14  |  3.0 KB  |  97 lines

  1. //    VirtualDub - Video processing and capture application
  2. //    System library component
  3. //    Copyright (C) 1998-2004 Avery Lee, All Rights Reserved.
  4. //
  5. //    Beginning with 1.6.0, the VirtualDub system library is licensed
  6. //    differently than the remainder of VirtualDub.  This particular file is
  7. //    thus licensed as follows (the "zlib" license):
  8. //
  9. //    This software is provided 'as-is', without any express or implied
  10. //    warranty.  In no event will the authors be held liable for any
  11. //    damages arising from the use of this software.
  12. //
  13. //    Permission is granted to anyone to use this software for any purpose,
  14. //    including commercial applications, and to alter it and redistribute it
  15. //    freely, subject to the following restrictions:
  16. //
  17. //    1.    The origin of this software must not be misrepresented; you must
  18. //        not claim that you wrote the original software. If you use this
  19. //        software in a product, an acknowledgment in the product
  20. //        documentation would be appreciated but is not required.
  21. //    2.    Altered source versions must be plainly marked as such, and must
  22. //        not be misrepresented as being the original software.
  23. //    3.    This notice may not be removed or altered from any source
  24. //        distribution.
  25.  
  26. #ifndef f_SYSTEM_PROGRESS_H
  27. #define f_SYSTEM_PROGRESS_H
  28.  
  29. #include <vd2/system/error.h>
  30.  
  31. class VDAtomicInt;
  32. class VDSignalPersistent;
  33.  
  34. class IProgress {
  35. public:
  36.     virtual void Error(const char *)=0;
  37.     virtual void Warning(const char *)=0;
  38.     virtual bool Query(const char *query, bool fDefault)=0;
  39.     virtual void ProgressStart(const char *text, const char *caption, const char *progtext, long lMax)=0;
  40.     virtual void ProgressAdvance(long)=0;
  41.     virtual void ProgressEnd()=0;
  42.     virtual void Output(const char *text)=0;
  43.     virtual VDAtomicInt *ProgressGetAbortFlag()=0;
  44.     virtual VDSignalPersistent *ProgressGetAbortSignal()=0;
  45. };
  46.  
  47.  
  48. void ProgressSetHandler(IProgress *pp);
  49. IProgress *ProgressGetHandler();
  50.  
  51. bool ProgressCheckAbort();
  52. void ProgressSetAbort(bool bNewValue);
  53. VDSignalPersistent *ProgressGetAbortSignal();
  54. void ProgressError(const class MyError&);
  55. void ProgressWarning(const char *format, ...);
  56. void ProgressOutput(const char *format, ...);
  57. bool ProgressQuery(bool fDefault, const char *format, ...);
  58. void ProgressStart(long lMax, const char *caption, const char *progresstext, const char *format, ...);
  59. void ProgressAdvance(long lNewValue);
  60. void ProgressEnd();
  61.  
  62.  
  63. class VDProgress {
  64. public:
  65.     VDProgress(long lMax, const char *caption, const char *progresstext, const char *format, ...) {
  66.         ProgressStart(lMax, caption, progresstext, format);
  67.     }
  68.  
  69.     ~VDProgress() {
  70.         ProgressEnd();
  71.     }
  72.  
  73.     void advance(long v) {
  74.         ProgressAdvance(v);
  75.     }
  76. };
  77.  
  78. class VDProgressAbortable {
  79. public:
  80.     VDProgressAbortable(long lMax, const char *caption, const char *progresstext, const char *format, ...) {
  81.         ProgressStart(lMax, caption, progresstext, format);
  82.         ProgressSetAbort(false);
  83.     }
  84.  
  85.     ~VDProgressAbortable() {
  86.         ProgressEnd();
  87.     }
  88.  
  89.     void advance(long v) {
  90.         if (ProgressCheckAbort())
  91.             throw MyUserAbortError();
  92.         ProgressAdvance(v);
  93.     }
  94. };
  95.  
  96. #endif
  97.