iceoryx_doc  1.0.1
service_registry.hpp
1 // Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://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,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // SPDX-License-Identifier: Apache-2.0
16 #ifndef IOX_POSH_ROUDI_SERVICE_REGISTRY_HPP
17 #define IOX_POSH_ROUDI_SERVICE_REGISTRY_HPP
18 
19 #include "iceoryx_posh/capro/service_description.hpp"
20 #include "iceoryx_utils/cxx/vector.hpp"
21 #include "iceoryx_utils/internal/cxx/set.hpp"
22 
23 #include <cstdint>
24 #include <map>
25 
26 namespace iox
27 {
28 namespace roudi
29 {
31 {
32  public:
33  static constexpr uint32_t MAX_INSTANCES_PER_SERVICE = 100u;
34  using CaproIdString_t = capro::IdString_t;
35  using InstanceSet_t = cxx::vector<CaproIdString_t, MAX_INSTANCES_PER_SERVICE>;
36  struct instance_t
37  {
38  InstanceSet_t instanceSet;
39  };
40  using serviceMap_t = std::map<CaproIdString_t, instance_t>;
41 
42  void add(const CaproIdString_t& service, const CaproIdString_t& instance);
43  void remove(const CaproIdString_t& service, const CaproIdString_t& instance);
44  void find(InstanceSet_t& instances,
45  const CaproIdString_t& service,
46  const CaproIdString_t& instance = capro::AnyInstanceString) const;
47  const serviceMap_t& getServiceMap() const;
48 
49  private:
50  mutable serviceMap_t m_serviceMap;
51 };
52 } // namespace roudi
53 } // namespace iox
54 
55 #endif // IOX_POSH_ROUDI_SERVICE_REGISTRY_HPP
Definition: service_registry.hpp:31
Definition: service_description.hpp:29
Definition: service_registry.hpp:37