1 // 2 // Copyright (C) 2015 Google, Inc. 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at: 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 17 #pragma once 18 19 #include <bluetooth/characteristic.h> 20 #include <bluetooth/uuid.h> 21 22 #include <vector> 23 24 namespace bluetooth { 25 class Service { 26 public: 27 Service() = default; 28 Service(const Service& other); 29 Service(uint16_t handle, bool primary, const UUID& uuid, 30 const std::vector<Characteristic>& characteristics, 31 const std::vector<Service>& included_services) 32 : handle_(handle), 33 primary_(primary), 34 uuid_(uuid), 35 characteristics_(characteristics), 36 included_services_(included_services){}; 37 Service& operator=(const Service& other); 38 virtual ~Service() = default; 39 40 // Comparison function and operator. 41 bool Equals(const Service& other) const; 42 bool operator==(const Service& rhs) const; 43 bool operator!=(const Service& rhs) const; 44 45 uint16_t handle() const { return handle_; } 46 bool primary() const { return primary_; } 47 const UUID& uuid() const { return uuid_; } 48 const std::vector<Characteristic>& characteristics() const { 49 return characteristics_; 50 } 51 std::vector<Characteristic>& characteristics() { return characteristics_; } 52 const std::vector<Service>& included_services() const { 53 return included_services_; 54 } 55 56 protected: 57 uint16_t handle_; 58 bool primary_; 59 UUID uuid_; 60 std::vector<Characteristic> characteristics_; 61 std::vector<Service> included_services_; 62 }; 63 } 64