1
0
forked from Alepha/Alepha

Moving towards type-linked exception storage.

This commit is contained in:
2022-10-16 11:36:09 -04:00
parent 8a75be721e
commit 5c1d821bc2

View File

@ -163,13 +163,25 @@ namespace Alepha::Hydrogen
template< typename T > template< typename T >
concept DerivedFromException= std::is_base_of_v< Exception, T >; concept DerivedFromException= std::is_base_of_v< Exception, T >;
class NamedResourceStorage;
class NamedResourceThrowable class NamedResourceInterface
: public virtual bases< Throwable >
{ {
public: public:
using storage_type= NamedResourceStorage;
virtual ~NamedResourceInterface()= default;
virtual std::string_view resourceName() const noexcept= 0; virtual std::string_view resourceName() const noexcept= 0;
}; };
class NamedResourceStorage
: virtual public NamedResourceInterface
{
private:
std::string storage;
public:
std::string_view resourceName() const noexcept final { return storage; }
};
class NamedResourceThrowable : virtual public bases< Throwable, NamedResourceInterface > {};
class AnyTaggedNamedResourceThrowable class AnyTaggedNamedResourceThrowable
: virtual public bases< NamedResourceThrowable, AnyTaggedThrowable > {}; : virtual public bases< NamedResourceThrowable, AnyTaggedThrowable > {};
template< typename tag > template< typename tag >
@ -209,12 +221,25 @@ namespace Alepha::Hydrogen
: public virtual bases< AnyTaggedNamedResourceViolation, TaggedViolation< tag >, TaggedNamedResourceThrowable< tag > > {}; : public virtual bases< AnyTaggedNamedResourceViolation, TaggedViolation< tag >, TaggedNamedResourceThrowable< tag > > {};
class AllocationThrowable class AllocationAmountStorage;
: public virtual bases< Throwable > class AllocationAmountInterface
{ {
public: public:
using storage_type= AllocationAmountStorage;
virtual ~AllocationAmountInterface()= default;
virtual std::size_t allocationAmount() const noexcept= 0; virtual std::size_t allocationAmount() const noexcept= 0;
}; };
class AllocationAmountStorage
: virtual public AllocationAmountInterface
{
private:
std::size_t amount;
public:
std::size_t allocationAmount() const noexcept final { return amount; }
};
class AllocationThrowable
: public virtual bases< Throwable, AllocationAmountInterface > {};
class AnyTaggedAllocationThrowable class AnyTaggedAllocationThrowable
: public virtual bases< AllocationThrowable, AnyTaggedThrowable > {}; : public virtual bases< AllocationThrowable, AnyTaggedThrowable > {};
template< typename tag > template< typename tag >
@ -257,16 +282,6 @@ namespace Alepha::Hydrogen
const char *message() const noexcept { return storage.c_str(); } const char *message() const noexcept { return storage.c_str(); }
}; };
class AllocationAmountStorage
: virtual public AllocationThrowable
{
private:
std::size_t storage;
public:
std::size_t allocationAmount() const noexcept final { return storage; }
};
class AllocationExceptionBridge class AllocationExceptionBridge
: virtual public std::bad_alloc, public virtual ExceptionBridgeInterface, virtual public Exception : virtual public std::bad_alloc, public virtual ExceptionBridgeInterface, virtual public Exception
{ {