<commit_before>///////////////////////////////////////////////////////////////////////////////
// FILE:       dc1394.cpp
// PROJECT:    MicroManage
// SUBSYSTEM:  DeviceAdapters
//-----------------------------------------------------------------------------
// DESCRIPTION:
// dc1394 camera_ module based on libdc1394 API
//                
// AUTHOR:        <NAME>, 12/29/2006, contributions by <NAME>
//                
// COPYRIGHT:     University of California, San Francisco, 2006
//
// LICENSE:       This file is distributed under the BSD license.
//                License text is included with the source distribution.
//
//                This file is distributed in the hope that it will be useful,
//                but WITHOUT ANY WARRANTY; without even the implied warranty
//                of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
//                IN NO EVENT SHALL THE COPYRIGHT OWNER OR
//                CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//                INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES.
//

#include "../../MMDevice/ModuleInterface.h"
#include "../../MMDevice/DeviceUtils.h"
#include "dc1394.h"
#include <dc1394/control.h>
#include <dc1394/utils.h>
#include <dc1394/conversions.h>
#include <dc1394/vendor/avt.h>
#include <boost/lexical_cast.hpp>
#include <string>
#include <cstring> // memset(), memcpy()
#include <sstream>
#include <iomanip>
#include <math.h>

#include <iostream>

using namespace std;

// global constants
const char* g_DeviceName = "dc1394_CAM";
const char* g_PixelType_8bit = "8bit";
const char* g_PixelType_16bit = "16bit";
const char* g_Keyword_Modes = "Video Modes";
const char* g_Keyword_FrameRates = "Frame Rates";

// singleton instance
Cdc1394* Cdc1394::s_pInstance = 0;
unsigned Cdc1394::s_refCount = 0;


// Macros for error chacking on dc1394 calls.
//
// All calls to dc1394 library functions that return dc1394error_t should use
// one of these.

#pragma warning(disable: 4127) // Conditional expression is constant

// Helper; do not use directly
// TODO Translate dc1394 codes to readable messages
#define _LOG_DC1394_ERROR(_func, _err, _msg) do { \
   ostringstream __err_oss; __err_oss << (_err); \
   ostringstream __line_oss; __line_oss << __LINE__; \
   _func("dc1394 error " + __err_oss.str() + " at " + __FILE__ + ":" + __line_oss.str() + "; " + (_msg)); \
} while (0)

// Check if _err (of type dc1394error_t) is an error. If it is, log it,
// together with _msg (const std::string or const char*), and return _mm_err
// (an int representing a MM error code) from the current function (whose
// return type must be int).
#define CHECK_DC1394_ERROR(_err, _mm_err, _msg) do { \
   dc1394error_t __err = (_err); \
   int __mm_err = (_mm_err); \
   const std::string& __msg = (_msg); \
   if (__err != DC1394_SUCCESS) { \
      _LOG_DC1394_ERROR(LogMessage, __err, __msg); \
      if (__mm_err != DEVICE_OK) { \
         ostringstream mm_err_oss; mm_err_oss << __mm_err; \<commit_msg>Remove compiler warning on Mac<commit_after>///////////////////////////////////////////////////////////////////////////////
// FILE:       dc1394.cpp
// PROJECT:    MicroManage
// SUBSYSTEM:  DeviceAdapters
//-----------------------------------------------------------------------------
// DESCRIPTION:
// dc1394 camera_ module based on libdc1394 API
//                
// AUTHOR:        <NAME>, 12/29/2006, contributions by <NAME>is
//                
// COPYRIGHT:     University of California, San Francisco, 2006
//
// LICENSE:       This file is distributed under the BSD license.
//                License text is included with the source distribution.
//
//                This file is distributed in the hope that it will be useful,
//                but WITHOUT ANY WARRANTY; without even the implied warranty
//                of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
//                IN NO EVENT SHALL THE COPYRIGHT OWNER OR
//                CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//                INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES.
//

#include "../../MMDevice/ModuleInterface.h"
#include "../../MMDevice/DeviceUtils.h"
#include "dc1394.h"
#include <dc1394/control.h>
#include <dc1394/utils.h>
#include <dc1394/conversions.h>
#include <dc1394/vendor/avt.h>
#include <boost/lexical_cast.hpp>
#include <string>
#include <cstring> // memset(), memcpy()
#include <sstream>
#include <iomanip>
#include <math.h>

#include <iostream>

using namespace std;

// global constants
const char* g_DeviceName = "dc1394_CAM";
const char* g_PixelType_8bit = "8bit";
const char* g_PixelType_16bit = "16bit";
const char* g_Keyword_Modes = "Video Modes";
const char* g_Keyword_FrameRates = "Frame Rates";

// singleton instance
Cdc1394* Cdc1394::s_pInstance = 0;
unsigned Cdc1394::s_refCount = 0;


// Macros for error chacking on dc1394 calls.
//
// All calls to dc1394 library functions that return dc1394error_t should use
// one of these.

#ifdef WIN32
#pragma warning(disable: 4127) // Conditional expression is constant
#endif

// Helper; do not use directly
// TODO Translate dc1394 codes to readable messages
#define _LOG_DC1394_ERROR(_func, _err, _msg) do { \
   ostringstream __err_oss; __err_oss << (_err); \
   ostringstream __line_oss; __line_oss << __LINE__; \
   _func("dc1394 error " + __err_oss.str() + " at " + __FILE__ + ":" + __line_oss.str() + "; " + (_msg)); \
} while (0)

// Check if _err (of type dc1394error_t) is an error. If it is, log it,
// together with _msg (const std::string or const char*), and return _mm_err
// (an int representing a MM error code) from the current function (whose
// return type must be int).
#define CHECK_DC1394_ERROR(_err, _mm_err, _msg) do { \
   dc1394error_t __err = (_err); \
   int __mm_err = (_mm_err); \
   const std::string& __msg = (_msg); \
   if (__err != DC1394_SUCCESS) { \
      _LOG_DC1394_ERROR(LogMessage, __err, __msg); \
      if (__mm_err != DEVICE_OK) { \
         ostringstream mm_err_oss; mm_err_oss << __mm_err; \
{'fraction_non_alphanumeric': 0.16344086021505377, 'fraction_numerical': 0.03904052936311001, 'mean_word_length': 2.4588100686498855, 'pattern_counts': {'":': 2, '<': 41, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2246865', 'n_tokens_mistral': 2001, 'n_tokens_neox': 1838, 'n_words': 591}