45 static BSHP<ProgressListener> fg_listener;
173 std::ostringstream ss;
174 ss <<
"OnProgressStatus " << a_stackIndex <<
": " << a_fractionComplete <<
'\n';
175 m_messages += ss.str();
185 std::ostringstream ss;
186 ss <<
"OnBeginOperationString " << a_operation <<
'\n';
187 m_messages += ss.str();
198 std::ostringstream ss;
199 ss <<
"OnEndOperation " << a_stackIndex <<
'\n';
200 m_messages += ss.str();
210 std::ostringstream ss;
211 ss <<
"OnUpdateMessage " << a_stackIndex <<
": " << a_message <<
'\n';
212 m_messages += ss.str();
252 std::string expected =
253 "OnBeginOperationString First progress\n" 254 "OnProgressStatus 1: 0.5\n" 255 "OnBeginOperationString Second progress\n" 256 "OnProgressStatus 2: 0.25\n" 257 "OnUpdateMessage 2: Second progress message 2\n" 258 "OnProgressStatus 2: 0.75\n" 260 "OnBeginOperationString Third progress\n" 261 "OnProgressStatus 2: 0.25\n" 262 "OnProgressStatus 2: 0.5\n" 263 "OnProgressStatus 2: 0.75\n" 264 "OnProgressStatus 2: 1\n" 266 "OnProgressStatus 1: 1\n" 267 "OnEndOperation 1\n";
268 TS_ASSERT_EQUALS(expected, listener->m_messages);
mock class to show how the Progress and ProgressListener classes work
Stack based class to give notification of progress for a long task. Progress can be stacked by making...
void CurrentItem(long long a_item)
Give notification for the number of items completed. Used with SetItemCount.
BSHP< ProgressListener > & iListener()
Get the current ProgressListener.
void UpdateMessage(const std::string &a_message)
Update the current progress message.
Progress(const std::string &a_message)
Constructor.
Listen to progress reported from Progress class.
void testProgress()
Test Progress class.
int OnBeginOperationString(const std::string &a_operation) override
Listen to when operation begins.
void OnUpdateMessage(int a_stackIndex, const std::string &a_message) override
Listen to when operation ends.
void OnEndOperation(int a_stackIndex) override
Listen to when operation ends.
void SetItemCount(long long a_count)
Set the number of items to be processed. Used with CurrentItem.
void ProgressStatus(double a_percentComplete)
Give notification for the progress percent complete.
#define XM_ASSERT(x)
Does a regular ASSERT if xmAsserting, otherwise does nothing.
std::string m_messages
stored up messages
int m_stackIndex
instances index on stack of instances
Functions and macros for assertion and checking for errors.
long long m_itemCount
number of items to process
void OnProgressStatus(int a_stackIndex, double a_fractionComplete) override
Listen to progress status.
static void SetListener(BSHP< ProgressListener > a_listener)
Set the current progress listener.
virtual ~ProgressListener()
Destructor.
static BSHP< ProgressListener > GetListener()
Get the current progress listener.