tomwalters@0: // Copyright 2006-2010, Thomas Walters, Willem van Engen tomwalters@0: // tomwalters@0: // AIM-C: A C++ implementation of the Auditory Image Model tomwalters@0: // http://www.acousticscale.org/AIMC tomwalters@0: // tomwalters@45: // Licensed under the Apache License, Version 2.0 (the "License"); tomwalters@45: // you may not use this file except in compliance with the License. tomwalters@45: // You may obtain a copy of the License at tomwalters@0: // tomwalters@45: // http://www.apache.org/licenses/LICENSE-2.0 tomwalters@0: // tomwalters@45: // Unless required by applicable law or agreed to in writing, software tomwalters@45: // distributed under the License is distributed on an "AS IS" BASIS, tomwalters@45: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. tomwalters@45: // See the License for the specific language governing permissions and tomwalters@45: // limitations under the License. tomwalters@0: tomwalters@0: /*! \file tomwalters@0: * \brief Common includes for all AIM-C tomwalters@0: */ tomwalters@0: tomwalters@0: /*! \author: Thomas Walters tomwalters@0: * \author: Willem van Engen tomwalters@0: * \date 2010/01/30 tomwalters@23: * \version \$Id$ tomwalters@0: */ tomwalters@0: tomwalters@11: #ifndef AIMC_SUPPORT_COMMON_H_ tomwalters@11: #define AIMC_SUPPORT_COMMON_H_ tomwalters@0: tomwalters@0: #include tomwalters@0: #include tomwalters@0: #include tomwalters@0: tomwalters@252: // Defines for windows tomwalters@252: #ifdef _WINDOWS tomwalters@252: #define M_PI 3.14159265359 tomwalters@252: #define isnan _isnan tomwalters@252: #define isinf(x) (!_finite(x)) tomwalters@252: #define snprintf _snprintf tomwalters@252: #define PATH_MAX _MAX_PATH tomwalters@252: #endif tomwalters@252: tom@230: #define AIM_NAME "AIM-C" tom@230: #define AIM_VERSION_STRING "version_number" tom@230: tomwalters@0: // A macro to disallow the copy constructor and operator= functions tomwalters@0: // This should be used in the private: declarations for a class tomwalters@0: #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ tomwalters@0: TypeName(const TypeName&); \ tomwalters@0: void operator=(const TypeName&) tomwalters@0: tomwalters@0: #if !defined(_T) tomwalters@0: # ifdef _UNICODE tomwalters@0: # define _T(x) L ## x tomwalters@0: # else tomwalters@0: # define _T(x) x tomwalters@0: # endif tomwalters@0: #endif tomwalters@0: tom@118: #if !defined(_S) tom@118: # ifdef _UNICODE tom@118: # define _S(x) L ## x tom@118: # else tom@118: # define _S(x) x tom@118: # endif tom@118: #endif tom@118: tomwalters@0: /*! \brief C++ delete if != NULL tomwalters@0: * tomwalters@0: * This was used so often, that is was moved to a macro. tomwalters@0: */ tomwalters@0: #define DELETE_IF_NONNULL(x) { \ tomwalters@0: if ( (x) ) { \ tomwalters@0: delete (x); \ tomwalters@0: (x) = NULL; \ tomwalters@0: } \ tomwalters@0: } tomwalters@0: tomwalters@0: /*! \brief C++ delete[] if != NULL tomwalters@0: * tomwalters@0: * This was used so often, that is was moved to a macro. tomwalters@0: */ tomwalters@0: #define DELETE_ARRAY_IF_NONNULL(x) { \ tomwalters@0: if ( (x) ) { \ tomwalters@0: delete[] (x); \ tomwalters@0: (x) = NULL; \ tomwalters@0: } \ tomwalters@0: } tomwalters@0: tomwalters@0: /*! \brief C free if != NULL tomwalters@0: * tomwalters@0: * This was used so often, that is was moved to a macro. tomwalters@0: */ tomwalters@0: #define FREE_IF_NONNULL(x) { \ tomwalters@0: if ( (x) ) { \ tomwalters@0: free(x); \ tomwalters@0: (x) = NULL; \ tomwalters@0: } \ tomwalters@0: } tomwalters@0: tomwalters@0: #ifdef DEBUG tomwalters@0: # define AIM_VERIFY(x) AIM_ASSERT(x) tomwalters@0: # define AIM_ASSERT(x) { \ tomwalters@0: if (!(x)) { \ tomwalters@0: LOG_ERROR("Assertion failed.\n"); \ tomwalters@8: *(reinterpret_cast(0)) = 0; \ tomwalters@0: } \ tomwalters@0: } tomwalters@0: #else tomwalters@0: # define AIM_VERIFY(x) {x;} tomwalters@0: # define AIM_ASSERT(...) tomwalters@0: #endif tomwalters@0: tomwalters@0: namespace aimc { tomwalters@0: void LOG_ERROR(const char *sFmt, ...); tomwalters@0: void LOG_INFO(const char *sFmt, ...); tomwalters@6: void LOG_INFO_NN(const char *sFmt, ...); tomwalters@0: } // namespace aimc tomwalters@0: tomwalters@11: #endif // AIMC_SUPPORT_COMMON_H_