Update.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. };
  30. class UpdateHandler
  31. {
  32. private:
  33. Patcher *patcher;
  34. RCArray< Update > *updates;
  35. Critical cs;
  36. int ref;
  37. // privat
  38. void lock();
  39. void unlock();
  40. public:
  41. // Konstruktor
  42. UpdateHandler();
  43. // Destruktor
  44. ~UpdateHandler();
  45. // nicht constant
  46. bool add( Update *update );
  47. void remove( int dg = 0 );
  48. bool hat( int dg = 0 );
  49. // Reference Counting
  50. UpdateHandler *getThis();
  51. UpdateHandler *release();
  52. };