From e57394a772da96fdcbbbdffa3ab9c6950e0bb595 Mon Sep 17 00:00:00 2001 From: kimkulling Date: Thu, 12 Apr 2018 16:09:01 +0200 Subject: [PATCH] move log tools from blender to logger interface. --- code/BlenderModifier.cpp | 28 ----------- code/BlenderModifier.h | 57 ++++++++++----------- code/ColladaLoader.cpp | 5 +- include/assimp/Logger.hpp | 102 +++++++++++++++++++++++++------------- 4 files changed, 98 insertions(+), 94 deletions(-) diff --git a/code/BlenderModifier.cpp b/code/BlenderModifier.cpp index 9b73239ed..1f32ee410 100644 --- a/code/BlenderModifier.cpp +++ b/code/BlenderModifier.cpp @@ -70,34 +70,6 @@ static const fpCreateModifier creators[] = { NULL // sentinel }; -// ------------------------------------------------------------------------------------------------ -// just testing out some new macros to simplify logging -#define ASSIMP_LOG_WARN_F(string,...)\ - DefaultLogger::get()->warn((Formatter::format(string),__VA_ARGS__)) - -#define ASSIMP_LOG_ERROR_F(string,...)\ - DefaultLogger::get()->error((Formatter::format(string),__VA_ARGS__)) - -#define ASSIMP_LOG_DEBUG_F(string,...)\ - DefaultLogger::get()->debug((Formatter::format(string),__VA_ARGS__)) - -#define ASSIMP_LOG_INFO_F(string,...)\ - DefaultLogger::get()->info((Formatter::format(string),__VA_ARGS__)) - - -#define ASSIMP_LOG_WARN(string)\ - DefaultLogger::get()->warn(string) - -#define ASSIMP_LOG_ERROR(string)\ - DefaultLogger::get()->error(string) - -#define ASSIMP_LOG_DEBUG(string)\ - DefaultLogger::get()->debug(string) - -#define ASSIMP_LOG_INFO(string)\ - DefaultLogger::get()->info(string) - - // ------------------------------------------------------------------------------------------------ struct SharedModifierData : ElemBase { diff --git a/code/BlenderModifier.h b/code/BlenderModifier.h index 01d133499..cd34659c9 100644 --- a/code/BlenderModifier.h +++ b/code/BlenderModifier.h @@ -47,34 +47,39 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define INCLUDED_AI_BLEND_MODIFIER_H #include "BlenderIntermediate.h" -#include namespace Assimp { namespace Blender { // ------------------------------------------------------------------------------------------- -/** Dummy base class for all blender modifiers. Modifiers are reused between imports, so - * they should be stateless and not try to cache model data. */ +/** + * Dummy base class for all blender modifiers. Modifiers are reused between imports, so + * they should be stateless and not try to cache model data. + */ // ------------------------------------------------------------------------------------------- -class BlenderModifier -{ +class BlenderModifier { public: + /** + * The class destructor, virtual. + */ virtual ~BlenderModifier() { // empty } -public: - // -------------------- - /** Check if *this* modifier is active, given a ModifierData& block.*/ + /** + * Check if *this* modifier is active, given a ModifierData& block. + */ virtual bool IsActive( const ModifierData& /*modin*/) { return false; } // -------------------- - /** Apply the modifier to a given output node. The original data used + /** + * Apply the modifier to a given output node. The original data used * to construct the node is given as well. Not called unless IsActive() - * was called and gave positive response. */ + * was called and gave positive response. + */ virtual void DoIt(aiNode& /*out*/, ConversionData& /*conv_data*/, const ElemBase& orig_modifier, @@ -86,14 +91,13 @@ public: } }; - // ------------------------------------------------------------------------------------------- -/** Manage all known modifiers and instance and apply them if necessary */ +/** + * Manage all known modifiers and instance and apply them if necessary + */ // ------------------------------------------------------------------------------------------- -class BlenderModifierShowcase -{ +class BlenderModifierShowcase { public: - // -------------------- /** Apply all requested modifiers provided we support them. */ void ApplyModifiers(aiNode& out, @@ -103,25 +107,18 @@ public: ); private: - TempArray< std::vector,BlenderModifier > cached_modifiers; }; - - - - -// MODIFIERS - - +// MODIFIERS ///////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------- -/** Mirror modifier. Status: implemented. */ +/** + * Mirror modifier. Status: implemented. + */ // ------------------------------------------------------------------------------------------- -class BlenderModifier_Mirror : public BlenderModifier -{ +class BlenderModifier_Mirror : public BlenderModifier { public: - // -------------------- virtual bool IsActive( const ModifierData& modin); @@ -137,8 +134,7 @@ public: // ------------------------------------------------------------------------------------------- /** Subdivision modifier. Status: dummy. */ // ------------------------------------------------------------------------------------------- -class BlenderModifier_Subdivision : public BlenderModifier -{ +class BlenderModifier_Subdivision : public BlenderModifier { public: // -------------------- @@ -153,6 +149,7 @@ public: ) ; }; +} +} -}} #endif // !INCLUDED_AI_BLEND_MODIFIER_H diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 01ba1c400..4bb5f4521 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -47,13 +47,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER #include "ColladaLoader.h" +#include "ColladaParser.h" + #include #include #include #include #include +#include -#include "ColladaParser.h" #include #include #include @@ -63,7 +65,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "math.h" #include #include -#include using namespace Assimp; using namespace Assimp::Formatter; diff --git a/include/assimp/Logger.hpp b/include/assimp/Logger.hpp index 56516ca4d..303f841ce 100644 --- a/include/assimp/Logger.hpp +++ b/include/assimp/Logger.hpp @@ -46,7 +46,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef INCLUDED_AI_LOGGER_H #define INCLUDED_AI_LOGGER_H -#include "types.h" +#include +#include namespace Assimp { @@ -59,7 +60,7 @@ class LogStream; /** @brief CPP-API: Abstract interface for logger implementations. * Assimp provides a default implementation and uses it for almost all * logging stuff ('DefaultLogger'). This class defines just basic logging - * behaviour and is not of interest for you. Instead, take a look at #DefaultLogger. */ + * behavior and is not of interest for you. Instead, take a look at #DefaultLogger. */ class ASSIMP_API Logger #ifndef SWIG : public Intern::AllocateFromAssimpHeap @@ -71,8 +72,7 @@ public: /** @enum LogSeverity * @brief Log severity to describe the granularity of logging. */ - enum LogSeverity - { + enum LogSeverity { NORMAL, //!< Normal granularity of logging VERBOSE //!< Debug infos will be logged, too }; @@ -85,8 +85,7 @@ public: * A LogStream doesn't receive any messages of a specific type * if it doesn't specify the corresponding ErrorSeverity flag. */ - enum ErrorSeverity - { + enum ErrorSeverity { Debugging = 1, //!< Debug log message Info = 2, //!< Info log message Warn = 4, //!< Warn log message @@ -102,25 +101,25 @@ public: /** @brief Writes a debug message * @param message Debug message*/ void debug(const char* message); - inline void debug(const std::string &message); + void debug(const std::string &message); // ---------------------------------------------------------------------- /** @brief Writes a info message * @param message Info message*/ void info(const char* message); - inline void info(const std::string &message); + void info(const std::string &message); // ---------------------------------------------------------------------- /** @brief Writes a warning message * @param message Warn message*/ void warn(const char* message); - inline void warn(const std::string &message); + void warn(const std::string &message); // ---------------------------------------------------------------------- /** @brief Writes an error message * @param message Error message*/ void error(const char* message); - inline void error(const std::string &message); + void error(const std::string &message); // ---------------------------------------------------------------------- /** @brief Set a new log severity. @@ -159,15 +158,19 @@ public: unsigned int severity = Debugging | Err | Warn | Info) = 0; protected: - - /** Default constructor */ + /** + * Default constructor + */ Logger(); - /** Construction with a given log severity */ + /** + * Construction with a given log severity + */ explicit Logger(LogSeverity severity); // ---------------------------------------------------------------------- - /** @brief Called as a request to write a specific debug message + /** + * @brief Called as a request to write a specific debug message * @param message Debug message. Never longer than * MAX_LOG_MESSAGE_LENGTH characters (excluding the '0'). * @note The message string is only valid until the scope of @@ -176,7 +179,8 @@ protected: virtual void OnDebug(const char* message)= 0; // ---------------------------------------------------------------------- - /** @brief Called as a request to write a specific info message + /** + * @brief Called as a request to write a specific info message * @param message Info message. Never longer than * MAX_LOG_MESSAGE_LENGTH characters (ecxluding the '0'). * @note The message string is only valid until the scope of @@ -185,7 +189,8 @@ protected: virtual void OnInfo(const char* message) = 0; // ---------------------------------------------------------------------- - /** @brief Called as a request to write a specific warn message + /** + * @brief Called as a request to write a specific warn message * @param message Warn message. Never longer than * MAX_LOG_MESSAGE_LENGTH characters (exluding the '0'). * @note The message string is only valid until the scope of @@ -194,7 +199,8 @@ protected: virtual void OnWarn(const char* essage) = 0; // ---------------------------------------------------------------------- - /** @brief Called as a request to write a specific error message + /** + * @brief Called as a request to write a specific error message * @param message Error message. Never longer than * MAX_LOG_MESSAGE_LENGTH characters (exluding the '0'). * @note The message string is only valid until the scope of @@ -203,66 +209,94 @@ protected: virtual void OnError(const char* message) = 0; protected: - - //! Logger severity LogSeverity m_Severity; }; // ---------------------------------------------------------------------------------- // Default constructor -inline Logger::Logger() { +inline +Logger::Logger() { setLogSeverity(NORMAL); } // ---------------------------------------------------------------------------------- // Virtual destructor -inline Logger::~Logger() -{ +inline +Logger::~Logger() { + // empty } // ---------------------------------------------------------------------------------- // Construction with given logging severity -inline Logger::Logger(LogSeverity severity) { +inline +Logger::Logger(LogSeverity severity) { setLogSeverity(severity); } // ---------------------------------------------------------------------------------- // Log severity setter -inline void Logger::setLogSeverity(LogSeverity log_severity){ +inline +void Logger::setLogSeverity(LogSeverity log_severity){ m_Severity = log_severity; } // ---------------------------------------------------------------------------------- // Log severity getter -inline Logger::LogSeverity Logger::getLogSeverity() const { +inline +Logger::LogSeverity Logger::getLogSeverity() const { return m_Severity; } // ---------------------------------------------------------------------------------- -inline void Logger::debug(const std::string &message) -{ +inline +void Logger::debug(const std::string &message) { return debug(message.c_str()); } // ---------------------------------------------------------------------------------- -inline void Logger::error(const std::string &message) -{ +inline +void Logger::error(const std::string &message) { return error(message.c_str()); } // ---------------------------------------------------------------------------------- -inline void Logger::warn(const std::string &message) -{ +inline +void Logger::warn(const std::string &message) { return warn(message.c_str()); } // ---------------------------------------------------------------------------------- -inline void Logger::info(const std::string &message) -{ +inline +void Logger::info(const std::string &message) { return info(message.c_str()); } -// ---------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------ +#define ASSIMP_LOG_WARN_F(string,...)\ + DefaultLogger::get()->warn((Formatter::format(string),__VA_ARGS__)) + +#define ASSIMP_LOG_ERROR_F(string,...)\ + DefaultLogger::get()->error((Formatter::format(string),__VA_ARGS__)) + +#define ASSIMP_LOG_DEBUG_F(string,...)\ + DefaultLogger::get()->debug((Formatter::format(string),__VA_ARGS__)) + +#define ASSIMP_LOG_INFO_F(string,...)\ + DefaultLogger::get()->info((Formatter::format(string),__VA_ARGS__)) + + +#define ASSIMP_LOG_WARN(string)\ + DefaultLogger::get()->warn(string) + +#define ASSIMP_LOG_ERROR(string)\ + DefaultLogger::get()->error(string) + +#define ASSIMP_LOG_DEBUG(string)\ + DefaultLogger::get()->debug(string) + +#define ASSIMP_LOG_INFO(string)\ + DefaultLogger::get()->info(string) + } // Namespace Assimp