//
//  logging.h
//  logging
//
//  Created by Mehdi Stapleton on 2015-05-18.
//
//

#ifndef __logging__
#define __logging__

//#define XCODE_COMPILATION
#ifndef XCODE_COMPILATION
#include "mex.h"
#endif

//Standard libraries
#include <assert.h>
#include <sstream>
#include <string>
#include <cstdio>
#include <iostream>
#include <fstream>

//---------------------------------------------------------------
//             GENERAL PREPROCESSOR DEFINITIONS
//---------------------------------------------------------------

//#define DEBUG_MODE

//---------------------------------------------------------------
//                      TYPE DEFINITIONS
//---------------------------------------------------------------


//---------------------------------------------------------------
//                      GLOBAL CONSTANTS
//---------------------------------------------------------------


//---------------------------------------------------------------
//                      LOGGING FUNCTIONS
//---------------------------------------------------------------

#ifndef XCODE_COMPILATION

#define LOG_DEBUG(txt) {std::ostringstream debug_oss; \
debug_oss <<"Debug:"<< txt << ";\n"; \
mexPrintf(debug_oss.str().c_str());}

#define LOG_PRINT(txt) {std::ostringstream debug_oss; \
debug_oss << txt << ";\n"; \
mexPrintf(debug_oss.str().c_str());}

#define LOG_WARNING(txt) {std::ostringstream debug_oss; \
debug_oss <<"Warning:"<< txt << ";\n"; \
mexPrintf(debug_oss.str().c_str());}

#define LOG_ERROR(txt) {std::ostringstream debug_oss; \
debug_oss <<"Error:"<< txt << ";\n"; \
mexErrMsgTxt(debug_oss.str().c_str());}

#endif

//---------------------------------------------------------------
//                      MACROS
//---------------------------------------------------------------

#ifndef XCODE_COMPILATION

#define PROJECT_RELPATH(relpath) PROJECT_DIR_PATH + relpath

#define IS_REAL_3D_FULL_DOUBLE(P) (!mxIsComplex(P) && \
        mxGetNumberOfDimensions(P) == 3 && !mxIsSparse(P) && mxIsDouble(P))

#define IS_REAL_2D_FULL_DOUBLE(P) (!mxIsComplex(P) && \
        mxGetNumberOfDimensions(P) == 2 && !mxIsSparse(P) && mxIsDouble(P))

#define IS_REAL_SCALAR(P) (mxIsDouble(P) && !mxIsComplex(P) && mxGetNumberOfElements(P) == 1)

#endif

#endif /* defined(__logging__) */
