Jpp  18.3.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | List of all members
DataInputInterface Class Reference

#include <data_input_interface.hh>

Public Member Functions

 DataInputInterface (size_t number_of_workers=1)
 
 ~DataInputInterface ()
 
void stop ()
 
void pause ()
 
void cont ()
 
void start ()
 
void add_worker ()
 
void add_channel (unsigned short port, FrameFarm &farm)
 

Private Attributes

size_t m_number_of_workers
 
std::vector< InChannelHandler * > m_channel_handlers
 
boost::asio::io_service m_service
 
boost::scoped_ptr
< boost::thread_group > 
m_threads
 

Detailed Description

Author
cpellegrino

Definition at line 18 of file data_input_interface.hh.

Constructor & Destructor Documentation

DataInputInterface::DataInputInterface ( size_t  number_of_workers = 1)
inline

Definition at line 27 of file data_input_interface.hh.

28  :
29  m_number_of_workers(number_of_workers),
30  m_threads(0)
31  {}
boost::scoped_ptr< boost::thread_group > m_threads
DataInputInterface::~DataInputInterface ( )
inline

Definition at line 33 of file data_input_interface.hh.

34  {
35  stop();
36  for (size_t i = 0; i < m_channel_handlers.size(); ++i)
37  {
38  delete m_channel_handlers[i];
39  }
40  }
std::vector< InChannelHandler * > m_channel_handlers

Member Function Documentation

void DataInputInterface::stop ( )
inline

Definition at line 42 of file data_input_interface.hh.

43  {
44  m_service.stop();
45 
46  if (m_threads)
47  {
48  m_threads->join_all();
49  }
50 
51  m_threads.reset();
52  }
boost::asio::io_service m_service
boost::scoped_ptr< boost::thread_group > m_threads
void DataInputInterface::pause ( )
inline

Definition at line 54 of file data_input_interface.hh.

55  {
56  BOOST_FOREACH(InChannelHandler* h, m_channel_handlers)
57  {
58  h->pause();
59  }
60  }
std::vector< InChannelHandler * > m_channel_handlers
void DataInputInterface::cont ( )
inline

Definition at line 62 of file data_input_interface.hh.

63  {
64  BOOST_FOREACH(InChannelHandler* h, m_channel_handlers)
65  {
66  h->cont();
67  }
68  }
std::vector< InChannelHandler * > m_channel_handlers
void DataInputInterface::start ( )
inline

Definition at line 70 of file data_input_interface.hh.

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  }
boost::asio::io_service m_service
boost::scoped_ptr< boost::thread_group > m_threads
void DataInputInterface::add_worker ( )
inline

Definition at line 83 of file data_input_interface.hh.

84  {
85  if (m_threads)
86  {
87  m_threads->create_thread(boost::bind(&boost::asio::io_service::run,
88  &m_service));
89  }
90 
92  }
boost::asio::io_service m_service
boost::scoped_ptr< boost::thread_group > m_threads
void DataInputInterface::add_channel ( unsigned short  port,
FrameFarm farm 
)
inline

Definition at line 94 of file data_input_interface.hh.

95  {
96  InChannelHandler* new_channel = new InChannelHandler(m_service, port, farm);
97  m_channel_handlers.push_back(new_channel);
98  }
boost::asio::io_service m_service
std::vector< InChannelHandler * > m_channel_handlers

Member Data Documentation

size_t DataInputInterface::m_number_of_workers
private

Definition at line 20 of file data_input_interface.hh.

std::vector<InChannelHandler*> DataInputInterface::m_channel_handlers
private

Definition at line 21 of file data_input_interface.hh.

boost::asio::io_service DataInputInterface::m_service
private

Definition at line 22 of file data_input_interface.hh.

boost::scoped_ptr<boost::thread_group> DataInputInterface::m_threads
private

Definition at line 23 of file data_input_interface.hh.


The documentation for this class was generated from the following file: