forked from boston-dynamics/spot-cpp-sdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsignal_schema_key.h
More file actions
59 lines (43 loc) · 1.65 KB
/
Copy pathsignal_schema_key.h
File metadata and controls
59 lines (43 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* Copyright (c) 2023 Boston Dynamics, Inc. All rights reserved.
*
* Downloading, reproducing, distributing or otherwise using the SDK Software
* is subject to the terms and conditions of the Boston Dynamics Software
* Development Kit License (20191101-BDSDK-SL).
*/
#pragma once
#include <stdint.h>
#include <string>
namespace bosdyn {
namespace client {
namespace data_buffer {
class SignalSchemaKey {
public:
SignalSchemaKey(const std::string& client_name, const std::string& serialized_schema)
: m_client_name(client_name), m_serialized_schema(serialized_schema) {
ComputeHash();
}
~SignalSchemaKey() = default;
const std::string& ClientName() const { return m_client_name; }
const std::string& SerializedSchema() const { return m_serialized_schema; }
bool IsEquivalent(const SignalSchemaKey& other) const {
return ClientName() == other.ClientName() && SerializedSchema() == other.SerializedSchema();
}
// Hashed value for this key.
uint64_t Hash() const { return m_hash; }
// We generally want the same key and serialized scheme to result in the same key id,
// but in the unlikely case that we ever get the same hashed value as another key
// with different client name and serialized schema, we can increment the salt value
// and compute a new key for a given registration.
uint64_t GenerateReplacementHash();
protected:
uint64_t ComputeHash();
private:
const std::string m_client_name;
const std::string m_serialized_schema;
uint64_t m_salt = 0;
uint64_t m_hash = 0;
};
} // namespace data_buffer
} // namespace client
} // namespace bosdyn