/* -------------------------------------------------------------------------------- * * Open Asset Import Library (ASSIMP) (http://assimp.sourceforge.net) * Assimp2Java bridge * * Copyright (c) 2006-2009, ASSIMP Development Team * All rights reserved. See the LICENSE file for more information. * * -------------------------------------------------------------------------------- */ /** @file jbridge_Logger.h * Declaration of a log dispatching service to send all log messages to Java */ #ifndef INCLUDED_JBRIDGE_LOGGER_H #define INCLUDED_JBRIDGE_LOGGER_H #include namespace Assimp { namespace jbridge { // --------------------------------------------------------------------------- class IOStream; struct LogStreamInfo; // --------------------------------------------------------------------------- /** @class JNILogDispatcher * @brief Logging system implementation that is used to send all * log messages generated by native code to the Java logging system. */ class JNILogDispatcher : public Logger { friend class JNIEnvironment; public: //! Default constructor JNILogDispatcher() : m_iRefCnt(1) {} /** @brief Logs a debug message */ void OnDebug(const char* msg); /** @brief Logs an info message */ void OnInfo(const char* msg); /** @brief Logs a warning message */ void OnWarn(const char* msg); /** @brief Logs an error message */ void OnError(const char* msg); /** @brief Log severity setter */ void setLogSeverity(LogSeverity log_severity) {} /** @brief Detach a still attached stream from logger */ bool attachStream(LogStream *pStream, unsigned int severity) { return false; } /** @brief Detach a still attached stream from logger */ bool detatchStream(LogStream *pStream, unsigned int severity) { return false; } //! COM-style reference counting mechanism unsigned int AddRef() { return ++m_iRefCnt; } //! COM-style reference counting mechanism unsigned int Release() { const unsigned int n = --m_iRefCnt; if (n == 0) { delete this; // don't forget to reset the logger to the default implementation DefaultLogger::set(NULL); } return n; } private: //! Called by JNIEnvironment bool OnAttachToCurrentThread(JNIThreadData* pcData); bool OnDetachFromCurrentThread(JNIThreadData* pcData); private: //! Handle to assimp.DefaultLogger class jclass m_pcClass; //! Handle to the static assimp.DefaultLogger._NativeCallWriteError() method jmethodID m_pcMethodError; //! Handle to the static assimp.DefaultLogger._NativeCallWriteInfo() method jmethodID m_pcMethodInfo; //! Handle to the static assimp.DefaultLogger._NativeCallWriteDebug() method jmethodID m_pcMethodDebug; //! Handle to the static assimp.DefaultLogger._NativeCallWriteWarn() method jmethodID m_pcMethodWarn; //! Reference counter of the logger unsigned int m_iRefCnt; }; }} #endif // !! INCLUDED_JBRIDGE_LOGGER_H