Scroom  0.14
Scroom::Utils::ProgressInterfaceMultiplexer Class Reference

#include <progressinterfacehelpers.hh>

Inheritance diagram for Scroom::Utils::ProgressInterfaceMultiplexer:
Inheritance graph
Collaboration diagram for Scroom::Utils::ProgressInterfaceMultiplexer:
Collaboration graph

Classes

class  Child
 
class  ChildData
 

Public Types

using Ptr = boost::shared_ptr< ProgressInterfaceMultiplexer >
 

Public Member Functions

ProgressInterface::Ptr createProgressInterface ()
 
- Public Member Functions inherited from Scroom::Utils::Base
 Base ()=default
 
 Base (const Base &)=delete
 
 Base (Base &&)=delete
 
Baseoperator= (const Base &)=delete
 
Baseoperator= (Base &&)=delete
 
virtual ~Base ()=default
 
template<typename R >
boost::shared_ptr< R > shared_from_this ()
 
template<typename R >
boost::shared_ptr< R const > shared_from_this () const
 

Static Public Member Functions

static Ptr create (ProgressInterface::Ptr parent)
 

Private Member Functions

 ProgressInterfaceMultiplexer (ProgressInterface::Ptr parent)
 
void updateProgressState ()
 
void unsubscribe (const ChildData::Ptr &data)
 

Private Attributes

boost::mutex mut
 
ProgressStateInterface::Ptr parent
 
std::set< ChildData::Ptrchildren
 

Friends

class Child
 

Member Typedef Documentation

◆ Ptr

Constructor & Destructor Documentation

◆ ProgressInterfaceMultiplexer()

Scroom::Utils::ProgressInterfaceMultiplexer::ProgressInterfaceMultiplexer ( ProgressInterface::Ptr  parent)
explicitprivate
249  {
250  }

Referenced by create().

Here is the caller graph for this function:

Member Function Documentation

◆ create()

ProgressInterfaceMultiplexer::Ptr Scroom::Utils::ProgressInterfaceMultiplexer::create ( ProgressInterface::Ptr  parent)
static
253  {
254  return Ptr(new ProgressInterfaceMultiplexer(std::move(parent)));
255  }

Referenced by ProgressInterfaceMultiplexer_Fixture::ProgressInterfaceMultiplexer_Fixture().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createProgressInterface()

ProgressInterface::Ptr Scroom::Utils::ProgressInterfaceMultiplexer::createProgressInterface ( )
258  {
259  ChildData::Ptr const data = ChildData::create();
260  Child::Ptr child = Child::create(shared_from_this<ProgressInterfaceMultiplexer>(), data);
261 
262  boost::mutex::scoped_lock const l(mut);
263  children.insert(data);
264 
265  return child;
266  }
Here is the call graph for this function:

◆ unsubscribe()

void Scroom::Utils::ProgressInterfaceMultiplexer::unsubscribe ( const ChildData::Ptr data)
private
269  {
270  boost::mutex::scoped_lock const l(mut);
271  children.erase(data);
272  }

◆ updateProgressState()

void Scroom::Utils::ProgressInterfaceMultiplexer::updateProgressState ( )
private
275  {
277  double progress = 0.0;
278  int workers = 0;
279 
280  boost::mutex::scoped_lock const l(mut);
281  for(const ChildData::Ptr& child: children)
282  {
283  boost::mutex::scoped_lock const child_lock(child->mut);
284  switch(child->state)
285  {
287  break;
290  {
292  }
293  progress += child->progress;
294  workers++;
295  break;
298  {
300  }
301  progress += child->progress;
302  workers++;
303  break;
305  if(state == ProgressStateInterface::IDLE)
306  {
308  }
309  progress += 1.0;
310  workers++;
311  break;
312  }
313  }
314 
315  parent->setProgress(state, progress / workers);
316 
318  {
319  for(const ChildData::Ptr& child: children)
320  {
321  child->clearFinished();
322  }
323  }
324  }

Friends And Related Function Documentation

◆ Child

Member Data Documentation

◆ children

std::set<ChildData::Ptr> Scroom::Utils::ProgressInterfaceMultiplexer::children
private

◆ mut

boost::mutex Scroom::Utils::ProgressInterfaceMultiplexer::mut
private

◆ parent


The documentation for this class was generated from the following files:
Scroom::Utils::ProgressStateInterfaceFromProgressInterfaceForwarder::create
static Ptr create(ProgressInterface::Ptr child)
Definition: progressinterfacehelpers.cc:76
Scroom::Utils::ProgressInterfaceMultiplexer::ChildData::create
static Ptr create()
Definition: progressinterfacehelpers.cc:200
Scroom::Utils::ProgressStateInterface::FINISHED
@ FINISHED
Definition: progressinterfacehelpers.hh:34
Scroom::Utils::ProgressInterfaceMultiplexer::ProgressInterfaceMultiplexer
ProgressInterfaceMultiplexer(ProgressInterface::Ptr parent)
Definition: progressinterfacehelpers.cc:247
Scroom::Utils::ProgressInterfaceMultiplexer::Ptr
boost::shared_ptr< ProgressInterfaceMultiplexer > Ptr
Definition: progressinterfacehelpers.hh:184
Scroom::Utils::ProgressStateInterface::WAITING
@ WAITING
Definition: progressinterfacehelpers.hh:32
Scroom::Utils::ProgressInterfaceMultiplexer::children
std::set< ChildData::Ptr > children
Definition: progressinterfacehelpers.hh:239
Scroom::Utils::ProgressInterfaceMultiplexer::mut
boost::mutex mut
Definition: progressinterfacehelpers.hh:237
Scroom::Utils::ProgressInterfaceMultiplexer::parent
ProgressStateInterface::Ptr parent
Definition: progressinterfacehelpers.hh:238
Scroom::Utils::ProgressStateInterface::State
State
Definition: progressinterfacehelpers.hh:29
Scroom::Utils::ProgressInterfaceMultiplexer::Child::Ptr
boost::shared_ptr< Child > Ptr
Definition: progressinterfacehelpers.hh:212
Scroom::Utils::ProgressInterfaceMultiplexer::Child::create
static Ptr create(ProgressInterfaceMultiplexer::Ptr parent, ChildData::Ptr data)
Definition: progressinterfacehelpers.cc:233
Scroom::Utils::ProgressStateInterface::IDLE
@ IDLE
Definition: progressinterfacehelpers.hh:31
Scroom::Utils::ProgressInterfaceMultiplexer::ChildData::Ptr
boost::shared_ptr< ChildData > Ptr
Definition: progressinterfacehelpers.hh:190
Scroom::Utils::ProgressStateInterface::WORKING
@ WORKING
Definition: progressinterfacehelpers.hh:33