25 #ifndef __DOTS_LIBRARY_EXCEPTIONS_H__
26 #define __DOTS_LIBRARY_EXCEPTIONS_H__
28 #include <boost/noncopyable.hpp>
29 #include <boost/thread/once.hpp>
34 #pragma warning (push)
35 #pragma warning (disable: 4251) // warning C4251: 'Safir::Dob::Typesystem::LibraryExceptions::m_CallbackMap' : class 'stdext::hash_map<_Kty,_Ty>' needs to have dll-interface to be used by clients of class 'Safir::Dob::Typesystem::LibraryExceptions'
36 #pragma warning (disable: 4275) // warning C4275: non dll-interface class 'boost::noncopyable_::noncopyable' used as base for dll-interface class 'Safir::Dob::Typesystem::LibraryExceptions'
39 #define CATCH_LIBRARY_EXCEPTIONS_AND_RUN(statement) \
40 catch (const Safir::Dob::Typesystem::FundamentalException & exc) \
41 {Safir::Dob::Typesystem::LibraryExceptions::Instance().Set(exc); statement;} \
42 catch (const Safir::Dob::Typesystem::Exception & exc) \
43 {Safir::Dob::Typesystem::LibraryExceptions::Instance().Set(exc); statement;} \
44 catch (const std::exception & exc) \
45 {Safir::Dob::Typesystem::LibraryExceptions::Instance().Set(exc); statement;} \
47 {Safir::Dob::Typesystem::LibraryExceptions::Instance().SetUnknown(); statement;}
49 #define CATCH_LIBRARY_EXCEPTIONS \
50 catch (const Safir::Dob::Typesystem::FundamentalException & exc) \
51 {Safir::Dob::Typesystem::LibraryExceptions::Instance().Set(exc);} \
52 catch (const Safir::Dob::Typesystem::Exception & exc) \
53 {Safir::Dob::Typesystem::LibraryExceptions::Instance().Set(exc);} \
54 catch (const std::exception & exc) \
55 {Safir::Dob::Typesystem::LibraryExceptions::Instance().Set(exc);} \
57 {Safir::Dob::Typesystem::LibraryExceptions::Instance().SetUnknown();}
70 private boost::noncopyable
167 void Set(
const std::exception & exception);
201 void AppendDescription(
const std::wstring & moreDescription);
222 typedef void (*ThrowExceptionCallback)(
const std::wstring & description);
233 {
return m_CallbackMap.insert(CallbackMap::value_type(exceptionId,throwFunction)).second;}
248 void Throw(
const TypeId exceptionId,
const std::string& description)
const;
257 typedef unordered_map<TypeId, ThrowExceptionCallback> CallbackMap;
258 CallbackMap m_CallbackMap;
266 struct SingletonHelper
272 static boost::once_flag m_onceFlag;
280 #pragma warning (pop)
This is the base class of all (non-Fundamental) Exceptions.
Definition: Exceptions.h:223
static LibraryExceptions & Instance()
Get the instance of the singleton.
This is the base class of all Fundamental Exceptions.
Definition: Exceptions.h:190
DotsC_TypeId TypeId
A unique type identifier.
Definition: Defs.h:219
Contains methods used when passing exceptions across language boundaries.
Definition: LibraryExceptions.h:69
bool RegisterException(const TypeId exceptionId, ThrowExceptionCallback throwFunction)
Register an exception with the object factory.
Definition: LibraryExceptions.h:232
Common functionality for the exception hierarchy of the DOB typesystem.
Definition: Exceptions.h:63
#define DOTS_CPP_API
Definition: Defs.h:33