OidHighReader.h
// OidHighReader.h
//
// Author David Barrett-Lennard
// (C)opyright Cedanet Pty Ltd 2011
#include <set>
#include <map>
@import "OidSpace.h"
@import "cxPersistStore.h"
/*
Oid.h supports oid high mapping during deserialisation using TLS:
struct IOidHighDeserialiser
{
virtual void DeserialiseOidHigh(InputArchive& ar, OidHigh& oidHigh) = 0;
};
@api void SetThreadOidHighDeserialiser(IOidHighDeserialiser* p);
*/
namespace ceda
{
class OidSpaceMap;
///////////////////////////////////////////////////////////////////////////////////////////////////
// OidHighConversionMap
/*
A transient map used by the receiver side of a session to convert remote OidHigh to local
OidHigh. It is assumed that the sender doesn't translate OidHighs and instead that
responsibility is taken by the receiver as it reads remote OidHighs from an archive.
*/
class @api OidHighConversionMap
{
public:
void Write(xostream& os) const;
void Add(OidHigh remoteOidHigh, OidHigh localOidHigh);
// Apply a conversion to map the given remote OidHigh to a local OidHigh
// If remoteOidHigh = 0 then sets localOidHigh = 0 and returns true.
// Returns false if given OidHigh is unknown
bool MapRemoteOidHighToLocalOidHigh(OidHigh remoteOidHigh, OidHigh& localOidHigh) const;
private:
// Map from remote OidHigh to local OidHigh
typedef std::map<OidHigh,OidHigh> MAP;
MAP map_;
};
///////////////////////////////////////////////////////////////////////////////////////////////////
// OidHighReader
class @api OidHighReader : public IOidHighDeserialiser
{
public:
OidHighReader(OidSpaceMap* oidSpaceMap);
void SetOidSpaceMap(OidSpaceMap* oidSpaceMap) { m_oidSpaceMap = oidSpaceMap; }
void DeserialiseOid(InputArchive& ar, OID& oid);
// Implementation of IOidHighDeserialiser
virtual void DeserialiseOidHigh(InputArchive& ar, OidHigh& oidHigh);
int64 GetNumGuidsSent() const { return m_countSendOidSpaceGuid; }
private:
OidSpaceMap* m_oidSpaceMap;
OidHighConversionMap m_oidHighConversionMap;
// This sender must keep track of the set of OidHighs that have been sent to the remote computer.
// New ones need to have an (OidHigh,OidSpaceGuid) pair sent to allow the receiver to update its OidHigh
// conversion map
std::set<OidHigh> m_sentOidHighs;
int64 m_countSendOidSpaceGuid;
@if (CEDA_VALIDATE_OID_READER_WRITER_ORDER)
{
int32 m_order;
}
};
} // namespace ceda