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.
93 lines
2.9 KiB
93 lines
2.9 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 ResultStatus, which leverages both error codes and instances of status_t
|
|
in order to check the status of returned codes and throw exceptions if need be.
|
|
*/
|
|
|
|
/* */
|
|
#ifndef TEAMCENTER_BASE_UTILS_RESULTSTATUS_HXX
|
|
#define TEAMCENTER_BASE_UTILS_RESULTSTATUS_HXX
|
|
|
|
#include <base_utils/StatusT.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
|
|
ResultStatus 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_ReturningAStatusT();
|
|
[...]
|
|
}
|
|
catch ( const IFail& ifail )
|
|
{
|
|
//Handle the exception here
|
|
[...]
|
|
}
|
|
@endcode
|
|
*/
|
|
class BASE_UTILS_API ResultStatus
|
|
{
|
|
public:
|
|
/**
|
|
Default constructor.
|
|
*/
|
|
ResultStatus();
|
|
|
|
/**
|
|
Constructs a ResultStatus object from a status_t instance.
|
|
<br>If the input instance is not 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.
|
|
*/
|
|
ResultStatus( const status_t& iStatusT); /* */
|
|
|
|
/**
|
|
Constructs a ResultStatus 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.
|
|
*/
|
|
ResultStatus( const int ifail ); /* */
|
|
|
|
/**
|
|
Destructor
|
|
*/
|
|
virtual ~ResultStatus();
|
|
|
|
/**
|
|
Operator =
|
|
Throws an IFail exception if the parameter @p result is not OK.
|
|
|
|
@note It is expected that the matching error is already on the top of the error stack prior to this call.
|
|
*/
|
|
ResultStatus& operator=( const status_t& result );
|
|
|
|
/**
|
|
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.
|
|
*/
|
|
ResultStatus& operator=( const int ifail );/* */
|
|
};
|
|
|
|
#include <base_utils/libbase_utils_undef.h>
|
|
|
|
#endif // TEAMCENTER_BASE_UTILS_RESULTSTATUS_HXX
|