ErrorReport.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. // Description : Class that collects error reports to present them later.
  9. #ifndef CRYINCLUDE_EDITOR_ERRORREPORT_H
  10. #define CRYINCLUDE_EDITOR_ERRORREPORT_H
  11. #pragma once
  12. // forward declarations.
  13. class CParticleItem;
  14. #include "Objects/BaseObject.h"
  15. #include "Include/EditorCoreAPI.h"
  16. #include "Include/IErrorReport.h"
  17. #include "ErrorRecorder.h"
  18. /*! Single error entry in error report.
  19. */
  20. class CErrorRecord
  21. {
  22. public:
  23. enum ESeverity
  24. {
  25. ESEVERITY_ERROR,
  26. ESEVERITY_WARNING,
  27. ESEVERITY_COMMENT
  28. };
  29. enum EFlags
  30. {
  31. FLAG_NOFILE = 0x0001, // Indicate that required file was not found.
  32. FLAG_SCRIPT = 0x0002, // Error with scripts.
  33. FLAG_TEXTURE = 0x0004, // Error with scripts.
  34. FLAG_OBJECTID = 0x0008, // Error with object Ids, Unresolved/Duplicate etc...
  35. FLAG_AI = 0x0010, // Error with AI.
  36. };
  37. //! Severety of this error.
  38. ESeverity severity;
  39. //! Module of error.
  40. EValidatorModule module;
  41. //! Error Text.
  42. QString error;
  43. //! File which is missing or causing problem.
  44. QString file;
  45. //! More detailed description for this error.
  46. QString description;
  47. // Asset dependencies
  48. QString assetScope;
  49. int count;
  50. //! Object that caused this error.
  51. _smart_ptr<CBaseObject> pObject;
  52. int flags;
  53. CErrorRecord(CBaseObject* object, ESeverity _severity, const QString& _error, int _flags = 0, int _count = 0,
  54. EValidatorModule _module = VALIDATOR_MODULE_EDITOR)
  55. : severity(_severity)
  56. , module(_module)
  57. , pObject(object)
  58. , flags(_flags)
  59. , count(_count)
  60. , error(_error)
  61. {
  62. }
  63. CErrorRecord()
  64. {
  65. severity = ESEVERITY_WARNING;
  66. module = VALIDATOR_MODULE_EDITOR;
  67. pObject = 0;
  68. flags = 0;
  69. count = 0;
  70. }
  71. QString GetErrorText() const;
  72. };
  73. /*! Error report manages collection of errors occured duruing map analyzes or level load.
  74. */
  75. class CErrorReport
  76. : public IErrorReport
  77. {
  78. public:
  79. CErrorReport();
  80. //! If enabled errors are reported immidiatly and not stored.
  81. void SetImmediateMode(bool bEnable);
  82. bool IsImmediateMode() const { return m_bImmediateMode; };
  83. void SetShowErrors(bool bShowErrors = true) { m_bShowErrors = bShowErrors; };
  84. //! Adds new error to report.
  85. void ReportError(CErrorRecord& err);
  86. //! Check if error report have any errors.
  87. bool IsEmpty() const;
  88. //! Get number of contained error records.
  89. int GetErrorCount() const { return static_cast<int>(m_errors.size()); };
  90. //! Get access to indexed error record.
  91. CErrorRecord& GetError(int i);
  92. //! Clear all error records.
  93. void Clear();
  94. //! Display dialog with all errors.
  95. void Display();
  96. //! Assign current Object to which new reported warnings are assigned.
  97. void SetCurrentValidatorObject(CBaseObject* pObject);
  98. //! Assign current filename.
  99. void SetCurrentFile(const QString& file);
  100. private:
  101. //! Array of all error records added to report.
  102. std::vector<CErrorRecord> m_errors;
  103. bool m_bImmediateMode;
  104. bool m_bShowErrors;
  105. _smart_ptr<CBaseObject> m_pObject;
  106. CParticleItem* m_pParticle;
  107. QString m_currentFilename;
  108. };
  109. #endif // CRYINCLUDE_EDITOR_ERRORREPORT_H