RCCommon.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. // if this becomes a hotspot in profile, we could use CRCs or other boost to comparison here. These classes are constructed rarely
  56. // compared to how commonly they are compared with each other.
  57. return !(operator==(other));
  58. }
  59. bool QueueElementID::operator<(const QueueElementID& other) const
  60. {
  61. int compare = m_sourceAssetReference.AbsolutePath().Compare(other.m_sourceAssetReference.AbsolutePath());
  62. if (compare != 0)
  63. {
  64. return (compare < 0);
  65. }
  66. compare = QString::compare(m_platform, other.m_platform, Qt::CaseInsensitive);
  67. if (compare != 0)
  68. {
  69. return (compare < 0);
  70. }
  71. compare = QString::compare(m_jobDescriptor, other.m_jobDescriptor, Qt::CaseInsensitive);
  72. if (compare != 0)
  73. {
  74. return (compare < 0);
  75. }
  76. // all three are equal, other is not less than this.
  77. return false;
  78. }
  79. uint qHash(const AssetProcessor::QueueElementID& key, uint seed)
  80. {
  81. return qHash(QString(key.GetSourceAssetReference().AbsolutePath().c_str()).toLower() + key.GetPlatform().toLower() + key.GetJobDescriptor().toLower(), seed);
  82. }
  83. } // end namespace AssetProcessor