MountPolicy.cpp 3.43 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * The CERN Tape Archive (CTA) project
 * Copyright (C) 2015  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/>.
 */

#include "common/dataStructures/MountPolicy.hpp"
20
#include "common/dataStructures/utils.hpp"
21
22
#include "common/exception/Exception.hpp"

23
24
25
26
namespace cta {
namespace common {
namespace dataStructures {

Daniele Kruse's avatar
Daniele Kruse committed
27
28
29
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
30
MountPolicy::MountPolicy():
31
32
33
34
  archivePriority(0),
  archiveMinRequestAge(0),
  retrievePriority(0),
  retrieveMinRequestAge(0),
35
  maxDrivesAllowed(0) {}
Daniele Kruse's avatar
Daniele Kruse committed
36

37
38
39
40
MountPolicy::MountPolicy(const std::string name, const uint64_t archivePriority,const uint64_t archiveMinRequestAge, const uint64_t retrievePriority, 
        const uint64_t retrieveMinRequestAge, const uint64_t maxDrivesAllowed):
        name(name), archivePriority(archivePriority), archiveMinRequestAge(archiveMinRequestAge), retrievePriority(retrievePriority), 
        retrieveMinRequestAge(retrieveMinRequestAge), maxDrivesAllowed(maxDrivesAllowed) {}
41
//------------------------------------------------------------------------------
42
// operator==
43
//------------------------------------------------------------------------------
44
bool MountPolicy::operator==(const MountPolicy &rhs) const {
45
  return name==rhs.name
46
47
48
49
      && archivePriority==rhs.archivePriority
      && archiveMinRequestAge==rhs.archiveMinRequestAge
      && retrievePriority==rhs.retrievePriority
      && retrieveMinRequestAge==rhs.retrieveMinRequestAge
50
51
52
53
      && maxDrivesAllowed==rhs.maxDrivesAllowed
      && creationLog==rhs.creationLog
      && lastModificationLog==rhs.lastModificationLog
      && comment==rhs.comment;
54
55
56
}

//------------------------------------------------------------------------------
57
// operator!=
58
//------------------------------------------------------------------------------
59
bool MountPolicy::operator!=(const MountPolicy &rhs) const {
60
  return !operator==(rhs);
61
62
63
}

//------------------------------------------------------------------------------
64
// operator<<
65
//------------------------------------------------------------------------------
66
std::ostream &operator<<(std::ostream &os, const MountPolicy &obj) {
67
  os << "(name=" << obj.name
68
69
70
71
     << " archive_priority=" << obj.archivePriority
     << " archive_minRequestAge=" << obj.archiveMinRequestAge
     << " retrieve_priority=" << obj.retrievePriority
     << " retrieve_minRequestAge=" << obj.retrieveMinRequestAge
72
73
74
75
     << " maxDrivesAllowed=" << obj.maxDrivesAllowed
     << " creationLog=" << obj.creationLog
     << " lastModificationLog=" << obj.lastModificationLog
     << " comment=" << obj.comment << ")";
76
  return os;
77
78
}

79
80
MountPolicy MountPolicy::s_defaultMountPolicyForRepack("default_mount_policy_repack",1,1,1,1,1);

81
82
83
} // namespace dataStructures
} // namespace common
} // namespace cta