test_variable.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include "direct_access.h"
  2. #include <library/cpp/yt/global/mock_modules/module2_public/test_tag.h>
  3. #include <library/cpp/yt/global/variable.h>
  4. namespace NYT {
  5. ////////////////////////////////////////////////////////////////////////////////
  6. NGlobal::TErasedStorage GetGlobal2() noexcept;
  7. NGlobal::TErasedStorage GetGlobal3() noexcept;
  8. ////////////////////////////////////////////////////////////////////////////////
  9. static NGlobal::TVariable<TGuid> TestVariable2{TestTag2, &GetGlobal2, TGuid{42, 77}};
  10. static NGlobal::TVariable<std::array<int, 4>> TestVariable3{
  11. TestTag3,
  12. &GetGlobal3,
  13. std::array{0, 0, 42, 77}};
  14. ////////////////////////////////////////////////////////////////////////////////
  15. NGlobal::TErasedStorage GetGlobal2() noexcept
  16. {
  17. return NGlobal::TErasedStorage{TestVariable2.Get()};
  18. }
  19. NGlobal::TErasedStorage GetGlobal3() noexcept
  20. {
  21. return NGlobal::TErasedStorage{TestVariable3.Get()};
  22. }
  23. ////////////////////////////////////////////////////////////////////////////////
  24. TGuid GetTestVariable2()
  25. {
  26. return TestVariable2.Get();
  27. }
  28. void SetTestVariable2(TGuid val)
  29. {
  30. TestVariable2.Set(val);
  31. }
  32. std::array<int, 4> GetTestVariable3()
  33. {
  34. return TestVariable3.Get();
  35. }
  36. void SetTestVariable3(std::array<int, 4> val)
  37. {
  38. TestVariable3.Set(val);
  39. }
  40. ////////////////////////////////////////////////////////////////////////////////
  41. } // namespace NYT