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.

108 lines
3.3 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. #ifndef CLI_PROGRESS_REPORTER_H
  24. #define CLI_PROGRESS_REPORTER_H
  25. #include <wx/string.h>
  26. #include <progress_reporter.h>
  27. /**
  28. * Reporter forwarding messages to stdout or stderr as appropriate
  29. */
  30. class CLI_PROGRESS_REPORTER : public PROGRESS_REPORTER
  31. {
  32. public:
  33. CLI_PROGRESS_REPORTER() {}
  34. virtual ~CLI_PROGRESS_REPORTER() {}
  35. static PROGRESS_REPORTER& GetInstance();
  36. /**
  37. * Set the number of phases.
  38. */
  39. virtual void SetNumPhases( int aNumPhases ) override {}
  40. virtual void AddPhases( int aNumPhases ) override {};
  41. /**
  42. * Initialize the \a aPhase virtual zone of the dialog progress bar.
  43. */
  44. virtual void BeginPhase( int aPhase ) override {}
  45. /**
  46. * Use the next available virtual zone of the dialog progress bar.
  47. */
  48. virtual void AdvancePhase() override {}
  49. /**
  50. * Use the next available virtual zone of the dialog progress bar and updates the message.
  51. */
  52. virtual void AdvancePhase( const wxString& aMessage ) override;
  53. /**
  54. * Display \a aMessage in the progress bar dialog.
  55. */
  56. virtual void Report( const wxString& aMessage ) override;
  57. /**
  58. * Set the progress value to aProgress (0..1).
  59. */
  60. virtual void SetCurrentProgress( double aProgress ) override {}
  61. /**
  62. * Fix the value that gives the 100 percent progress bar length
  63. * (inside the current virtual zone).
  64. */
  65. virtual void SetMaxProgress( int aMaxProgress ) override {}
  66. /**
  67. * Increment the progress bar length (inside the current virtual zone).
  68. */
  69. virtual void AdvanceProgress() override {}
  70. /**
  71. * Update the UI (if any).
  72. *
  73. * @warning This should only be called from the main thread.
  74. *
  75. * @return false if the user cancelled.
  76. */
  77. virtual bool KeepRefreshing( bool aWait = false ) override { return false; }
  78. /**
  79. * Change the title displayed on the window caption.
  80. *
  81. * Has meaning only for some reporters. Does nothing for others.
  82. *
  83. * @warning This should only be called from the main thread.
  84. */
  85. virtual void SetTitle( const wxString& aTitle ) override {}
  86. virtual bool IsCancelled() const override { return false; }
  87. private:
  88. void printLine( const wxString& aMessage );
  89. };
  90. #endif