Convert MCore::Command uint32 -> size_t

Signed-off-by: Chris Burel <burelc@amazon.com>
This commit is contained in:
Chris Burel
2021-05-24 12:03:49 -07:00
parent d712c54e20
commit 889cdd8c0a
3 changed files with 16 additions and 34 deletions
@@ -163,9 +163,9 @@ namespace EMStudio
{}
~UndoMenuCallback() = default;
void OnRemoveCommand([[maybe_unused]] uint32 historyIndex) override { m_mainWindow->UpdateUndoRedo(); }
void OnSetCurrentCommand([[maybe_unused]] uint32 index) override { m_mainWindow->UpdateUndoRedo(); }
void OnAddCommandToHistory([[maybe_unused]] uint32 historyIndex, [[maybe_unused]] MCore::CommandGroup* group, [[maybe_unused]] MCore::Command* command, [[maybe_unused]] const MCore::CommandLine& commandLine) override { m_mainWindow->UpdateUndoRedo(); }
void OnRemoveCommand([[maybe_unused]] size_t historyIndex) override { m_mainWindow->UpdateUndoRedo(); }
void OnSetCurrentCommand([[maybe_unused]] size_t index) override { m_mainWindow->UpdateUndoRedo(); }
void OnAddCommandToHistory([[maybe_unused]] size_t historyIndex, [[maybe_unused]] MCore::CommandGroup* group, [[maybe_unused]] MCore::Command* command, [[maybe_unused]] const MCore::CommandLine& commandLine) override { m_mainWindow->UpdateUndoRedo(); }
void OnPreExecuteCommand([[maybe_unused]] MCore::CommandGroup* group, [[maybe_unused]] MCore::Command* command, [[maybe_unused]] const MCore::CommandLine& commandLine) override {}
void OnPostExecuteCommand([[maybe_unused]] MCore::CommandGroup* group, [[maybe_unused]] MCore::Command* command, [[maybe_unused]] const MCore::CommandLine& commandLine, [[maybe_unused]] bool wasSuccess, [[maybe_unused]] const AZStd::string& outResult) override {}
+9 -27
View File
@@ -8,6 +8,7 @@
// include the required headers
#include "Command.h"
#include <AzCore/std/numeric.h>
#include <AzCore/Serialization/SerializeContext.h>
@@ -81,9 +82,9 @@ namespace MCore
}
uint32 Command::GetNumCallbacks() const
size_t Command::GetNumCallbacks() const
{
return static_cast<uint32>(mCallbacks.size());
return mCallbacks.size();
}
@@ -123,37 +124,18 @@ namespace MCore
// calculate the number of registered pre-execute callbacks
uint32 Command::CalcNumPreCommandCallbacks() const
size_t Command::CalcNumPreCommandCallbacks() const
{
uint32 result = 0;
const size_t numCallbacks = mCallbacks.size();
for (size_t i = 0; i < numCallbacks; ++i)
return AZStd::accumulate(begin(mCallbacks), end(mCallbacks), size_t{0}, [](size_t total, const Callback* callback)
{
if (mCallbacks[i]->GetExecutePreCommand())
{
result++;
}
}
return result;
return callback->GetExecutePreCommand() ? total + 1 : total;
});
}
// calculate the number of registered post-execute callbacks
uint32 Command::CalcNumPostCommandCallbacks() const
size_t Command::CalcNumPostCommandCallbacks() const
{
uint32 result = 0;
const size_t numCallbacks = mCallbacks.size();
for (size_t i = 0; i < numCallbacks; ++i)
{
if (mCallbacks[i]->GetExecutePreCommand() == false)
{
result++;
}
}
return result;
return mCallbacks.size() - CalcNumPreCommandCallbacks();
}
} // namespace MCore
+4 -4
View File
@@ -279,26 +279,26 @@ namespace MCore
* Get the number of registered/added command callbacks.
* @result The number of command callbacks that have been added.
*/
uint32 GetNumCallbacks() const;
size_t GetNumCallbacks() const;
/**
* Calculate the number of registered pre-execute callbacks.
* @result The number of registered pre-execute callbacks.
*/
uint32 CalcNumPreCommandCallbacks() const;
size_t CalcNumPreCommandCallbacks() const;
/**
* Calculate the number of registered post-execute callbacks.
* @result The number of registered post-execute callbacks.
*/
uint32 CalcNumPostCommandCallbacks() const;
size_t CalcNumPostCommandCallbacks() const;
/**
* Get a given command callback.
* @param index The callback number, which must be in range of [0..GetNumCallbacks()-1].
* @result A pointer to the command callback object.
*/
MCORE_INLINE Command::Callback* GetCallback(uint32 index) { return mCallbacks[index]; }
MCORE_INLINE Command::Callback* GetCallback(size_t index) { return mCallbacks[index]; }
/**
* Add (register) a command callback.