IBR-DTNSuite  0.12
FileHash.cpp
Go to the documentation of this file.
1 /*
2  * FileHash.cpp
3  *
4  * Copyright (C) 2013 IBR, TU Braunschweig
5  *
6  * Written-by: David Goltzsche <goltzsch@ibr.cs.tu-bs.de>
7  * Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  * Created on: Oct 17, 2013
22  */
23 #include "FileHash.h"
24 
25 namespace io
26 {
28  {
29  }
30 
31  FileHash::FileHash(const std::string &path, const std::string &hash)
32  : _path(path), _hash(hash)
33  {
34  }
35 
37  {
38  }
39 
40  const std::string& FileHash::getHash() const
41  {
42  return _hash;
43  }
44 
45  const std::string& FileHash::getPath() const
46  {
47  return _path;
48  }
49 
50  bool FileHash::operator!=(const FileHash& other) const
51  {
52  return (_path != other.getPath()) || (_hash != other.getHash());
53  }
54 
55  bool FileHash::operator==(const FileHash& other) const
56  {
57  return (_path == other.getPath()) && (_hash == other.getHash());
58  }
59 
60  bool FileHash::operator<(const FileHash& other) const
61  {
62  if (_path < other.getPath()) return true;
63  if (_path > other.getPath()) return false;
64 
65  if (_hash < other.getHash()) return true;
66  return false;
67  }
68 }