⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 error.cpp

📁 美国COPLEY驱动器,程序开发工具之一.
💻 CPP
字号:
/************************************************************/
/*                                                          */
/*  Copley Motion Libraries                                 */
/*                                                          */
/*  Author: Stephen Glow                                    */
/*                                                          */
/*  Copyright (c) 2002-2005 Copley Controls Corp.           */
/*                          http://www.copleycontrols.com   */
/*                                                          */
/************************************************************/

/** \file
This file handles initializing the static data objects used by the Error class.
*/

#include "CML.h"

CML_NAMESPACE_USE();

CML_NEW_ERROR( Error, OK,      "No error" );
CML_NEW_ERROR( Error, Unknown, "Unknown error ID code" );

#if CML_ERROR_HASH_SIZE > 0 
// Error hash table
static const Error *errHash[ CML_ERROR_HASH_SIZE ];

/***************************************************************************/
/**
Lookup the constant error object associated with the passed ID code.
If the passed ID doesn't correspond to any known Error object, then
the address of the Error::Unknown will be returned.

@param id The ID code of the error to be found
@return A pointer to an error object.
*/
/***************************************************************************/
const Error *Error::Lookup( int16 id )
{
	// Look the error object up in the hash table
	const Error *err = errHash[ id % CML_ERROR_HASH_SIZE ];

	// Search all the errors in this hash location
	while( err && (err->id != id) )
		err = err->next;

	// If the error wasn't found, return 'unknown'
	if( !err )
	{
		cml.Error( "Unable to locate error id: %d\n", id );
		return &Error::Unknown;
	}

	return err;
}

/***************************************************************************/
/**
Initialize the Error object hash table.
*/
/***************************************************************************/

void Error::InitErrorHash( void )
{
	int i = id % CML_ERROR_HASH_SIZE;
	next = errHash[i];
	errHash[i] = this;
}

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -