/* * @project The CERN Tape Archive (CTA) * @copyright Copyright(C) 2003-2021 CERN * @license This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include #include #include "FilePositionInfos.hpp" namespace castor { namespace tape { namespace tapeserver { namespace rao { /** * This class represents an RAO file. It contains the index of the file in the vector * of jobs passed in the RAOAlgorithm::performRAO() method and the file position informations. * It also stores the distance this file has with other files. */ class RAOFile { public: RAOFile(const uint64_t index, const FilePositionInfos & filePositionInfos); RAOFile(const RAOFile & other); RAOFile &operator=(const RAOFile & other); uint64_t getIndex() const; /** * Get the position informations about this file * @return the position informations about this file */ FilePositionInfos getFilePositionInfos() const; /** * Add a distance between this file and another RAOFile * @param distance the distance to go from this file to another RAOFile * @param file the destination file */ void addDistanceToFile(const double distance, const RAOFile & file); /** * Get the closest file index i.e the file to which the cost to go to is the lowest * @return the closest file index. */ uint64_t getClosestFileIndex() const; bool operator<(const RAOFile &other) const; bool operator==(const RAOFile & other) const; virtual ~RAOFile(); private: uint64_t m_index; FilePositionInfos m_filePositionInfos; /** * This class holds information about the * cost to go to the destination file * @param cost the cost to go to the file located at the destinationFileIndex * @param destinationFileIndex the file to which we store the cost to go to */ class DistanceToFile { public: DistanceToFile(const double cost, const uint64_t destinationFileIndex); bool operator<(const DistanceToFile &other) const; /** * Returns the cost to go to the destination file located at the destinationFileIndex * @return the cost to go to the destination file */ double getCost() const; /** * Get the destination file index * @return the destination file index */ uint64_t getDestinationFileIndex() const; private: double m_cost; uint64_t m_destinationFileIndex; }; std::list m_distancesWithOtherFiles; }; }}}}