LogFunctions.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (assimp)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2020, assimp team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the assimp team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the assimp team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. /** @file LogFunctions.h */
  35. #ifndef AI_MDL_HALFLIFE_LOGFUNCTIONS_INCLUDED
  36. #define AI_MDL_HALFLIFE_LOGFUNCTIONS_INCLUDED
  37. #include <assimp/Logger.hpp>
  38. #include <string>
  39. namespace Assimp {
  40. namespace MDL {
  41. namespace HalfLife {
  42. /**
  43. * \brief A function to log precise messages regarding limits exceeded.
  44. *
  45. * \param[in] subject Subject.
  46. * \param[in] current_amount Current amount.
  47. * \param[in] direct_object Direct object.
  48. * LIMIT Limit constant.
  49. *
  50. * Example: Model has 100 textures, which exceeds the limit (50)
  51. *
  52. * where \p subject is 'Model'
  53. * \p current_amount is '100'
  54. * \p direct_object is 'textures'
  55. * LIMIT is '50'
  56. */
  57. template <int LIMIT>
  58. static inline void log_warning_limit_exceeded(
  59. const std::string &subject, int current_amount,
  60. const std::string &direct_object) {
  61. ASSIMP_LOG_WARN(MDL_HALFLIFE_LOG_HEADER
  62. + subject
  63. + " has "
  64. + std::to_string(current_amount) + " "
  65. + direct_object
  66. + ", which exceeds the limit ("
  67. + std::to_string(LIMIT)
  68. + ")");
  69. }
  70. /** \brief Same as above, but uses 'Model' as the subject. */
  71. template <int LIMIT>
  72. static inline void log_warning_limit_exceeded(int current_amount,
  73. const std::string &direct_object) {
  74. log_warning_limit_exceeded<LIMIT>("Model", current_amount, direct_object);
  75. }
  76. } // namespace HalfLife
  77. } // namespace MDL
  78. } // namespace Assimp
  79. #endif // AI_MDL_HALFLIFE_LOGFUNCTIONS_INCLUDED