cmCTestResourceAllocator.h 992 B

123456789101112131415161718192021222324252627282930313233343536
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include <map>
  5. #include <string>
  6. class cmCTestResourceSpec;
  7. class cmCTestResourceAllocator
  8. {
  9. public:
  10. struct Resource
  11. {
  12. unsigned int Total;
  13. unsigned int Locked;
  14. unsigned int Free() const { return this->Total - this->Locked; }
  15. bool operator==(const Resource& other) const;
  16. bool operator!=(const Resource& other) const;
  17. };
  18. void InitializeFromResourceSpec(const cmCTestResourceSpec& spec);
  19. const std::map<std::string, std::map<std::string, Resource>>& GetResources()
  20. const;
  21. bool AllocateResource(const std::string& name, const std::string& id,
  22. unsigned int slots);
  23. bool DeallocateResource(const std::string& name, const std::string& id,
  24. unsigned int slots);
  25. private:
  26. std::map<std::string, std::map<std::string, Resource>> Resources;
  27. };