RAOFile.hpp 2.96 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * The CERN Tape Archive (CTA) project
 * Copyright (C) 2019  CERN
 *
 * 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 <http://www.gnu.org/licenses/>.
 */

#pragma once

21
22
23
#include <utility>
#include <list>

24
25
26
27
#include "FilePositionInfos.hpp"

namespace castor { namespace tape { namespace tapeserver { namespace rao {

28
29
30
31
32
/**
 * 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.
 */  
33
34
35
36
37
38
class RAOFile {
public:
  RAOFile(const uint64_t index, const FilePositionInfos & filePositionInfos);
  RAOFile(const RAOFile & other);
  RAOFile &operator=(const RAOFile & other);
  uint64_t getIndex() const;
39
40
41
42
  /**
   * Get the position informations about this file
   * @return the position informations about this file
   */
43
  FilePositionInfos getFilePositionInfos() const;
44
45
46
47
48
  /**
   * 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
   */
49
  void addDistanceToFile(const double distance, const RAOFile & file);
50
51
52
53
  /**
   * Get the closest file index i.e the file to which the cost to go to is the lowest
   * @return the closest file index.
   */
54
  uint64_t getClosestFileIndex() const;
55
56
  bool operator<(const RAOFile &other) const;
  bool operator==(const RAOFile & other) const;
57
  virtual ~RAOFile();
58
  
59
60
61
62
63
64
65
66
67
68
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
   */
69
70
71
72
  class DistanceToFile {
  public:
    DistanceToFile(const double cost, const uint64_t destinationFileIndex);
    bool operator<(const DistanceToFile &other) const;
73
74
75
76
    /**
     * Returns the cost to go to the destination file located at the destinationFileIndex
     * @return the cost to go to the destination file
     */
77
    double getCost() const;
78
79
80
81
    /**
     * Get the destination file index
     * @return the destination file index
     */
82
83
84
85
86
87
    uint64_t getDestinationFileIndex() const;
  private:
    double m_cost;
    uint64_t m_destinationFileIndex;
  };
  
88
  std::list<DistanceToFile> m_distancesWithOtherFiles;
89
90
91
};

}}}}