VR-Engage  2.2
Loading...
Searching...
No Matches
vreMessageId.h
Go to the documentation of this file.
1/*********************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*********************************************************************************/
5
6//! \file vreMessageId.h
7//! \brief Defines message identifier class for the VREngage messaging system
8//!
9//! This file contains the DtVreMessageId class which provides unique identification
10//! and hierarchical matching for VREngage messages. Message IDs support dot-notation
11//! hierarchies and wildcard matching, enabling flexible message routing and filtering.
12
13#pragma once
14
16
17#include <string>
18#include <vector>
19
20#include <vlutil/vlHash.h>
21
22namespace makVre
23{
24
25//! \brief Message identifier class for the VREngage messaging system
26//!
27//! This class provides unique identification and hierarchical matching for VREngage
28//! messages. It supports dot-notation hierarchies (e.g., "category.subcategory.name")
29//! and wildcard matching using the "*" character. Message IDs are used for message
30//! routing, filtering, and identification in the VREngage messaging system.
31//!
32//! Message IDs are created from string type names, which are hashed for efficient
33//! comparison. The string is also tokenized by dots to support hierarchical matching.
35{
36public:
37 //! \brief Default constructor
38 //!
39 //! Initializes a new message ID with an "INVALID TYPE" type string.
40 //! This constructor should generally not be used directly.
42
43 //! \brief Constructor with type string
44 //! \param name Type name string for the message ID
45 //!
46 //! Initializes a new message ID with the specified type string.
47 //! The type string is hashed for efficient comparison and tokenized
48 //! by dots to support hierarchical matching. The string can contain
49 //! wildcards (*) to match any value at a specific hierarchy level.
50 DtVreMessageId(const std::string& name);
51
52 //! \brief Copy constructor
53 //! \param orig Message ID to copy
54 //!
55 //! Creates a new message ID that is a copy of the specified message ID.
57
58 //! \brief Destructor
59 //!
60 //! Cleans up resources used by the message ID.
62
63 //! \brief Checks if this message ID matches another message ID
64 //! \param id Message ID to compare against
65 //! \return True if the IDs match, false otherwise
66 //!
67 //! This method checks if this message ID matches the specified message ID.
68 //! If the hash values match exactly, the result is true. Otherwise, it performs
69 //! a hierarchical comparison, taking wildcards into account. A wildcard in this
70 //! ID will match any value in the corresponding position of the other ID.
71 bool matches(const DtVreMessageId& id) const;
72
73 //! \brief Checks if this message ID matches another message ID at a specific depth
74 //! \param id Message ID to compare against
75 //! \param depth Hierarchy level to compare at (0-based index)
76 //! \return True if the IDs match at the specified depth, false otherwise
77 //!
78 //! This method checks if this message ID matches the specified message ID
79 //! at the given hierarchy depth. It compares the hash values at the specified
80 //! depth, taking wildcards into account. A wildcard in this ID will match any
81 //! value in the corresponding position of the other ID.
82 bool matches(const DtVreMessageId& id, int depth) const;
83
84 //! \brief Gets the type string of this message ID
85 //! \return Reference to the type string
86 //!
87 //! This method returns the original type string used to create this message ID.
88 const std::string& type() const { return myType; }
89
90 //! \brief Sets a new type string for this message ID
91 //! \param newType New type string to set
92 //!
93 //! This method sets a new type string for this message ID and recomputes
94 //! the hash values and tokenized hierarchy. It is generally not recommended
95 //! to change the type of a message ID after creation.
96 void setType(const std::string& newType);
97
98 //! \brief Gets the hash value at a specific hierarchy depth
99 //! \param depth Hierarchy level to get the hash for (0-based index)
100 //! \return Hash value at the specified depth
101 //!
102 //! This method returns the hash value at the specified hierarchy depth.
103 //! It is used for hierarchical matching in the message routing system.
104 DtHashId idAtDepth(int depth) const { return myIds[depth]; }
105
106 //! \brief Gets the hash value of the complete type string
107 //! \return Hash value of the type string
108 //!
109 //! This method returns the hash value of the complete type string.
110 //! It is used for efficient message type identification and comparison.
111 DtHashId hashType() const { return myHashType; }
112
113 //! \brief Equality operator
114 //! \param rhs Right-hand side message ID to compare with
115 //! \return True if the message IDs have the same hash value, false otherwise
116 //!
117 //! This operator compares the hash values of the two message IDs.
118 //! Two message IDs are considered equal if their hash values match exactly.
119 bool operator==(const DtVreMessageId& rhs) const;
120
121 //! \brief Inequality operator
122 //! \param rhs Right-hand side message ID to compare with
123 //! \return True if the message IDs have different hash values, false otherwise
124 //!
125 //! This operator is the logical negation of the equality operator.
126 bool operator!=(const DtVreMessageId& rhs) const { return !(*this == rhs); }
127
128protected:
129 //! \brief Hash value of the complete type string
130 //!
131 //! This hash value is used for efficient message type identification and comparison.
132 DtHashId myHashType;
133
134 //! \brief Original type string used to create this message ID
135 std::string myType;
136
137 //! \brief Vector of hash values for each hierarchy level
138 //!
139 //! This vector contains the hash values for each level of the dot-separated
140 //! hierarchy. Wildcards are represented by the special theWildcard value.
141 std::vector<DtHashId> myIds;
142
143 //! \brief Special hash value used to represent wildcards in the hierarchy
144 //!
145 //! This value is used in the myIds vector to represent wildcards (*)
146 //! in the type string hierarchy.
147 static DtHashId theWildcard;
148};
149
150} // namespace makVre
const std::string & type() const
Gets the type string of this message ID.
Definition vreMessageId.h:88
std::vector< DtHashId > myIds
Vector of hash values for each hierarchy level.
Definition vreMessageId.h:141
bool matches(const DtVreMessageId &id, int depth) const
Checks if this message ID matches another message ID at a specific depth.
~DtVreMessageId()
Destructor.
std::string myType
Original type string used to create this message ID.
Definition vreMessageId.h:135
bool operator!=(const DtVreMessageId &rhs) const
Inequality operator.
Definition vreMessageId.h:126
bool matches(const DtVreMessageId &id) const
Checks if this message ID matches another message ID.
bool operator==(const DtVreMessageId &rhs) const
Equality operator.
DtHashId hashType() const
Gets the hash value of the complete type string.
Definition vreMessageId.h:111
DtVreMessageId(const DtVreMessageId &orig)
Copy constructor.
DtVreMessageId(const std::string &name)
Constructor with type string.
DtVreMessageId()
Default constructor.
DtHashId idAtDepth(int depth) const
Gets the hash value at a specific hierarchy depth.
Definition vreMessageId.h:104
void setType(const std::string &newType)
Sets a new type string for this message ID.
static DtHashId theWildcard
Special hash value used to represent wildcards in the hierarchy.
Definition vreMessageId.h:147
DtHashId myHashType
Hash value of the complete type string.
Definition vreMessageId.h:132
Defines export macros for the VREngage Message Manager library.
#define MESSAGEMANAGER_DLL
Export/import macro for non-Windows platforms.
Definition export.h:39
Include export definitions for this library.
Definition glsVreMessageUtil.h:49