25#ifndef __DOTS_INSTANCE_ID_H__
26#define __DOTS_INSTANCE_ID_H__
32#include <Safir/Dob/Typesystem/Internal/InternalOperations.h>
71 m_instanceId(Internal::Generate64BitHash(id)),
96 m_instanceIdStr(idStr)
99 if (!m_instanceIdStr.empty() && m_instanceId != Internal::Generate64BitHash(idStr))
101 std::wostringstream ostr;
102 ostr <<
"InstanceId two-argument constructor got an inconsistent id. Got ("
103 <<
id <<
", '" << idStr <<
"'), but the string evaluates to " << Internal::Generate64BitHash(idStr) <<
".";
117 void RemoveString() {m_instanceIdStr.clear(); m_CachedUtf8String.clear();}
126 return m_instanceId == other.m_instanceId;
136 return !(*
this==other);
147 return m_instanceId < other.m_instanceId;
193 if (m_instanceIdStr.empty())
198 if (m_CachedUtf8String.empty())
203 return static_cast<Int32>(m_CachedUtf8String.length() + 1);
215 if (!m_instanceIdStr.empty() && m_CachedUtf8String.empty())
219 return m_CachedUtf8String;
226 std::wstring m_instanceIdStr;
228 mutable std::string m_CachedUtf8String;
232 {
return out << instanceId.
ToString();}
236 {
return std::hash<InstanceId::UnderlyingType>()(val.
GetRawValue());}
#define __WFILE__
Definition Exceptions.h:31
This namespace contains all the functionality and definitions of the SAFIR SDK.
Definition Backdoor.h:31
std::size_t hash_value(const Safir::Dob::Typesystem::ChannelId &val)
Definition ChannelId.h:228
DotsC_Int32 Int32
32 bit integer type.
Definition Defs.h:66
DotsC_Int64 Int64
64 bit integer type.
Definition Defs.h:69
static std::wostream & operator<<(std::wostream &out, const ChannelId &channelId)
Definition ChannelId.h:224
DOTS_CPP_API const std::string ToUtf8(const std::wstring &wstr)
Convert a std::wstring to UTF8-encoded std::string.
Meant to be used when something goes very wrong.
Definition Exceptions.h:364
Class containing the identity of an instance.
Definition InstanceId.h:49
DOTS_CPP_API const std::wstring ToString() const
Return a string representation of the instance id.
InstanceId(const std::wstring &id)
Constructor.
Definition InstanceId.h:70
bool operator==(const InstanceId &other) const
Equality operator.
Definition InstanceId.h:124
InstanceId()
Default constructor.
Definition InstanceId.h:61
void RemoveString()
Remove the included string from the instance id.
Definition InstanceId.h:117
static InstanceId GenerateRandom()
Returns a random instance id.
Definition InstanceId.h:54
bool operator<(const InstanceId &other) const
Less-than operator.
Definition InstanceId.h:145
InstanceId(const Int64 id, const std::wstring &idStr)
Constructor.
Definition InstanceId.h:94
const std::wstring & GetRawString() const
Get the string that was used to create this id.
Definition InstanceId.h:183
Int64 UnderlyingType
Definition InstanceId.h:167
Int32 Utf8StringLength() const
Get the length of the string when converted to UTF-8 encoding.
Definition InstanceId.h:191
UnderlyingType GetRawValue() const
Get the raw 64 bit integer identifier.
Definition InstanceId.h:174
const std::string & Utf8String() const
Convert the string to UTF-8.
Definition InstanceId.h:213
bool operator!=(const InstanceId &other) const
Inequality operator.
Definition InstanceId.h:134
InstanceId(const Dob::Typesystem::Int64 id)
Constructor.
Definition InstanceId.h:82
#define DOTS_CPP_API
Definition Defs.h:33