cmCTestResourceAllocator.h 1.0 KB

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