|
|
@ -2,6 +2,7 @@
|
|
|
|
#define COMPONENTS_LOADINGLISTENER_H
|
|
|
|
#define COMPONENTS_LOADINGLISTENER_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
|
|
namespace Loading
|
|
|
|
namespace Loading
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -33,12 +34,26 @@ namespace Loading
|
|
|
|
virtual ~Listener() = default;
|
|
|
|
virtual ~Listener() = default;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct LoadingOff
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
void operator()(Listener* listener) const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (listener != nullptr)
|
|
|
|
|
|
|
|
listener->loadingOff();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// @brief Used for stopping a loading sequence when the object goes out of scope
|
|
|
|
/// @brief Used for stopping a loading sequence when the object goes out of scope
|
|
|
|
struct ScopedLoad
|
|
|
|
struct ScopedLoad
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ScopedLoad(Listener* l) : mListener(l) { mListener->loadingOn(); }
|
|
|
|
std::unique_ptr<Listener, LoadingOff> mListener;
|
|
|
|
~ScopedLoad() { mListener->loadingOff(); }
|
|
|
|
|
|
|
|
Listener* mListener;
|
|
|
|
explicit ScopedLoad(Listener* listener)
|
|
|
|
|
|
|
|
: mListener(listener)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (mListener != nullptr)
|
|
|
|
|
|
|
|
mListener->loadingOn();
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|