You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.2 KiB

// Copyright 2020 Siemens Digital Industries Software
// ==================================================
// Copyright 2013.
// Siemens Product Lifecycle Management Software Inc.
// All Rights Reserved.
// ==================================================
// Copyright 2020 Siemens Digital Industries Software
/**
@file
Defines the class ResultCheck, which leverages error codes in order to check the
status of returned codes and throw exceptions if need be.
*/
#ifndef TEAMCENTER_BASE_UTILS_RESULT_CHECK_HXX
#define TEAMCENTER_BASE_UTILS_RESULT_CHECK_HXX
#include <base_utils/libbase_utils_exports.h>
/**
@brief A ResultStatus instance is a temporary object to which both error codes and instances status_t can be assigned.
<br>If, once such has been assigned, the result turns out to be a failure, the class will throw an IFail using the
last error on the error stack.
@code
ResultCheck ok;
try
{
//NOTE: No need to check what calls have returned.
// If this is an error, the ResultStatus class will ensure that an exception is thrown.
ok = callSomeFunction_ReturningAnErrorCode();
ok = callSomeOtherFunction_ReturningAnErrorCode();
[...]
}
catch ( const IFail& ifail )
{
//Handle the exception here
[...]
}
@endcode
@note Prefer usage of #ResultStatus, since it can handle both error codes and #status_t.
*/
class BASE_UTILS_API ResultCheck
{
public:
/**
Default constructor.
*/
ResultCheck();
/**
Constructs a ResultCheck object from an error code.
<br>If the error code is not ITK_ok, an IFail exception will be thrown.
@note It is expected that the matching error is already on the top of the error stack prior to this call.
*/
ResultCheck( const int ifail );/* */
/**
Destructor
*/
virtual ~ResultCheck();
/**
Operator =
Throws an IFail exception if the error code in the parameter @p ifail is not ITK_ok.
@note It is expected that the matching error is already on the top of the error stack prior to this call.
*/
ResultCheck& operator=( const int ifail ); /* */
};
#include <base_utils/libbase_utils_undef.h>
#endif