IBR-DTNSuite
0.12
Main Page
Namespaces
Classes
Files
File List
File Members
FileMonitor.h
Go to the documentation of this file.
1
/*
2
* FileMonitor.h
3
*
4
* Copyright (C) 2011 IBR, TU Braunschweig
5
*
6
* Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7
*
8
* Licensed under the Apache License, Version 2.0 (the "License");
9
* you may not use this file except in compliance with the License.
10
* You may obtain a copy of the License at
11
*
12
* http://www.apache.org/licenses/LICENSE-2.0
13
*
14
* Unless required by applicable law or agreed to in writing, software
15
* distributed under the License is distributed on an "AS IS" BASIS,
16
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
* See the License for the specific language governing permissions and
18
* limitations under the License.
19
*
20
*/
21
22
#include "
Component.h
"
23
#include "
core/Node.h
"
24
#include <
ibrcommon/data/File.h
>
25
#include <
ibrcommon/net/vsocket.h
>
26
#include <
ibrcommon/net/socket.h
>
27
#include <map>
28
29
#ifndef FILEMONITOR_H_
30
#define FILEMONITOR_H_
31
32
namespace
dtn
33
{
34
namespace
net
35
{
36
class
inotifysocket
:
ibrcommon::basesocket
37
{
38
public
:
39
inotifysocket
();
40
virtual
~inotifysocket
();
41
42
virtual
void
up
()
throw
(
ibrcommon::socket_exception
);
43
virtual
void
down
()
throw
(
ibrcommon::socket_exception
);
44
45
void
watch
(
const
ibrcommon::File
&path,
int
opts)
throw
(
ibrcommon::socket_exception
);
46
47
ssize_t
read
(
char
*data,
size_t
len)
throw
(
ibrcommon::socket_exception
);
48
49
private
:
50
51
typedef
std::map<int, ibrcommon::File> watch_map;
52
watch_map _watch_map;
53
};
54
55
class
FileMonitor
:
public
dtn::daemon::IndependentComponent
56
{
57
public
:
58
FileMonitor
();
59
virtual
~FileMonitor
();
60
61
void
watch
(
const
ibrcommon::File
&
watch
);
62
63
const
std::string
getName
()
const
;
64
65
protected
:
66
void
componentUp
()
throw
();
67
void
componentRun
()
throw
();
68
void
componentDown
()
throw
();
69
70
void
__cancellation
()
throw
();
71
72
private
:
73
void
scan();
74
bool
isActive(
const
ibrcommon::File
&path)
const
;
75
76
void
adopt(
const
ibrcommon::File
&path);
77
78
ibrcommon::File
_watch;
79
ibrcommon::vsocket
_socket;
80
81
typedef
std::set<ibrcommon::File> watch_set;
82
watch_set _watchset;
83
84
bool
_running;
85
86
std::map<ibrcommon::File, dtn::core::Node> _active_paths;
87
88
};
89
}
90
}
/* namespace ibrcommon */
91
#endif
/* FILEMONITOR_H_ */
daemon
src
net
FileMonitor.h
Generated on Thu Mar 27 2014 09:26:20 for IBR-DTNSuite by
1.8.4