RCCommon.cpp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include "RCCommon.h"
  9. #include <QHash>
  10. #include <AzCore/StringFunc/StringFunc.h>
  11. namespace AssetProcessor
  12. {
  13. QueueElementID::QueueElementID(SourceAssetReference sourceAssetReference, QString platform, QString jobDescriptor)
  14. : m_sourceAssetReference(AZStd::move(sourceAssetReference))
  15. , m_platform(platform)
  16. , m_jobDescriptor(jobDescriptor)
  17. {
  18. }
  19. SourceAssetReference QueueElementID::GetSourceAssetReference() const
  20. {
  21. return m_sourceAssetReference;
  22. }
  23. QString QueueElementID::GetPlatform() const
  24. {
  25. return m_platform;
  26. }
  27. QString QueueElementID::GetJobDescriptor() const
  28. {
  29. return m_jobDescriptor;
  30. }
  31. void QueueElementID::SetSourceAssetReference(SourceAssetReference sourceAssetReference)
  32. {
  33. m_sourceAssetReference = AZStd::move(sourceAssetReference);
  34. }
  35. void QueueElementID::SetPlatform(QString platform)
  36. {
  37. m_platform = platform;
  38. }
  39. void QueueElementID::SetJobDescriptor(QString jobDescriptor)
  40. {
  41. m_jobDescriptor = jobDescriptor;
  42. }
  43. bool QueueElementID::operator==(const QueueElementID& other) const
  44. {
  45. // if this becomes a hotspot in profile, we could use CRCs or other boost to comparison here. These classes are constructed rarely
  46. // compared to how commonly they are compared with each other.
  47. return (
  48. m_sourceAssetReference == other.m_sourceAssetReference &&
  49. (QString::compare(m_platform, other.m_platform, Qt::CaseInsensitive) == 0) &&
  50. (QString::compare(m_jobDescriptor, other.m_jobDescriptor, Qt::CaseInsensitive) == 0)
  51. );
  52. }
  53. bool QueueElementID::operator<(const QueueElementID& other) const
  54. {
  55. int compare = m_sourceAssetReference.AbsolutePath().Compare(other.m_sourceAssetReference.AbsolutePath());
  56. if (compare != 0)
  57. {
  58. return (compare < 0);
  59. }
  60. compare = QString::compare(m_platform, other.m_platform, Qt::CaseInsensitive);
  61. if (compare != 0)
  62. {
  63. return (compare < 0);
  64. }
  65. compare = QString::compare(m_jobDescriptor, other.m_jobDescriptor, Qt::CaseInsensitive);
  66. if (compare != 0)
  67. {
  68. return (compare < 0);
  69. }
  70. // all three are equal, other is not less than this.
  71. return false;
  72. }
  73. uint qHash(const AssetProcessor::QueueElementID& key, uint seed)
  74. {
  75. return qHash(QString(key.GetSourceAssetReference().AbsolutePath().c_str()).toLower() + key.GetPlatform().toLower() + key.GetJobDescriptor().toLower(), seed);
  76. }
  77. } // end namespace AssetProcessor