|
|
|
|
|
When implementing COM components, one must carefully observe the prohibition on allowing exceptions to escape out to the context of the caller. But implementing COM components to follow this can be verbose and tiresome. This function suite may be used to handle all that boring guff automatically, and log the details of caught exceptions to boot!
The pantheios::com::invoke_nothrow() functions can be used to wrap non-member entry point functions, as illustrated in the following example (an extract from the adjunct library Pantheios.COM):
STDAPI DllRegisterServer_()
{
pantheios::log_NOTICE("DllRegisterServer()");
HRESULT hr = S_OK;
#ifdef _MERGE_PROXYSTUB
if(SUCCEEDED(hr))
{
hr = PrxDllRegisterServer();
}
#endif \/\* _MERGE_PROXYSTUB \*\/
if(SUCCEEDED(hr))
{
hr = _Module.RegisterServer(true);
}
if(FAILED(hr))
{
pantheios::log_ERROR( "Registration failed: ", pantheios::integer(hr, pantheios::fmt::fullHex)
, ": ", winstl::error_desc_a(hr));
}
else
{
// Translate all the other Pantheios loggers
hr = ReregisterPantheiosEventSources();
}
return hr;
}
STDAPI DllRegisterServer()
{
return pantheios::com::invoke_nothrow(DllRegisterServer_, "DllRegisterServer");
}
Any exceptions thrown in the implementation function, DllRegisterServer_() will be caught by pantheios::com::invoke_nothrow() and translated into the appropriate HRESULT, and a corresponding log statement called.
The pantheios::com::invoke_nothrow_method() functions can be used to wrap COM methods, as illustrated in the following example (an extract from Open-RJ.COM):
STDMETHODIMP Record::get_Count_(long* pVal) { pantheios::log_DEBUG("Record::Count"); return get_long_(pVal, &orj_record_t::numFields); } STDMETHODIMP Record::get_Count(long* pVal) { return pantheios::invoke_nothrow_method(this, &Record::get_Count_, pVal, "Record::Count"); }
Functions | |
| template<typename R> | |
| R | invoke_nothrow (R(__stdcall *pfn)(), char const *functionName) |
| Wraps a 0-parameter function in an exception-handler and logs any exceptions using Pantheios. | |
| template<typename R, typename A0> | |
| R | invoke_nothrow (R(__stdcall *pfn)(A0), A0 a0, char const *functionName) |
| Wraps a 1-parameter function in an exception-handler and logs any exceptions using Pantheios. | |
| template<typename R, typename A0, typename A1> | |
| R | invoke_nothrow (R(__stdcall *pfn)(A0, A1), A0 a0, A1 a1, char const *functionName) |
| Wraps a 2-parameter function in an exception-handler and logs any exceptions using Pantheios. | |
| template<typename R, typename A0, typename A1, typename A2> | |
| R | invoke_nothrow (R(__stdcall *pfn)(A0, A1, A2), A0 a0, A1 a1, A2 a2, char const *functionName) |
| Wraps a 3-parameter function in an exception-handler and logs any exceptions using Pantheios. | |
| template<typename R, typename C> | |
| R | invoke_nothrow_method (C *pThis, R(C::*pfn)(), char const *functionName) |
| Wraps a 0-parameter class member function in an exception-handler and logs any exceptions using Pantheios. | |
| template<typename R, typename C> | |
| R | invoke_nothrow_method (C *pThis, R(__stdcallC::*pfn)(), char const *functionName) |
Wraps a 0-parameter stdcall class member function in an exception-handler and logs any exceptions using Pantheios. | |
| template<typename R, typename C, typename A0> | |
| R | invoke_nothrow_method (C *pThis, R(C::*pfn)(A0), A0 a0, char const *functionName) |
| Wraps a 1-parameter class member function in an exception-handler and logs any exceptions using Pantheios. | |
| template<typename R, typename C, typename A0> | |
| R | invoke_nothrow_method (C *pThis, R(__stdcallC::*pfn)(A0), A0 a0, char const *functionName) |
Wraps a 1-parameter stdcall class member function in an exception-handler and logs any exceptions using Pantheios. | |
| template<typename R, typename C, typename A0, typename A1> | |
| R | invoke_nothrow_method (C *pThis, R(C::*pfn)(A0, A1), A0 a0, A1 a1, char const *functionName) |
| Wraps a 2-parameter class member function in an exception-handler and logs any exceptions using Pantheios. | |
| template<typename R, typename C, typename A0, typename A1> | |
| R | invoke_nothrow_method (C *pThis, R(__stdcallC::*pfn)(A0, A1), A0 a0, A1 a1, char const *functionName) |
Wraps a 2-parameter stdcall class member function in an exception-handler and logs any exceptions using Pantheios. | |
| template<typename R, typename C, typename A0, typename A1, typename A2> | |
| R | invoke_nothrow_method (C *pThis, R(C::*pfn)(A0, A1, A2), A0 a0, A1 a1, A2 a2, char const *functionName) |
| Wraps a 3-parameter class member function in an exception-handler and logs any exceptions using Pantheios. | |
| template<typename R, typename C, typename A0, typename A1, typename A2> | |
| R | invoke_nothrow_method (C *pThis, R(__stdcallC::*pfn)(A0, A1, A2), A0 a0, A1 a1, A2 a2, char const *functionName) |
Wraps a 3-parameter stdcall class member function in an exception-handler and logs any exceptions using Pantheios. | |
| template<typename R, typename C, typename A0, typename A1, typename A2, typename A3> | |
| R | invoke_nothrow_method (C *pThis, R(C::*pfn)(A0, A1, A2, A3), A0 a0, A1 a1, A2 a2, A3 a3, char const *functionName) |
| Wraps a 4-parameter class member function in an exception-handler and logs any exceptions using Pantheios. | |
| template<typename R, typename C, typename A0, typename A1, typename A2, typename A3> | |
| R | invoke_nothrow_method (C *pThis, R(__stdcallC::*pfn)(A0, A1, A2, A3), A0 a0, A1 a1, A2 a2, A3 a3, char const *functionName) |
Wraps a 4-parameter stdcall class member function in an exception-handler and logs any exceptions using Pantheios. | |
| template<typename R, typename C, typename A0, typename A1, typename A2, typename A3, typename A4> | |
| R | invoke_nothrow_method (C *pThis, R(C::*pfn)(A0, A1, A2, A3, A4), A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, char const *functionName) |
| Wraps a 5-parameter class member function in an exception-handler and logs any exceptions using Pantheios. | |
| template<typename R, typename C, typename A0, typename A1, typename A2, typename A3, typename A4> | |
| R | invoke_nothrow_method (C *pThis, R(__stdcallC::*pfn)(A0, A1, A2, A3, A4), A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, char const *functionName) |
Wraps a 5-parameter stdcall class member function in an exception-handler and logs any exceptions using Pantheios. | |
| R pantheios::com::invoke_nothrow | ( | R(__stdcall *pfn)(A0, A1, A2) | , | |
| A0 | a0, | |||
| A1 | a1, | |||
| A2 | a2, | |||
| char const * | functionName | |||
| ) | [inline] |
Wraps a 3-parameter function in an exception-handler and logs any exceptions using Pantheios.
| pfn | The function that will be invoked | |
| a0 | The first argument to the function | |
| a1 | The second argument to the function | |
| a2 | The third argument to the function | |
| functionName | The name of the function, used in any logging messages |
| R pantheios::com::invoke_nothrow | ( | R(__stdcall *pfn)(A0, A1) | , | |
| A0 | a0, | |||
| A1 | a1, | |||
| char const * | functionName | |||
| ) | [inline] |
Wraps a 2-parameter function in an exception-handler and logs any exceptions using Pantheios.
| pfn | The function that will be invoked | |
| a0 | The first argument to the function | |
| a1 | The second argument to the function | |
| functionName | The name of the function, used in any logging messages |
| R pantheios::com::invoke_nothrow | ( | R(__stdcall *pfn)(A0) | , | |
| A0 | a0, | |||
| char const * | functionName | |||
| ) | [inline] |
Wraps a 1-parameter function in an exception-handler and logs any exceptions using Pantheios.
| pfn | The function that will be invoked | |
| a0 | The argument to the function | |
| functionName | The name of the function, used in any logging messages |
| R pantheios::com::invoke_nothrow | ( | R(__stdcall *pfn)() | , | |
| char const * | functionName | |||
| ) | [inline] |
Wraps a 0-parameter function in an exception-handler and logs any exceptions using Pantheios.
| pfn | The function that will be invoked | |
| functionName | The name of the function, used in any logging messages |
References pantheios::log_ALERT(), and pantheios::log_CRITICAL().
| R pantheios::com::invoke_nothrow_method | ( | C * | pThis, | |
| R(__stdcallC::*)(A0, A1, A2, A3, A4) | pfn, | |||
| A0 | a0, | |||
| A1 | a1, | |||
| A2 | a2, | |||
| A3 | a3, | |||
| A4 | a4, | |||
| char const * | functionName | |||
| ) | [inline] |
Wraps a 5-parameter stdcall class member function in an exception-handler and logs any exceptions using Pantheios.
| pThis | The instance on which the member function will be invoked | |
| pfn | The member function that will be invoked | |
| a0 | The first argument to the function | |
| a1 | The second argument to the function | |
| a2 | The third argument to the function | |
| a3 | The fourth argument to the function | |
| a4 | The fifth argument to the function | |
| functionName | The name of the function, used in any logging messages |
References pantheios::log_ALERT(), and pantheios::log_CRITICAL().
| R pantheios::com::invoke_nothrow_method | ( | C * | pThis, | |
| R(C::*)(A0, A1, A2, A3, A4) | pfn, | |||
| A0 | a0, | |||
| A1 | a1, | |||
| A2 | a2, | |||
| A3 | a3, | |||
| A4 | a4, | |||
| char const * | functionName | |||
| ) | [inline] |
Wraps a 5-parameter class member function in an exception-handler and logs any exceptions using Pantheios.
| pThis | The instance on which the member function will be invoked | |
| pfn | The member function that will be invoked | |
| a0 | The first argument to the function | |
| a1 | The second argument to the function | |
| a2 | The third argument to the function | |
| a3 | The fourth argument to the function | |
| a4 | The fifth argument to the function | |
| functionName | The name of the function, used in any logging messages |
References pantheios::log_ALERT(), and pantheios::log_CRITICAL().
| R pantheios::com::invoke_nothrow_method | ( | C * | pThis, | |
| R(__stdcallC::*)(A0, A1, A2, A3) | pfn, | |||
| A0 | a0, | |||
| A1 | a1, | |||
| A2 | a2, | |||
| A3 | a3, | |||
| char const * | functionName | |||
| ) | [inline] |
Wraps a 4-parameter stdcall class member function in an exception-handler and logs any exceptions using Pantheios.
| pThis | The instance on which the member function will be invoked | |
| pfn | The member function that will be invoked | |
| a0 | The first argument to the function | |
| a1 | The second argument to the function | |
| a2 | The third argument to the function | |
| a3 | The fourth argument to the function | |
| functionName | The name of the function, used in any logging messages |
References pantheios::log_ALERT(), and pantheios::log_CRITICAL().
| R pantheios::com::invoke_nothrow_method | ( | C * | pThis, | |
| R(C::*)(A0, A1, A2, A3) | pfn, | |||
| A0 | a0, | |||
| A1 | a1, | |||
| A2 | a2, | |||
| A3 | a3, | |||
| char const * | functionName | |||
| ) | [inline] |
Wraps a 4-parameter class member function in an exception-handler and logs any exceptions using Pantheios.
| pThis | The instance on which the member function will be invoked | |
| pfn | The member function that will be invoked | |
| a0 | The first argument to the function | |
| a1 | The second argument to the function | |
| a2 | The third argument to the function | |
| a3 | The fourth argument to the function | |
| functionName | The name of the function, used in any logging messages |
References pantheios::log_ALERT(), and pantheios::log_CRITICAL().
| R pantheios::com::invoke_nothrow_method | ( | C * | pThis, | |
| R(__stdcallC::*)(A0, A1, A2) | pfn, | |||
| A0 | a0, | |||
| A1 | a1, | |||
| A2 | a2, | |||
| char const * | functionName | |||
| ) | [inline] |
Wraps a 3-parameter stdcall class member function in an exception-handler and logs any exceptions using Pantheios.
| pThis | The instance on which the member function will be invoked | |
| pfn | The member function that will be invoked | |
| a0 | The first argument to the function | |
| a1 | The second argument to the function | |
| a2 | The third argument to the function | |
| functionName | The name of the function, used in any logging messages |
References pantheios::log_ALERT(), and pantheios::log_CRITICAL().
| R pantheios::com::invoke_nothrow_method | ( | C * | pThis, | |
| R(C::*)(A0, A1, A2) | pfn, | |||
| A0 | a0, | |||
| A1 | a1, | |||
| A2 | a2, | |||
| char const * | functionName | |||
| ) | [inline] |
Wraps a 3-parameter class member function in an exception-handler and logs any exceptions using Pantheios.
| pThis | The instance on which the member function will be invoked | |
| pfn | The member function that will be invoked | |
| a0 | The first argument to the function | |
| a1 | The second argument to the function | |
| a2 | The third argument to the function | |
| functionName | The name of the function, used in any logging messages |
References pantheios::log_ALERT(), and pantheios::log_CRITICAL().
| R pantheios::com::invoke_nothrow_method | ( | C * | pThis, | |
| R(__stdcallC::*)(A0, A1) | pfn, | |||
| A0 | a0, | |||
| A1 | a1, | |||
| char const * | functionName | |||
| ) | [inline] |
Wraps a 2-parameter stdcall class member function in an exception-handler and logs any exceptions using Pantheios.
| pThis | The instance on which the member function will be invoked | |
| pfn | The member function that will be invoked | |
| a0 | The first argument to the function | |
| a1 | The second argument to the function | |
| functionName | The name of the function, used in any logging messages |
References pantheios::log_ALERT(), and pantheios::log_CRITICAL().
| R pantheios::com::invoke_nothrow_method | ( | C * | pThis, | |
| R(C::*)(A0, A1) | pfn, | |||
| A0 | a0, | |||
| A1 | a1, | |||
| char const * | functionName | |||
| ) | [inline] |
Wraps a 2-parameter class member function in an exception-handler and logs any exceptions using Pantheios.
| pThis | The instance on which the member function will be invoked | |
| pfn | The member function that will be invoked | |
| a0 | The first argument to the function | |
| a1 | The second argument to the function | |
| functionName | The name of the function, used in any logging messages |
References pantheios::log_ALERT(), and pantheios::log_CRITICAL().
| R pantheios::com::invoke_nothrow_method | ( | C * | pThis, | |
| R(__stdcallC::*)(A0) | pfn, | |||
| A0 | a0, | |||
| char const * | functionName | |||
| ) | [inline] |
Wraps a 1-parameter stdcall class member function in an exception-handler and logs any exceptions using Pantheios.
| pThis | The instance on which the member function will be invoked | |
| pfn | The member function that will be invoked | |
| a0 | The argument to the function | |
| functionName | The name of the function, used in any logging messages |
References pantheios::log_ALERT(), and pantheios::log_CRITICAL().
| R pantheios::com::invoke_nothrow_method | ( | C * | pThis, | |
| R(C::*)(A0) | pfn, | |||
| A0 | a0, | |||
| char const * | functionName | |||
| ) | [inline] |
Wraps a 1-parameter class member function in an exception-handler and logs any exceptions using Pantheios.
| pThis | The instance on which the member function will be invoked | |
| pfn | The member function that will be invoked | |
| a0 | The argument to the function | |
| functionName | The name of the function, used in any logging messages |
References pantheios::log_ALERT(), and pantheios::log_CRITICAL().
| R pantheios::com::invoke_nothrow_method | ( | C * | pThis, | |
| R(__stdcallC::*)() | pfn, | |||
| char const * | functionName | |||
| ) | [inline] |
Wraps a 0-parameter stdcall class member function in an exception-handler and logs any exceptions using Pantheios.
| pThis | The instance on which the member function will be invoked | |
| pfn | The member function that will be invoked | |
| functionName | The name of the function, used in any logging messages |
References pantheios::log_ALERT(), and pantheios::log_CRITICAL().
| R pantheios::com::invoke_nothrow_method | ( | C * | pThis, | |
| R(C::*)() | pfn, | |||
| char const * | functionName | |||
| ) | [inline] |
Wraps a 0-parameter class member function in an exception-handler and logs any exceptions using Pantheios.
| pThis | The instance on which the member function will be invoked | |
| pfn | The member function that will be invoked | |
| functionName | The name of the function, used in any logging messages |
References pantheios::log_ALERT(), and pantheios::log_CRITICAL().
|
|
|
| pantheios Library documentation © Matthew Wilson, 2006-2008 |
|