Commit 8e0112ab authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Adding progress class

parent 5c81ecf9
......@@ -68,6 +68,9 @@ include_directories( "include" )
# files
set( ITABaseHeader
"include/ITABase/ITAProgress.h"
"include/ITAAudioSample.h"
"include/ITABaseDefinitions.h"
"include/ITABlockMath.h"
......@@ -136,6 +139,9 @@ set( ITABaseSources
"src/ITAStopWatch.cpp"
"src/ITATypes.cpp"
"src/ITAWinPCClock.cpp"
"src/ITABase/ITAProgress.cpp"
)
......
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2020
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_BASE_PROGRESS
#define IW_ITA_BASE_PROGRESS
#include <ITABaseDefinitions.h>
#include <string>
namespace ITABase
{
//! A progress handler can be added to functions that are potentially time consuming to keep track of progress and to abort calculation
/**
* Further improvements may introduce a granularity to keep down push message. Partly abstract only, still considered an interface as this is the main purpose.
*/
class ITA_BASE_API IProgressHandler
{
public:
IProgressHandler( std::string sName = "unnamed" );
~IProgressHandler();
void SetName( const std::string& sName );
std::string GetName() const;
void SetSection( const std::string& sSection );
std::string GetSection() const;
void SetItem( const std::string& sItem );
std::string GetItem() const;
virtual inline void PushProgressUpdate( std::string sSection, std::string sItem, float fProgressPercentage ) const
{
m_sSection = sSection;
PushProgressUpdate( sItem, fProgressPercentage );
};
virtual inline void PushProgressUpdate( std::string sItem, float fProgressPercentage ) const
{
m_sItem = sItem;
//PushProgressUpdate( fProgressPercentage );
};
//!< Please implement push message, will be called by function
/**
*/
virtual void PushProgressUpdate( float fProgressPercentage ) const = 0;
private:
mutable std::string m_sItem; //!< Currently processed looping function or similar
mutable std::string m_sSection; //!< Execution section, i.e. caller function
std::string m_sName; //!< Progress handler name, i.e. caller function or class or app
};
}
#endif // IW_ITA_BASE_PROGRESS
#include <ITABase/ITAProgress.h>
ITABase::IProgressHandler::IProgressHandler( std::string sName /*= "unnamed" */ )
: m_sName( sName )
{
}
ITABase::IProgressHandler::~IProgressHandler()
{
}
void ITABase::IProgressHandler::SetName( const std::string& sName )
{
m_sName = sName;
}
std::string ITABase::IProgressHandler::GetName() const
{
return m_sName;
}
void ITABase::IProgressHandler::SetSection( const std::string& sName )
{
m_sName = sName;
}
std::string ITABase::IProgressHandler::GetSection() const
{
return m_sName;
}
void ITABase::IProgressHandler::SetItem( const std::string& sName )
{
m_sName = sName;
}
std::string ITABase::IProgressHandler::GetItem() const
{
return m_sName;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment