Path: blob/master/Source/CTest/cmCTestResourceAllocator.h
4998 views
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying1file LICENSE.rst or https://cmake.org/licensing for details. */2#pragma once34#include <map>5#include <string>67class cmCTestResourceSpec;89class cmCTestResourceAllocator10{11public:12struct Resource13{14unsigned int Total;15unsigned int Locked;1617unsigned int Free() const { return this->Total - this->Locked; }1819friend bool operator==(Resource left, Resource right)20{21return left.Total == right.Total && left.Locked == right.Locked;22}2324friend bool operator!=(Resource left, Resource right)25{26return !(left == right);27}28};2930void InitializeFromResourceSpec(cmCTestResourceSpec const& spec);3132std::map<std::string, std::map<std::string, Resource>> const& GetResources()33const;3435bool AllocateResource(std::string const& name, std::string const& id,36unsigned int slots);37bool DeallocateResource(std::string const& name, std::string const& id,38unsigned int slots);3940private:41std::map<std::string, std::map<std::string, Resource>> Resources;42};434445