IBR-DTN  1.0.0
ObservedFile.h
Go to the documentation of this file.
1 /*
2  * ObservedFile.h
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: Sep 23, 2013
22  */
23 
24 #include "io/FileHash.h"
25 #include <ibrcommon/data/File.h>
26 #include <ibrcommon/refcnt_ptr.h>
27 #include <vector>
28 #include <set>
29 #include <string>
30 
31 #ifndef OBSERVEDFILE_H_
32 #define OBSERVEDFILE_H_
33 
34 namespace io
35 {
37  {
38  public:
39  ObservedFile(const ibrcommon::File &file);
40  virtual ~ObservedFile();
41 
42  bool operator==(const ObservedFile &other) const;
43  bool operator<(const ObservedFile &other) const;
44 
48  void update();
49 
53  size_t getStableCounter() const;
54 
58  const ibrcommon::File& getFile() const;
59 
63  void findFiles(std::set<ObservedFile> &files) const;
64 
68  const io::FileHash& getHash() const;
69 
70  private:
71  io::FileHash __hash() const;
72 
73  static ibrcommon::File* __copy(const ibrcommon::File &file);
74 
75  refcnt_ptr<ibrcommon::File> _file;
76 
77  size_t _stable_counter;
78  io::FileHash _last_hash;
79 
80  const static std::string TAG;
81  };
82 }
83 
84 #endif /* OBSERVEDFILE_H_ */
void findFiles(std::set< ObservedFile > &files) const
size_t getStableCounter() const
virtual ~ObservedFile()
bool operator==(const ObservedFile &other) const
ObservedFile(const ibrcommon::File &file)
const io::FileHash & getHash() const
bool operator<(const ObservedFile &other) const
const ibrcommon::File & getFile() const