PersistStoreExceptions.h

// PersistStoreExceptions.h
//
// Author David Barrett-Lennard
// (C)opyright Cedanet Pty Ltd 2008

@import "cxPersistStore.h"
@import "IPersistStore.h"
@import "OID.h"
@import "Ceda/cxObject/ReflectionByteCodeValue.h"
#include "Ceda/cxUtils/IException.h"
#include "Ceda/cxUtils/ExceptionBase.h"
#include "Ceda/cxUtils/xstring.h"
#include "Ceda/cxUtils/OpenMode.h"

namespace ceda
{
///////////////////////////////////////////////////////////////////////////////////////////////////
// TypeMismatchException
//
// Represents the error that the given ReflectedClass doesn't implement the given interface.

struct @api TypeMismatchException : public IException
{
    TypeMismatchException(const ReflectedClass& rc, const ReflectedInterface& ri) :
        m_rc(rc),
        m_ri(ri)
    {
    }

    virtual void Write(xostream& os) const;

    const ReflectedClass& m_rc;
    const ReflectedInterface& m_ri;
};

///////////////////////////////////////////////////////////////////////////////////////////////////
// DerefDanglingOidException

struct @api DerefDanglingOidException : public IException
{
    DerefDanglingOidException(OID oid) : m_oid(oid) {}

    virtual void Write(xostream& os) const;

    OID m_oid;
};

///////////////////////////////////////////////////////////////////////////////////////////////////
// DeserialisePersistentObjectException

struct @api DeserialisePersistentObjectException : public ExceptionBase
{
    DeserialisePersistentObjectException(ConstStringZ desc, OID oid) : 
        ExceptionBase(desc),
        m_oid(oid) 
    {
    }

    // The OID of the object that caused a deserialisation error
    OID m_oid;
};

///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenPSpaceException

struct @api OpenPSpaceException : public IException
{
    OpenPSpaceException(EOpenMode openMode, ConstStringZ name) : m_openMode(openMode), m_name(name) {}
    virtual void Write(xostream& os) const;
    
    EOpenMode m_openMode;
    xstring m_name;
};

///////////////////////////////////////////////////////////////////////////////////////////////////
// RepeatedClassNameInCidMapException

struct @api RepeatedClassNameInCidMapException : public IException
{
    RepeatedClassNameInCidMapException(ConstStringZ name) : m_name(name) {}
    virtual void Write(xostream& os) const;
    
    xstring m_name;
};

///////////////////////////////////////////////////////////////////////////////////////////////////
// DerefNullPrefException

// An attempt was made to dereference a null pref<T>
struct @api DerefNullPrefException : public IException
{
    virtual void Write(xostream& os) const;
};

///////////////////////////////////////////////////////////////////////////////////////////////////
// ObjectNotPersistableException

// An attempt was made to initialise a pref<T> to an object that doesn't implement IPersistable
struct @api ObjectNotPersistableException : public IException
{
    virtual void Write(xostream& os) const;
};

///////////////////////////////////////////////////////////////////////////////////////////////////
// TypeOpsNotFoundException

struct @api TypeOpsNotFoundException : public IException
{
    TypeOpsNotFoundException(const ReflectionByteCodeValue& rbcv) : m_rbcv(rbcv) {}

    virtual void Write(xostream& os) const;
    
    ReflectionByteCodeValue m_rbcv;
};

///////////////////////////////////////////////////////////////////////////////////////////////////
// BadTypeOpsIdException

struct @api BadTypeOpsIdException : public IException
{
    BadTypeOpsIdException(TypeOpsId tid) : m_tid(tid) {}

    virtual void Write(xostream& os) const;
    
    TypeOpsId m_tid;
};

} // namespace ceda