Update.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 : public Thread
  9. {
  10. private:
  11. Patcher *p;
  12. FBalken *fb;
  13. bool updateAbbrechen;
  14. int dg;
  15. std::function< void(bool) > after;
  16. public:
  17. // Konstruktor
  18. Update( Schrift *zSchrift, FBalken *fb, int dg, std::function< void(bool) > after = [](bool b){} );
  19. // Destruktor
  20. ~Update();
  21. // nicht constant
  22. void setPatcher( Patcher *p );
  23. void abbrechen();
  24. void herunterladen();
  25. void thread() override;
  26. void threadEnd() override;
  27. // constant
  28. int getDateiGruppe() const;
  29. // löscht das objekt wenn es nicht mehr gebraucht wird und beendet den Thread
  30. Thread *release() override;
  31. };
  32. class UpdateHandler
  33. {
  34. private:
  35. Patcher *patcher;
  36. RCArray< Update > *updates;
  37. Critical cs;
  38. int ref;
  39. // privat
  40. void lock();
  41. void unlock();
  42. public:
  43. // Konstruktor
  44. UpdateHandler();
  45. // Destruktor
  46. ~UpdateHandler();
  47. // nicht constant
  48. bool add( Update *update );
  49. void remove( int dg = 0 );
  50. bool hat( int dg = 0 );
  51. // Reference Counting
  52. UpdateHandler *getThis();
  53. UpdateHandler *release();
  54. };