IBR-DTN
1.0.0
Main Page
Namespaces
Classes
Files
File List
File Members
AbstractWorker.h
Go to the documentation of this file.
1
/*
2
* AbstractWorker.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
#ifndef ABSTRACTWORKER_H_
23
#define ABSTRACTWORKER_H_
24
25
#include <
ibrdtn/data/Bundle.h
>
26
#include <
ibrdtn/data/BundleID.h
>
27
#include <
ibrdtn/data/EID.h
>
28
#include "
core/EventReceiver.h
"
29
#include "
routing/QueueBundleEvent.h
"
30
#include <ibrcommon/thread/Mutex.h>
31
#include <ibrcommon/thread/Conditional.h>
32
#include <ibrcommon/thread/Thread.h>
33
#include "
net/ConvergenceLayer.h
"
34
35
#include <ibrcommon/thread/Queue.h>
36
#include <set>
37
38
using namespace
dtn::data;
39
40
namespace
dtn
41
{
42
namespace
core
43
{
44
class
AbstractWorker
:
public
ibrcommon::Mutex
45
{
46
class
AbstractWorkerAsync :
public
ibrcommon::JoinableThread,
public
dtn::core::EventReceiver
<dtn::routing::QueueBundleEvent>
47
{
48
public
:
49
AbstractWorkerAsync(
AbstractWorker
&worker);
50
virtual
~AbstractWorkerAsync();
51
52
void
initialize();
53
void
shutdown();
54
55
virtual
void
raiseEvent(
const
dtn::routing::QueueBundleEvent
&evt)
throw
();
56
57
protected
:
58
void
run()
throw
();
59
void
__cancellation()
throw
();
60
61
private
:
62
AbstractWorker
&_worker;
63
bool
_running
;
64
65
ibrcommon::Queue<dtn::data::BundleID> _receive_bundles;
66
};
67
68
public
:
69
AbstractWorker
();
70
71
virtual
~
AbstractWorker
();
72
73
virtual
const
EID
getWorkerURI()
const
;
74
75
virtual
void
callbackBundleReceived(
const
Bundle
&b) = 0;
76
77
protected
:
78
void
initialize(
const
std::string &uri);
79
void
transmit(
dtn::data::Bundle
&bundle);
80
81
dtn::data::EID
_eid
;
82
83
void
shutdown();
84
88
void
subscribe(
const
dtn::data::EID
&endpoint);
89
93
void
unsubscribe(
const
dtn::data::EID
&endpoint);
94
95
private
:
96
AbstractWorkerAsync _thread;
97
std::set<dtn::data::EID> _groups;
98
};
99
}
100
}
101
102
#endif
/*ABSTRACTWORKER_H_*/
dtn::core::AbstractWorker
Definition:
AbstractWorker.h:44
QueueBundleEvent.h
dtn::core::EventReceiver
Definition:
EventReceiver.h:32
Bundle.h
dtn::data::EID
Definition:
EID.h:34
dtn::data::Bundle
Definition:
Bundle.h:52
_running
bool _running
Definition:
dtninbox.cpp:122
BundleID.h
dtn::routing::QueueBundleEvent
Definition:
QueueBundleEvent.h:34
ConvergenceLayer.h
EventReceiver.h
EID.h
dtn::core::AbstractWorker::_eid
dtn::data::EID _eid
Definition:
AbstractWorker.h:81
daemon
src
core
AbstractWorker.h
Generated on Sun Jan 4 2015 15:27:32 for IBR-DTN by
1.8.6