Jpp
test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
software
DataQueue
CLBInterface
data_input_interface.hh
Go to the documentation of this file.
1
#ifndef DATA_INPUT_INTERFACE_HH
2
#define DATA_INPUT_INTERFACE_HH
3
4
#include <cassert>
5
#include <vector>
6
7
#include <boost/asio.hpp>
8
#include <boost/thread.hpp>
9
#include <boost/foreach.hpp>
10
#include <boost/scoped_ptr.hpp>
11
12
#include "
input_channel_handler.hh
"
13
14
/**
15
* \author cpellegrino
16
*/
17
18
class
DataInputInterface
19
{
20
size_t
m_number_of_workers
;
21
std::vector<InChannelHandler*>
m_channel_handlers
;
22
boost::asio::io_service
m_service
;
23
boost::scoped_ptr<boost::thread_group>
m_threads
;
24
25
public
:
26
27
DataInputInterface
(
size_t
number_of_workers = 1)
28
:
29
m_number_of_workers
(number_of_workers),
30
m_threads
(0)
31
{}
32
33
~DataInputInterface
()
34
{
35
stop
();
36
for
(
size_t
i = 0; i <
m_channel_handlers
.size(); ++i)
37
{
38
delete
m_channel_handlers
[i];
39
}
40
}
41
42
void
stop
()
43
{
44
m_service
.stop();
45
46
if
(
m_threads
)
47
{
48
m_threads
->join_all();
49
}
50
51
m_threads
.reset();
52
}
53
54
void
pause
()
55
{
56
BOOST_FOREACH(
InChannelHandler
* h,
m_channel_handlers
)
57
{
58
h->
pause
();
59
}
60
}
61
62
void
cont
()
63
{
64
BOOST_FOREACH(
InChannelHandler
* h,
m_channel_handlers
)
65
{
66
h->
cont
();
67
}
68
}
69
70
void
start
()
71
{
72
assert(!
m_threads
&&
"Calling DataInputInterface::start() on started istance."
);
73
74
m_threads
.reset(
new
boost::thread_group);
75
m_service
.reset();
76
for
(std::size_t i = 0; i <
m_number_of_workers
; ++i)
77
{
78
m_threads
->create_thread(boost::bind(&boost::asio::io_service::run,
79
&
m_service
));
80
}
81
}
82
83
void
add_worker
()
84
{
85
if
(
m_threads
)
86
{
87
m_threads
->create_thread(boost::bind(&boost::asio::io_service::run,
88
&
m_service
));
89
}
90
91
++
m_number_of_workers
;
92
}
93
94
void
add_channel
(
unsigned
short
port,
FrameFarm
& farm)
95
{
96
InChannelHandler
* new_channel =
new
InChannelHandler
(
m_service
, port, farm);
97
m_channel_handlers
.push_back(new_channel);
98
}
99
};
100
101
#endif
// INPUT_INTERFACE_HH
DataInputInterface
Definition
data_input_interface.hh:19
DataInputInterface::m_threads
boost::scoped_ptr< boost::thread_group > m_threads
Definition
data_input_interface.hh:23
DataInputInterface::add_worker
void add_worker()
Definition
data_input_interface.hh:83
DataInputInterface::m_number_of_workers
size_t m_number_of_workers
Definition
data_input_interface.hh:20
DataInputInterface::~DataInputInterface
~DataInputInterface()
Definition
data_input_interface.hh:33
DataInputInterface::m_channel_handlers
std::vector< InChannelHandler * > m_channel_handlers
Definition
data_input_interface.hh:21
DataInputInterface::start
void start()
Definition
data_input_interface.hh:70
DataInputInterface::pause
void pause()
Definition
data_input_interface.hh:54
DataInputInterface::stop
void stop()
Definition
data_input_interface.hh:42
DataInputInterface::add_channel
void add_channel(unsigned short port, FrameFarm &farm)
Definition
data_input_interface.hh:94
DataInputInterface::m_service
boost::asio::io_service m_service
Definition
data_input_interface.hh:22
DataInputInterface::DataInputInterface
DataInputInterface(size_t number_of_workers=1)
Definition
data_input_interface.hh:27
DataInputInterface::cont
void cont()
Definition
data_input_interface.hh:62
FrameFarm
Definition
frame_farm.hh:24
InChannelHandler
Definition
input_channel_handler.hh:16
InChannelHandler::pause
void pause()
Definition
input_channel_handler.hh:55
InChannelHandler::cont
void cont()
Definition
input_channel_handler.hh:60
std::vector
Definition
JSTDTypes.hh:15
input_channel_handler.hh
Generated by
1.12.0