WsipcSessionProtocolId.h

// WsipcSessionProtocolId.h
//
// Author David Barrett-Lennard
// (C)opyright Cedanet Pty Ltd 2015

@import "cxWorkingSetIpc.h"
@import "Ceda/cxObject/Object.h"
@import "Ceda/cxObject/Guid2.h"
#include "Ceda/cxUtils/xostream.h"
#include "Ceda/cxUtils/Archive.h"

namespace ceda
{

///////////////////////////////////////////////////////////////////////////////////////////////////
// WsipcSessionProtocolId

const int ProtocolIdLen = 28;

$model+ WsipcSessionProtocolId
{
    assignable<xstring> Id;
    int32 Version;
};

$function+ WsipcSessionProtocolId MakeWsipcSessionProtocolId(const xstring& id, int32 version);

// The number of serialised bytes when using SerialiseProtocolId or DeserialiseProtocolId.
// This is fixed at 32 bytes (up to 28 bytes for the characters of WsipcSessionProtocolId::Id, and 
// 4 bytes for WsipcSessionProtocolId::Version).
// This fixed size is useful for validating a message beginning with a serialised WsipcSessionProtocolId
const int SerialisedWsipcSessionProtocolIdSize = 32;

// WsipcSessionProtocolId is a model and therefore has generated implementations of operator<<
// for an Archive and operator>> for an InputArchive
// However we want alternative versions which are more robust for the purposes of validating
// a protocol id sent down a socket connection.

// May throw std::invalid_argument if p.Id doesn't meet the requirements documented above
@api void SerialiseProtocolId(Archive& ar, const WsipcSessionProtocolId& p);

@api void DeserialiseProtocolId(InputArchive& ar, WsipcSessionProtocolId& p);

///////////////////////////////////////////////////////////////////////////////////////////////////
// WsipcHostInfo

$model+ WsipcHostInfo
{
    assignable<xstring> Hostname;       // host machine's name
    assignable<xstring> FullHostname;   // the FQDN (fully qualified domain host name)
    assignable<xstring> Userid;         // the "user id" also known as "login name" under Unix
    assignable<xstring> Username;       // the full user name (something like "Mr. John Smith").
    assignable<xstring> OsDesciption;   // description of the current platform in a user-readable form
    MGuid Uid;                          // Application dependent GUID which may be used to identify a user
};

$function+ xstring GetOsDescription();
$function+ xstring GetHostName();
$function+ xstring GetUserName();
$function+ xstring GetFullHostName();
$function+ const ceda::WsipcHostInfo& GetLocalHostInfo();

} // namespace ceda