Seid.h

// Seid.h
//
// Author David Barrett-Lennard
// (C)opyright Cedanet Pty Ltd 2004

#ifndef Ceda_cxLss_Seid_H
#define Ceda_cxLss_Seid_H

#include "cxLss.h"

#ifdef _MSC_VER
    // non dll-interface struct 'X' used as base for dll-interface class 'Y'
    #pragma warning(disable:4275)
#endif

namespace ceda
{

// Low 32 bits and high 32 bits of a 64 bit Serial element Id (Seid)
typedef uint32 SeidPart;
typedef SeidPart SeidHigh;
typedef SeidPart SeidLow;

// A 64 bit Serial element Id (Seid)
// A null Seid contains zeros for both the low and high 32 bits.
// A null Seid is never used for a serial element in the LSS
// The conversion to bool is based on a test against null.

struct Seid
{
    Seid(SeidLow low,SeidHigh high) : low_(low), high_(high) {}
    explicit Seid(uint64 v) : value_(v) {}
    Seid() : value_(0) {}

    void SetNull() 
    { 
        value_ = 0;
    }

    bool IsNull() const
    {
        return value_ == 0;
    }

    explicit operator bool() const { return !IsNull(); }

    bool operator==(const Seid& other) const
    {
        return value_ == other.value_;
    }
    bool operator!=(const Seid& other) const
    {
        return value_ != other.value_;
    }

    bool operator<(const Seid& other) const 
    { 
        return value_ < other.value_;
    }

    union
    {
        struct
        {
            // Note: this assumes a little endian architecture
            // The order is consistent with uint64 representation of a Seid
            SeidLow  low_;
            SeidHigh high_;
        };
        uint64 value_;
    };
};

} // namespace ceda

#endif // include guard