diff --git a/Core/Code/Algorithms/mitkUIDGenerator.h b/Core/Code/Algorithms/mitkUIDGenerator.h index 417de7c4f4..a5bd3f5c8a 100644 --- a/Core/Code/Algorithms/mitkUIDGenerator.h +++ b/Core/Code/Algorithms/mitkUIDGenerator.h @@ -1,49 +1,58 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITK_UID_GENERATOR_INDCLUDED_FASAWE #define MITK_UID_GENERATOR_INDCLUDED_FASAWE #include #include +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4251) +#endif + namespace mitk { /*! \brief Generated unique IDs Creates (somehow most of the time) unique IDs from a given prefix, the current date/time and a random part. The prefix is given to the constructor, together with the desired length of the random part (minimum 5 digits). You will get another quite unique ID each time you call GetUID. */ class MITK_CORE_EXPORT UIDGenerator { public: UIDGenerator(const char* prefix = "UID_", unsigned int lengthOfRandomPart = 8); std::string GetUID(); private: std::string m_Prefix; unsigned int m_LengthOfRandomPart; }; } +#ifdef _MSC_VER +# pragma warning(pop) +#endif + #endif diff --git a/Core/Code/Interactions/mitkEventDescription.h b/Core/Code/Interactions/mitkEventDescription.h index d5c6c685e3..2bdc9b8009 100644 --- a/Core/Code/Interactions/mitkEventDescription.h +++ b/Core/Code/Interactions/mitkEventDescription.h @@ -1,52 +1,60 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef EVENTDESCRIPTION_H_HEADER_INCLUDED_C188FC4D #define EVENTDESCRIPTION_H_HEADER_INCLUDED_C188FC4D #include #include "mitkEvent.h" #include +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4251) +#endif + namespace mitk { //##Documentation //## @brief adds additional Information (Name and EventID) to an Event //## //## A name and an ID is added to the information of an event, so the event can //## be processed futher on. //## @ingroup Interaction class MITK_CORE_EXPORT EventDescription : public Event { public: EventDescription(int type, int button, int buttonState,int key, std::string name, int id); std::string GetName() const; int GetId() const; private: std::string m_Name; int m_Id; }; } // namespace mitk +#ifdef _MSC_VER +# pragma warning(pop) +#endif #endif /* EVENTDESCRIPTION_H_HEADER_INCLUDED_C188FC4D */ diff --git a/Utilities/mbilog/mbilog.h b/Utilities/mbilog/mbilog.h index 3c7206dcc6..abd102d095 100644 --- a/Utilities/mbilog/mbilog.h +++ b/Utilities/mbilog/mbilog.h @@ -1,225 +1,232 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _MBILOG_H #define _MBILOG_H #include #include "mbilogExports.h" #include "mbilogBackendBase.h" #include "mbilogBackendCout.h" #include "mbilogLogMessage.h" #include "mbilogLoggingTypes.h" #include "mbilogConfig.h" - +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4251) +#endif namespace mbilog { /** \brief Registeres a backend to the mbi logging mechanism. If a backend is registered here, all mbilog messages * are relayed to this backend through the method ProcessMessage. If no backend is registered the default * backend is used. */ void MBILOG_DLL_API RegisterBackend(BackendBase* backend); /** \brief Unregisters a backend. */ void MBILOG_DLL_API UnregisterBackend(BackendBase* backend); /** \brief Distributes the given message to all registered backends. Should only be called by objects * of the class pseudo stream. */ void MBILOG_DLL_API DistributeToBackends(LogMessage &l); /** * \brief An object of this class simulates a std::cout stream. This means messages can be added by * using the bit shift operator (<<). Should only be used by the macros defined in the file mbilog.h * \ingroup mbilog */ class MBILOG_DLL_API PseudoStream { protected: bool disabled; LogMessage msg; std::stringstream ss; public: inline PseudoStream( int level, const char* filePath, int lineNumber, const char* functionName) : disabled(false) , msg(LogMessage(level,filePath,lineNumber,functionName)) , ss(std::stringstream::out) { } /** \brief The message which is stored in the member ss is written to the backend. */ inline ~PseudoStream() { if(!disabled) { msg.message = ss.str(); msg.moduleName = MBILOG_MODULENAME; DistributeToBackends(msg); } } /** \brief Definition of the bit shift operator for this class.*/ template inline PseudoStream& operator<<(const T& data) { if(!disabled) { std::locale C("C"); std::locale originalLocale = ss.getloc(); ss.imbue(C); ss << data; ss.imbue( originalLocale ); } return *this; } /** \brief Definition of the bit shift operator for this class (for non const data).*/ template inline PseudoStream& operator<<(T& data) { if(!disabled) { std::locale C("C"); std::locale originalLocale = ss.getloc(); ss.imbue(C); ss << data; ss.imbue( originalLocale ); } return *this; } /** \brief Definition of the bit shift operator for this class (for functions).*/ inline PseudoStream& operator<<(std::ostream& (*func)(std::ostream&)) { if(!disabled) { std::locale C("C"); std::locale originalLocale = ss.getloc(); ss.imbue(C); ss << func; ss.imbue( originalLocale ); } return *this; } /** \brief Sets the category of this PseudoStream object. If there already is a category it is appended, seperated by a dot.*/ inline PseudoStream& operator()(const char *category) { if(!disabled) { if(msg.category.length()) msg.category+="."; msg.category+=category; } return *this; } /** \brief Enables/disables the PseudoStream. If set to false parsing and output is suppressed. */ inline PseudoStream& operator()(bool enabled) { disabled|=!enabled; return *this; } }; /** * \brief An object of this class simulates a std::cout stream but does nothing. This class is for dummy objects, bit shift * operators are availiable but doing nothing. Should only be used by the macros defined in the file mbilog.h * \ingroup mbilog */ class MBILOG_DLL_API NullStream { public: template inline NullStream& operator<<(const T& /*data*/) { return *this; } template inline NullStream& operator<<(T& /*data*/) { return *this; } inline NullStream& operator<<(std::ostream& (*)(std::ostream&)) { return *this; } inline NullStream& operator()(const char *) { return *this; } inline NullStream& operator()(bool) { return *this; } }; // /** \brief templated backend: one can define a class and a method to create a new backend. */ // template // struct DelegateBackend : public BackendBase // { // // typedef void(T::*Callback)(const mbilog::LogMessage&); // // DelegateBackend(T* obj, Callback callback) : m_Obj(obj), m_Callback(callback) // { // } // // void ProcessMessage(const mbilog::LogMessage& msg) // { // m_Obj->*m_Callback(msg); // } // // private: // // T* m_Obj; // Callback m_Callback; // }; } +#ifdef _MSC_VER +# pragma warning(pop) +#endif + /** \brief Macros for different message levels. Creates an instance of class PseudoStream with the corresponding message level. * Other parameters are the name of the source file, line of the source code and function name which are generated * by the compiler. */ #define MBI_INFO mbilog::PseudoStream(mbilog::Info,__FILE__,__LINE__,__FUNCTION__) #define MBI_WARN mbilog::PseudoStream(mbilog::Warn,__FILE__,__LINE__,__FUNCTION__) #define MBI_ERROR mbilog::PseudoStream(mbilog::Error,__FILE__,__LINE__,__FUNCTION__) #define MBI_FATAL mbilog::PseudoStream(mbilog::Fatal,__FILE__,__LINE__,__FUNCTION__) /** \brief Macro for the debug messages. The messages are disabled if the cmake variable MBILOG_ENABLE_DEBUG is false. */ #ifdef MBILOG_ENABLE_DEBUG #define MBI_DEBUG mbilog::PseudoStream(mbilog::Debug,__FILE__,__LINE__,__FUNCTION__) #else #define MBI_DEBUG true ? mbilog::NullStream() : mbilog::NullStream() //this is magic by markus #endif #endif diff --git a/Utilities/mbilog/mbilogLogMessage.h b/Utilities/mbilog/mbilogLogMessage.h index e96b19804f..9305ca45ea 100644 --- a/Utilities/mbilog/mbilogLogMessage.h +++ b/Utilities/mbilog/mbilogLogMessage.h @@ -1,81 +1,89 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _mbilogLogMessage_H #define _mbilogLogMessage_H #include #include "mbilogExports.h" +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4251) +#endif + namespace mbilog{ /** Documentation * \brief An object of this class represents a single logging message (logging event) of the * mbi logging mechanism. Logging message should only be generated by the macros in the class mbilog.h * * \ingroup mbilog */ //todo convert to Struct class MBILOG_DLL_API LogMessage { public: //TODO: all member names m_[...] /** \brief Logging level which is defined in the enum mbilogLoggingTypes.h TODO: convert to enum.*/ const int level; // the data of the following section is generated by the c-compiler /** \brief File name of the source file where the logging message was emitted which is generated by the macros in file mbilog.h*/ const char* filePath; /** \brief Line of the source source file where the logging message was emitted which is generated by the macros in file mbilog.h*/ const int lineNumber; /** \brief Name of the method where the logging message was emitted which is generated by the macros in file mbilog.h*/ const char* functionName; // the data of the following section is generated by the mitk module system /** \brief Name of the module where the logging message was emitted which is generated by the macros in file mbilog.h. Is empty if there module defined.*/ const char* moduleName; // user parameters /** \brief Category of the logging event, which was defined by the user.*/ std::string category; /** \brief The actual logging message.*/ std::string message; LogMessage( const int _level, const char* _filePath, const int _lineNumber, const char* _functionName ) : level(_level) , filePath(_filePath) , lineNumber(_lineNumber) , functionName(_functionName) { } }; } +#ifdef _MSC_VER +# pragma warning(pop) +#endif #endif