PseudoPref.h
// PseudoPref.h
//
// Author David Barrett-Lennard
// (C)opyright Cedanet Pty Ltd 2009
@import "IObject.h"
#include "Ceda/cxUtils/Archive.h"
#include "Ceda/cxUtils/xostream.h"
#include "Ceda/cxUtils/Hex.h"
/*
Some parts of cxObject needs access to the pref, but we want to avoid a circular link
dependency between cxObject and cxPersistStore.
Our solution is to define the pref as a datastruct here that is bitwise compatible
with a real pref.
*/
namespace ceda
{
$interface IPersistable;
struct PseudoPref
{
void Set(ptr<IPersistable> p)
{
m_oid.low_ = 0;
m_oid.high_ = 0;
m_ptr = p;
}
ptr<IObject> Get() const
{
return (ptr<IObject>&) m_ptr;
}
bool IsNull() const
{
return !m_ptr && m_oid.IsNull();
}
bool operator==(const PseudoPref& other) const
{
return m_oid == other.m_oid;
}
bool operator!=(const PseudoPref& other) const
{
return m_oid != other.m_oid;
}
bool operator<(const PseudoPref& other) const
{
return m_oid < other.m_oid;
}
bool operator<=(const PseudoPref& other) const
{
return !(other.m_oid < m_oid);
}
PseudoOid m_oid;
AnyInterface m_ptr;
};
@api xostream& operator<<(xostream& os, const PseudoPref& p);
@api void Serialise(Archive& ar, const PseudoPref& p);
@api void Deserialise(InputArchive& ar, PseudoPref& p);
} // namespace ceda