Scroom 0.14-48-ga0fee447
Loading...
Searching...
No Matches
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 = std::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 >
std::shared_ptr< R > shared_from_this ()
 
template<typename R >
std::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
254 {
255 }
ProgressStateInterface::Ptr parent
Definition progressinterfacehelpers.hh:238
static Ptr create(ProgressInterface::Ptr child)
Definition progressinterfacehelpers.cc:78

Member Function Documentation

◆ create()

ProgressInterfaceMultiplexer::Ptr Scroom::Utils::ProgressInterfaceMultiplexer::create ( ProgressInterface::Ptr  parent)
static
258 {
259 return Ptr(new ProgressInterfaceMultiplexer(std::move(parent)));
260 }
ProgressInterfaceMultiplexer(ProgressInterface::Ptr parent)
Definition progressinterfacehelpers.cc:252
std::shared_ptr< ProgressInterfaceMultiplexer > Ptr
Definition progressinterfacehelpers.hh:184

Referenced by ProgressInterfaceMultiplexer_Tests::ProgressInterfaceMultiplexer_Tests().

Here is the caller graph for this function:

◆ createProgressInterface()

ProgressInterface::Ptr Scroom::Utils::ProgressInterfaceMultiplexer::createProgressInterface ( )
263 {
265 Child::Ptr child = Child::create(shared_from_this<ProgressInterfaceMultiplexer>(), data);
266
267 boost::mutex::scoped_lock const l(mut);
268 children.insert(data);
269
270 return child;
271 }
uint8_t data
Definition blob-tests.cc:36
std::shared_ptr< ChildData > Ptr
Definition progressinterfacehelpers.hh:190
static Ptr create()
Definition progressinterfacehelpers.cc:205
static Ptr create(ProgressInterfaceMultiplexer::Ptr parent, ChildData::Ptr data)
Definition progressinterfacehelpers.cc:239
std::shared_ptr< Child > Ptr
Definition progressinterfacehelpers.hh:212
std::set< ChildData::Ptr > children
Definition progressinterfacehelpers.hh:239
boost::mutex mut
Definition progressinterfacehelpers.hh:237
PageList const l
Definition compression-tests.cc:33
Here is the call graph for this function:

◆ unsubscribe()

void Scroom::Utils::ProgressInterfaceMultiplexer::unsubscribe ( const ChildData::Ptr data)
private
274 {
275 boost::mutex::scoped_lock const l(mut);
276 children.erase(data);
277 }

◆ updateProgressState()

void Scroom::Utils::ProgressInterfaceMultiplexer::updateProgressState ( )
private
280 {
282 double progress = 0.0;
283 int workers = 0;
284
285 boost::mutex::scoped_lock const l(mut);
286 for(const ChildData::Ptr& child: children)
287 {
288 boost::mutex::scoped_lock const child_lock(child->mut);
289 switch(child->state)
290 {
292 break;
295 {
297 }
298 progress += child->progress;
299 workers++;
300 break;
303 {
305 }
306 progress += child->progress;
307 workers++;
308 break;
311 {
313 }
314 progress += 1.0;
315 workers++;
316 break;
317 }
318 }
319
320 parent->setProgress(state, progress / workers);
321
323 {
324 for(const ChildData::Ptr& child: children)
325 {
326 child->clearFinished();
327 }
328 }
329 }
State
Definition progressinterfacehelpers.hh:30
@ WAITING
Definition progressinterfacehelpers.hh:32
@ IDLE
Definition progressinterfacehelpers.hh:31
@ WORKING
Definition progressinterfacehelpers.hh:33
@ FINISHED
Definition progressinterfacehelpers.hh:34
stub progress
Definition progressinterfaceconversion-tests.cc:65

Friends And Related Symbol Documentation

◆ Child

friend class Child
friend

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: