ph.cpp 770 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // This file is part of Desktop App Toolkit,
  2. // a set of libraries for developing nice desktop applications.
  3. //
  4. // For license and copyright information please follow this link:
  5. // https://github.com/desktop-app/legal/blob/master/LEGAL
  6. //
  7. #include "ui/ph.h"
  8. namespace ph {
  9. namespace {
  10. int &PhraseCounter() {
  11. static auto result = 0;
  12. return result;
  13. }
  14. } // namespace
  15. phrase::phrase(const QString &initial) : value(initial) {
  16. if (auto &counter = PhraseCounter()) {
  17. ++counter;
  18. }
  19. }
  20. phrase::phrase(rpl::producer<QString> initial) : value(std::move(initial)) {
  21. }
  22. now_t start_phrase_count() {
  23. PhraseCounter() = 1;
  24. return now;
  25. }
  26. now_t check_phrase_count(int count) {
  27. Expects(PhraseCounter() == count + 1);
  28. PhraseCounter() = 0;
  29. return now;
  30. }
  31. } // namespace ph