TapeFile.cpp 2.82 KB
Newer Older
1
/*
2
 * @project        The CERN Tape Archive (CTA)
3
 * @copyright      Copyright(C) 2015-2021 CERN
4
5
6
7
 * @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.
8
 *
9
10
11
12
 *                 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.
13
 *
14
15
 *                 You should have received a copy of the GNU General Public License
 *                 along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17
 */

18
#include "common/dataStructures/TapeFile.hpp"
19
#include "common/dataStructures/utils.hpp"
20
21
#include "common/exception/Exception.hpp"

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

26
//------------------------------------------------------------------------------
Daniele Kruse's avatar
Daniele Kruse committed
27
28
// constructor
//------------------------------------------------------------------------------
29
TapeFile::TapeFile():
30
  fSeq(0),
Daniele Kruse's avatar
Daniele Kruse committed
31
  blockId(0),
32
  fileSize(0),
33
  copyNb(0),
34
  creationTime(0) {}
Daniele Kruse's avatar
Daniele Kruse committed
35
36

//------------------------------------------------------------------------------
37
// operator==
38
//------------------------------------------------------------------------------
39
bool TapeFile::operator==(const TapeFile &rhs) const {
40
  return vid==rhs.vid
41
      && fSeq==rhs.fSeq
42
      && blockId==rhs.blockId
43
      && fileSize==rhs.fileSize
Daniele Kruse's avatar
Daniele Kruse committed
44
      && copyNb==rhs.copyNb
45
      && creationTime==rhs.creationTime;
46
47
48
}

//------------------------------------------------------------------------------
49
// operator!=
50
//------------------------------------------------------------------------------
51
bool TapeFile::operator!=(const TapeFile &rhs) const {
52
  return !operator==(rhs);
53
54
}

55
//------------------------------------------------------------------------------
Cedric Caffy's avatar
Cedric Caffy committed
56
// TapeFile::matchesCopyNb
57
//------------------------------------------------------------------------------
Cedric Caffy's avatar
Cedric Caffy committed
58
59
bool TapeFile::matchesCopyNb(uint8_t cnb) const {
  return (cnb == copyNb);
60
61
}

62
//------------------------------------------------------------------------------
63
// operator<<
64
//------------------------------------------------------------------------------
65
std::ostream &operator<<(std::ostream &os, const TapeFile &obj) {
66
  os << "(vid=" << obj.vid
67
     << " fSeq=" << obj.fSeq
68
     << " blockId=" << obj.blockId
69
     << " fileSize=" << obj.fileSize
Cedric Caffy's avatar
Cedric Caffy committed
70
     << " copyNb=" << static_cast<int>(obj.copyNb)
71
72
     << " creationTime=" << obj.creationTime;
  os << ")";
73
  return os;
74
75
}

76
77
78
} // namespace dataStructures
} // namespace common
} // namespace cta