25 #ifndef __DOTS_INSTANCE_ID_H__
26 #define __DOTS_INSTANCE_ID_H__
28 #include <boost/functional/hash.hpp>
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;
225 UnderlyingType m_instanceId;
226 std::wstring m_instanceIdStr;
228 mutable std::string m_CachedUtf8String;
232 {
return out << instanceId.
ToString();}
DotsC_Int64 Int64
64 bit integer type.
Definition: Defs.h:69
Meant to be used when something goes very wrong.
Definition: Exceptions.h:360
#define __WFILE__
Definition: Exceptions.h:31
This namespace contains all the functionality and definitions of the SAFIR SDK.
Definition: Backdoor.h:30
Class containing the identity of an instance.
Definition: InstanceId.h:48
Int64 UnderlyingType
Definition: InstanceId.h:167
const std::string & Utf8String() const
Convert the string to UTF-8.
Definition: InstanceId.h:213
InstanceId(const std::wstring &id)
Constructor.
Definition: InstanceId.h:70
InstanceId(const Dob::Typesystem::Int64 id)
Constructor.
Definition: InstanceId.h:82
InstanceId()
Default constructor.
Definition: InstanceId.h:61
Int32 Utf8StringLength() const
Get the length of the string when converted to UTF-8 encoding.
Definition: InstanceId.h:191
#define DOTS_CPP_API
Definition: Defs.h:33
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
std::size_t hash_value(const Safir::Dob::Typesystem::ChannelId &val)
Definition: ChannelId.h:228
UnderlyingType GetRawValue() const
Get the raw 64 bit integer identifier.
Definition: InstanceId.h:174
const std::wstring & GetRawString() const
Get the string that was used to create this id.
Definition: InstanceId.h:183
static std::wostream & operator<<(std::wostream &out, const ChannelId &channelId)
Definition: ChannelId.h:224
DotsC_Int32 Int32
32 bit integer type.
Definition: Defs.h:66
DOTS_CPP_API const std::wstring ToString() const
Return a string representation of the instance id.
InstanceId(const Int64 id, const std::wstring &idStr)
Constructor.
Definition: InstanceId.h:94
bool operator<(const InstanceId &other) const
Less-than operator.
Definition: InstanceId.h:145
bool operator!=(const InstanceId &other) const
Inequality operator.
Definition: InstanceId.h:134
bool operator==(const InstanceId &other) const
Equality operator.
Definition: InstanceId.h:124
DOTS_CPP_API const std::string ToUtf8(const std::wstring &wstr)
Convert a std::wstring to UTF8-encoded std::string.