1 // Copyright 2024 The Pigweed Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 // use this file except in compliance with the License. You may obtain a copy of 5 // the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations under 13 // the License. 14 15 #pragma once 16 17 #include "pw_bluetooth_sapphire/internal/host/common/identifier.h" 18 19 namespace bthost { 20 // Separate types to help prevent mixing up the two types of service IDs used in 21 // gatt2/Server. 22 class ClientServiceId : public bt::Identifier<uint64_t> { 23 public: ClientServiceId(uint64_t value)24 constexpr explicit ClientServiceId(uint64_t value) 25 : Identifier<uint64_t>(value) {} ClientServiceId()26 constexpr ClientServiceId() : ClientServiceId(0u) {} 27 }; 28 29 class InternalServiceId : public bt::Identifier<uint64_t> { 30 public: InternalServiceId(uint64_t value)31 constexpr explicit InternalServiceId(uint64_t value) 32 : Identifier<uint64_t>(value) {} InternalServiceId()33 constexpr InternalServiceId() : InternalServiceId(0u) {} 34 }; 35 } // namespace bthost 36 37 namespace std { 38 template <> 39 struct hash<bthost::ClientServiceId> { 40 size_t operator()(const bthost::ClientServiceId& id) const { 41 return std::hash<decltype(id.value())>()(id.value()); 42 } 43 }; 44 45 template <> 46 struct hash<bthost::InternalServiceId> { 47 size_t operator()(const bthost::InternalServiceId& id) const { 48 return std::hash<decltype(id.value())>()(id.value()); 49 } 50 }; 51 } // namespace std 52