25 #ifndef __DOTS_CHANNEL_ID_H__
26 #define __DOTS_CHANNEL_ID_H__
28 #include <boost/functional/hash.hpp>
32 #include <Safir/Dob/Typesystem/Internal/InternalOperations.h>
57 m_channelId(Internal::DEFAULT_CHANNEL_ID),
58 m_channelIdStr(L
"DEFAULT_CHANNEL")
69 m_channelId(Internal::Generate64BitHash(id)),
99 if (!m_channelIdStr.empty() && m_channelId != Internal::Generate64BitHash(idStr))
101 std::wostringstream ostr;
102 ostr <<
"ChannelId two-argument constructor got an inconsistent id. Got ("
103 <<
id <<
", '" << idStr <<
"'), but the string evaluates to " << Internal::Generate64BitHash(idStr) <<
".";
118 void RemoveString() {m_channelIdStr.clear(); m_CachedUtf8String.clear();}
127 return m_channelId == other.m_channelId;
137 return !(*
this==other);
148 return m_channelId < other.m_channelId;
186 if (m_channelIdStr.empty())
191 if (m_CachedUtf8String.empty())
196 return static_cast<Int32>(m_CachedUtf8String.length() + 1);
208 if (!m_channelIdStr.empty() && m_CachedUtf8String.empty())
212 return m_CachedUtf8String;
218 UnderlyingType m_channelId;
219 std::wstring m_channelIdStr;
221 mutable std::string m_CachedUtf8String;
225 {
return out << channelId.
ToString();}
DotsC_Int64 Int64
64 bit integer type.
Definition: Defs.h:69
Class containing the identity of a channel.
Definition: ChannelId.h:45
bool operator!=(const ChannelId &other) const
Inequality operator.
Definition: ChannelId.h:135
Meant to be used when something goes very wrong.
Definition: Exceptions.h:360
static DOTS_CPP_API const ChannelId ALL_CHANNELS
Constant representing all channels.
Definition: ChannelId.h:49
#define __WFILE__
Definition: Exceptions.h:31
Int32 Utf8StringLength() const
Get the length of the string when converted to UTF-8 encoding.
Definition: ChannelId.h:184
This namespace contains all the functionality and definitions of the SAFIR SDK.
Definition: Backdoor.h:30
bool operator==(const ChannelId &other) const
Equality operator.
Definition: ChannelId.h:125
bool operator<(const ChannelId &other) const
Less-than operator.
Definition: ChannelId.h:146
DOTS_CPP_API const std::wstring ToString() const
Return a string representation of the channel id.
#define DOTS_CPP_API
Definition: Defs.h:33
std::size_t hash_value(const Safir::Dob::Typesystem::ChannelId &val)
Definition: ChannelId.h:228
ChannelId()
Default constructor.
Definition: ChannelId.h:56
Int64 UnderlyingType
Definition: ChannelId.h:160
void RemoveString()
Remove the included string from the channel id.
Definition: ChannelId.h:118
ChannelId(const Int64 id)
Constructor.
Definition: ChannelId.h:81
static std::wostream & operator<<(std::wostream &out, const ChannelId &channelId)
Definition: ChannelId.h:224
ChannelId(const Int64 id, const std::wstring &idStr)
Constructor.
Definition: ChannelId.h:94
const std::string & Utf8String() const
Convert the string to UTF-8.
Definition: ChannelId.h:206
DotsC_Int32 Int32
32 bit integer type.
Definition: Defs.h:66
UnderlyingType GetRawValue() const
Get the raw 64 bit integer identifier.
Definition: ChannelId.h:167
const std::wstring & GetRawString() const
Get the string that was used to create this id.
Definition: ChannelId.h:176
ChannelId(const std::wstring &id)
Constructor.
Definition: ChannelId.h:68
DOTS_CPP_API const std::string ToUtf8(const std::wstring &wstr)
Convert a std::wstring to UTF8-encoded std::string.