Tag Parser  6.2.2
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Public Types | Public Member Functions | Protected Member Functions | List of all members
Media::StatusProvider Class Reference

The StatusProvider class acts as a base class for objects providing status information. More...

#include <statusprovider.h>

Inheritance diagram for Media::StatusProvider:
[legend]

Public Types

typedef std::function< void(StatusProvider &sender)> CallbackFunction
 
typedef std::vector< CallbackFunctionCallbackVector
 
typedef std::pair< int, CallbackFunctionCallbackPair
 

Public Member Functions

const NotificationListnotifications () const
 Returns notifications for the current object. More...
 
bool hasNotifications () const
 Returns an indication whether there are notifications for the current object. More...
 
bool hasCriticalNotifications () const
 Returns an indication whether there are critical notifications for the current object. More...
 
NotificationType worstNotificationType () const
 Returns the worst notification type. More...
 
const std::string & currentStatus () const
 Returns a status information for the current object. More...
 
double currentPercentage () const
 Returns the progress percentage of the current object. More...
 
size_t registerCallback (CallbackFunction callback)
 Registers a callback function. More...
 
void unregisterCallback (size_t id)
 Unregisters a previously registered callback function whith the specified id. More...
 
void unregisterAllCallbacks ()
 Unregisters all callback functions. More...
 
void forwardStatusUpdateCalls (StatusProvider *other=nullptr)
 Forwards all status updates calls to the specified statusProvider. More...
 
StatusProviderusedProvider ()
 Returns the provider which callback functions will be called when the status or the percentage is updated. More...
 
void tryToAbort ()
 Commands the object to abort the current operation. More...
 
bool isAborted () const
 Returns an indication whether the current operation should be aborted. More...
 
void invalidateStatus ()
 Invalidates the current status. More...
 
void invalidateNotifications ()
 Invalidates the object's notifications. More...
 
void updateStatus (const std::string &status)
 This method is meant to be called by the derived class to report updated status information. More...
 
void updateStatus (const std::string &status, double percentage)
 This method is meant to be called by the derived class to report updated status information. More...
 
void updatePercentage (double percentage)
 This method is meant to be called by the derived class to report updated progress percentage only. More...
 
void addNotification (const Notification &notification)
 This protected method is meant to be called by the derived class to add a notification. More...
 
void addNotification (NotificationType type, const std::string &message, const std::string &context)
 This protected method is meant to be called by the derived class to add a notification of the specified type, message and context. More...
 
void addNotifications (const StatusProvider &from)
 This protected method is meant to be called by the derived class to add all notifications from another StatusProvider instance. More...
 
void addNotifications (const std::string &higherContext, const StatusProvider &from)
 This protected method is meant to be called by the derived class to add all notifications from another StatusProvider instance. More...
 
void addNotifications (const NotificationList &notifications)
 This protected method is meant to be called by the derived class to add the specified notifications. More...
 

Protected Member Functions

 StatusProvider ()
 Constructs a new StatusProvider. More...
 

Detailed Description

The StatusProvider class acts as a base class for objects providing status information.

Definition at line 11 of file statusprovider.h.

Member Typedef Documentation

◆ CallbackFunction

typedef std::function<void (StatusProvider &sender)> Media::StatusProvider::CallbackFunction

Definition at line 14 of file statusprovider.h.

◆ CallbackPair

Definition at line 16 of file statusprovider.h.

◆ CallbackVector

Definition at line 15 of file statusprovider.h.

Constructor & Destructor Documentation

◆ StatusProvider()

Media::StatusProvider::StatusProvider ( )
protected

Constructs a new StatusProvider.

Since the class is meant to be used as base class the constructor is protected.

Definition at line 20 of file statusprovider.cpp.

Member Function Documentation

◆ addNotification() [1/2]

void Media::StatusProvider::addNotification ( const Notification notification)

This protected method is meant to be called by the derived class to add a notification.

Definition at line 53 of file statusprovider.cpp.

◆ addNotification() [2/2]

void Media::StatusProvider::addNotification ( NotificationType  type,
const std::string &  message,
const std::string &  context 
)

This protected method is meant to be called by the derived class to add a notification of the specified type, message and context.

Definition at line 64 of file statusprovider.cpp.

◆ addNotifications() [1/3]

void Media::StatusProvider::addNotifications ( const StatusProvider from)

This protected method is meant to be called by the derived class to add all notifications from another StatusProvider instance.

Definition at line 75 of file statusprovider.cpp.

◆ addNotifications() [2/3]

void Media::StatusProvider::addNotifications ( const std::string &  higherContext,
const StatusProvider from 
)

This protected method is meant to be called by the derived class to add all notifications from another StatusProvider instance.

The specified higherContext is concated with the original context string.

Definition at line 91 of file statusprovider.cpp.

◆ addNotifications() [3/3]

void Media::StatusProvider::addNotifications ( const NotificationList notifications)

This protected method is meant to be called by the derived class to add the specified notifications.

