VecTime.h

// VecTime.h
//
// Author David Barrett-Lennard
// (C)opyright Cedanet Pty Ltd 2019

@import "cxOperation.h"
@import "Ceda/cxObject/Object.h"
@import "Ceda/cxObject/Guid2.h"
#include "Ceda/cxUtils/xvector.h"
#include <utility>

namespace ceda
{

///////////////////////////////////////////////////////////////////////////////////////////////////
// SiteId

// A site is uniquely identified by a 128 bit GUID

$typedef+ Guid SiteId;

///////////////////////////////////////////////////////////////////////////////////////////////////
// VecTime

// A sequence of (s,t) pairs ordered by s
// where s is a siteid and t is the number of operations from site s

$struct+ VecTime : xvector< std::pair<SiteId,ssize_t> >
{
    void UnionWith(const VecTime& rhs);

    ssize_t GetCount() const;
    
    void Write(xostream& os) const;

    void Serialise(Archive& ar) const;
    void Deserialise(InputArchive& ar);
};

$function+ VecTime Union(const VecTime& v1, const VecTime& v2);
$function+ VecTime Intersection(const VecTime& v1, const VecTime& v2);

$function+ inline int64 Count(const VecTime& v)
{
    return v.GetCount();
}

} // namespace ceda