Update.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. #include "../../Netzwerk/Patcher.h"
  3. #include <Fortschritt.h>
  4. #include <Knopf.h>
  5. #include <Array.h>
  6. #include <Thread.h>
  7. using namespace Framework;
  8. class Update : private Thread
  9. {
  10. private:
  11. Patcher *p;
  12. FBalken *fb;
  13. bool updateAbbrechen;
  14. int dg;
  15. int ref;
  16. std::function< void(bool) > after;
  17. public:
  18. // Konstruktor
  19. Update( Schrift *zSchrift, FBalken *fb, int dg, std::function< void(bool) > after = [](bool b){} );
  20. // Destruktor
  21. ~Update();
  22. // nicht constant
  23. void setPatcher( Patcher *p );
  24. void abbrechen();
  25. void herunterladen();
  26. void thread() override;
  27. void threadEnd() override;
  28. // constant
  29. int getDateiGruppe() const;
  30. // Reference Counting
  31. Update *getThis();
  32. Update *release();
  33. };
  34. class UpdateHandler
  35. {
  36. private:
  37. Patcher *patcher;
  38. RCArray< Update > *updates;
  39. Critical cs;
  40. int ref;
  41. // privat
  42. void lock();
  43. void unlock();
  44. public:
  45. // Konstruktor
  46. UpdateHandler();
  47. // Destruktor
  48. ~UpdateHandler();
  49. // nicht constant
  50. bool add( Update *update );
  51. void remove( int dg = 0 );
  52. bool hat( int dg = 0 );
  53. // Reference Counting
  54. UpdateHandler *getThis();
  55. UpdateHandler *release();
  56. };