Definition at line 104 of file statusprovider.cpp.

◆ currentPercentage()

double Media::StatusProvider::currentPercentage ( ) const
inline

Returns the progress percentage of the current object.

Definition at line 146 of file statusprovider.h.

◆ currentStatus()

const std::string & Media::StatusProvider::currentStatus ( ) const
inline

Returns a status information for the current object.

Definition at line 135 of file statusprovider.h.

◆ forwardStatusUpdateCalls()

void Media::StatusProvider::forwardStatusUpdateCalls ( StatusProvider other = nullptr)
inline

Forwards all status updates calls to the specified statusProvider.

Not the callback methods associated to the current instance will be called to inform about status updates. Instead the callback methods associated to the specified instance will be called.

The current instance is still the sender.

The current instance is considered as abortet if the specified provider is abortet even if tryToAbort() has not been called.

The current instance will return the status and percentage of the specified provider if it provides no own status or percentage.

Provide nullptr to revert to the default behaviour.

Remarks
Leads to endless recursion if statusProvider forwards (indirectly or directly) to the current instance.

Definition at line 208 of file statusprovider.h.

◆ hasCriticalNotifications()

bool Media::StatusProvider::hasCriticalNotifications ( ) const
inline

Returns an indication whether there are critical notifications for the current object.

Definition at line 119 of file statusprovider.h.

◆ hasNotifications()

bool Media::StatusProvider::hasNotifications ( ) const
inline

Returns an indication whether there are notifications for the current object.

Definition at line 111 of file statusprovider.h.

◆ invalidateNotifications()

void Media::StatusProvider::invalidateNotifications ( )
inline

Invalidates the object's notifications.

All notifications will be wiped.

Definition at line 246 of file statusprovider.h.

◆ invalidateStatus()

void Media::StatusProvider::invalidateStatus ( )
inline

Invalidates the current status.

The status, the progress percentage and the "aborted"-flag will be wiped. It is recommend to call this method before performing an operation.

This method is meant to be called by the derived class before performing operations to wipe possibly still present previous/obsolet status information.

Definition at line 234 of file statusprovider.h.

◆ isAborted()

bool Media::StatusProvider::isAborted ( ) const
inline

Returns an indication whether the current operation should be aborted.

This can be tested when implementing an operation that should be able to be aborted.

Definition at line 160 of file statusprovider.h.

◆ notifications()

const NotificationList & Media::StatusProvider::notifications ( ) const
inline

Returns notifications for the current object.

Definition at line 103 of file statusprovider.h.

◆ registerCallback()

size_t Media::StatusProvider::registerCallback ( CallbackFunction  callback)

Registers a callback function.

This function will be called when the status/progress changes.

Parameters
callbackSpecifies the function to be called.
Returns
Returns an ID for registration. This ID might be used to unregister the callback function using unregisterCallback().
See also
CallbackFunction
unregisterCallback()

Definition at line 36 of file statusprovider.cpp.

◆ tryToAbort()

void Media::StatusProvider::tryToAbort ( )
inline

Commands the object to abort the current operation.

If the object is currently not operating calling this method has no effect.

The current operation might not be stopped immediately.

Definition at line 220 of file statusprovider.h.

◆ unregisterAllCallbacks()

void Media::StatusProvider::unregisterAllCallbacks ( )
inline

Unregisters all callback functions.

See also
registerCallback()

Definition at line 183 of file statusprovider.h.

◆ unregisterCallback()

void Media::StatusProvider::unregisterCallback ( size_t  id)
inline

Unregisters a previously registered callback function whith the specified id.

Parameters
idSpecifies the ID of the callback to be unregistered.
See also
registerCallback()

Definition at line 171 of file statusprovider.h.

◆ updatePercentage()

void Media::StatusProvider::updatePercentage ( double  percentage)
inline

This method is meant to be called by the derived class to report updated progress percentage only.

The specified percentage should be a value between 0 and 1.

Definition at line 84 of file statusprovider.h.

◆ updateStatus() [1/2]

void Media::StatusProvider::updateStatus ( const std::string &  status)
inline

This method is meant to be called by the derived class to report updated status information.

Definition at line 61 of file statusprovider.h.

◆ updateStatus() [2/2]

void Media::StatusProvider::updateStatus ( const std::string &  status,
double  percentage 
)
inline

This method is meant to be called by the derived class to report updated status information.

The specified progress percentage should be a value between 0 and 1.

Definition at line 72 of file statusprovider.h.

◆ usedProvider()

StatusProvider * Media::StatusProvider::usedProvider ( )
inline

Returns the provider which callback functions will be called when the status or the percentage is updated.

The default is the current instance. This can be changed using the forwardStatusUpdateCalls() method.

Definition at line 95 of file statusprovider.h.

◆ worstNotificationType()

NotificationType Media::StatusProvider::worstNotificationType ( ) const
inline

Returns the worst notification type.

Definition at line 127 of file statusprovider.h.


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