/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* $Source: src/include/usr/hwpf/hwp/hwpisteperror.H $ */ /* */ /* IBM CONFIDENTIAL */ /* */ /* COPYRIGHT International Business Machines Corp. 2012 */ /* */ /* p1 */ /* */ /* Object Code Only (OCO) source materials */ /* Licensed Internal Code Source Materials */ /* IBM HostBoot Licensed Internal Code */ /* */ /* The source code for this program is not published or otherwise */ /* divested of its trade secrets, irrespective of what has been */ /* deposited with the U.S. Copyright Office. */ /* */ /* Origin: 30 */ /* */ /* IBM_PROLOG_END_TAG */ #ifndef __ISTEPERROR_H #define __ISTEPERROR_H /** * @file isteperror.H * * Defines the following classes: * * IStepError: Handles creation of a top level error to incidate that a * particular ISTEP has failed, all hwp error plids are added * to the top level error. */ #include #include namespace ISTEP_ERROR { /** * @class IStepError * * Inteface to the a top level error log returned to the ISTEP dispatcher when * an individual step fails due to an error in a hardware procedure. * * The class may be used to aggregate the errors returned from procedures * which may have been run in parallel. The top level error log will * indicate the failed step and the module in which the error was created. * Callers should note that only the addErrorDetails call should be used * within a thread. * * NOTE: This class returns an allocated error log object which needs to * deleted by the reciever. * users must call getErrorHandle() to recieve the pointer which can * be deleted. * */ class IStepError { public: /** * @brief */ IStepError() : iv_eHandle(NULL), iv_errorCount(0) { mutex_init( &iv_mutex ); }; /** * @brief Destructor * * Will free internal storage if getErrorHandle is not called */ ~IStepError() { mutex_destroy( &iv_mutex ); if( iv_eHandle ) { delete iv_eHandle; } }; /** * @brief Adds selected error details from the passed in * error to the top level istep error log object * * The expected usage for this object is to agrigate * errors which may have been generated by hardware * procedures which are run in parallel. * * The first call will initialize the internal object * pointer allocating a new errl object as needed. * Subsequent calls to this function will result in a new * user data section being added to the top level error * log with additional error data from the error handle * passed in. * * NOTE: This function is thread safe. * * @param: reasoncode - reason code identifying which Istep has * failed * @param: modid - module id identifying which module or * procedure has caused the error to be * created * * @param i_err - error handle passed in, the internal code * will parse specific details from the log * passed in to include in the top level elog. */ void addErrorDetails(ISTEP::istepReasonCode reasoncode, ISTEP::istepModuleId modid, errlHndl_t i_err ); /** * @brief Return an errlHndl_t which points to the internal error * log object. * * Note: Caller must delete the errlHndl_t after use. * This funciton is not thread safe * * @return iv_eHandle - error handle of top level ISTEP error to * be returned to the ISTEP dispatcher. * */ errlHndl_t getErrorHandle(); /** * @brief Utility function to determine if the internal error handle * is null. * * @return boolean * true indicates errl handle is currently NULL; * false indicates error object has been * allocated; * * Note: This funciton is not thread safe * */ bool isNull() const { return ((iv_eHandle == NULL ) ? true : false); }; private: // disable copy constructor IStepError(const IStepError&); // serialize access to the internal data area mutex_t iv_mutex; // pointer to the top level ISTEP error log, this log will be // passed back to the istep dispatcher when a hardware proceudre // fails. errlHndl_t iv_eHandle; // count placed in user data 3 of the error log to indicate how // many errors were captured in this top level elog uint32_t iv_errorCount; }; inline errlHndl_t IStepError::getErrorHandle() { errlHndl_t l_err = iv_eHandle; // storage will be freed by destructor if the pointer is non-null iv_eHandle = NULL; return l_err; }; }; #endif