tomwalters@268: // Copyright 2006-2010, Thomas Walters, Willem van Engen
tomwalters@268: //
tomwalters@268: // AIM-C: A C++ implementation of the Auditory Image Model
tomwalters@268: // http://www.acousticscale.org/AIMC
tomwalters@268: //
tomwalters@268: // This program is free software: you can redistribute it and/or modify
tomwalters@268: // it under the terms of the GNU General Public License as published by
tomwalters@268: // the Free Software Foundation, either version 3 of the License, or
tomwalters@268: // (at your option) any later version.
tomwalters@268: //
tomwalters@268: // This program is distributed in the hope that it will be useful,
tomwalters@268: // but WITHOUT ANY WARRANTY; without even the implied warranty of
tomwalters@268: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
tomwalters@268: // GNU General Public License for more details.
tomwalters@268: //
tomwalters@268: // You should have received a copy of the GNU General Public License
tomwalters@268: // along with this program. If not, see .
tomwalters@268:
tomwalters@268: /*! \file
tomwalters@268: * \brief Common includes for all AIM-C
tomwalters@268: */
tomwalters@268:
tomwalters@268: /*! \author: Thomas Walters
tomwalters@268: * \author: Willem van Engen
tomwalters@268: * \date 2010/01/30
tomwalters@296: * \version \$Id$
tomwalters@268: */
tomwalters@268:
tomwalters@283: #ifndef AIMC_SUPPORT_COMMON_H_
tomwalters@283: #define AIMC_SUPPORT_COMMON_H_
tomwalters@268:
tomwalters@268: #include
tomwalters@268: #include
tomwalters@268: #include
tomwalters@268:
tomwalters@268: // A macro to disallow the copy constructor and operator= functions
tomwalters@268: // This should be used in the private: declarations for a class
tomwalters@268: #define DISALLOW_COPY_AND_ASSIGN(TypeName) \
tomwalters@268: TypeName(const TypeName&); \
tomwalters@268: void operator=(const TypeName&)
tomwalters@268:
tomwalters@268: #if !defined(_T)
tomwalters@268: # ifdef _UNICODE
tomwalters@268: # define _T(x) L ## x
tomwalters@268: # else
tomwalters@268: # define _T(x) x
tomwalters@268: # endif
tomwalters@268: #endif
tomwalters@268:
tomwalters@268: /*! \brief C++ delete if != NULL
tomwalters@268: *
tomwalters@268: * This was used so often, that is was moved to a macro.
tomwalters@268: */
tomwalters@268: #define DELETE_IF_NONNULL(x) { \
tomwalters@268: if ( (x) ) { \
tomwalters@268: delete (x); \
tomwalters@268: (x) = NULL; \
tomwalters@268: } \
tomwalters@268: }
tomwalters@268:
tomwalters@268: /*! \brief C++ delete[] if != NULL
tomwalters@268: *
tomwalters@268: * This was used so often, that is was moved to a macro.
tomwalters@268: */
tomwalters@268: #define DELETE_ARRAY_IF_NONNULL(x) { \
tomwalters@268: if ( (x) ) { \
tomwalters@268: delete[] (x); \
tomwalters@268: (x) = NULL; \
tomwalters@268: } \
tomwalters@268: }
tomwalters@268:
tomwalters@268: /*! \brief C free if != NULL
tomwalters@268: *
tomwalters@268: * This was used so often, that is was moved to a macro.
tomwalters@268: */
tomwalters@268: #define FREE_IF_NONNULL(x) { \
tomwalters@268: if ( (x) ) { \
tomwalters@268: free(x); \
tomwalters@268: (x) = NULL; \
tomwalters@268: } \
tomwalters@268: }
tomwalters@268:
tomwalters@268: #ifdef DEBUG
tomwalters@268: # define AIM_VERIFY(x) AIM_ASSERT(x)
tomwalters@268: # define AIM_ASSERT(x) { \
tomwalters@268: if (!(x)) { \
tomwalters@268: LOG_ERROR("Assertion failed.\n"); \
tomwalters@280: *(reinterpret_cast(0)) = 0; \
tomwalters@268: } \
tomwalters@268: }
tomwalters@268: #else
tomwalters@268: # define AIM_VERIFY(x) {x;}
tomwalters@268: # define AIM_ASSERT(...)
tomwalters@268: #endif
tomwalters@268:
tomwalters@268: namespace aimc {
tomwalters@268: void LOG_ERROR(const char *sFmt, ...);
tomwalters@268: void LOG_INFO(const char *sFmt, ...);
tomwalters@278: void LOG_INFO_NN(const char *sFmt, ...);
tomwalters@268: } // namespace aimc
tomwalters@268:
tomwalters@283: #endif // AIMC_SUPPORT_COMMON_H_