File: catalog.h

package info (click to toggle)
qtwebengine-opensource-src 5.15.2%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,891,008 kB
  • sloc: cpp: 12,231,790; ansic: 4,139,950; javascript: 590,747; python: 550,957; asm: 507,724; xml: 434,729; java: 166,199; objc: 79,696; perl: 72,973; sh: 70,983; cs: 30,332; makefile: 21,627; yacc: 8,867; tcl: 8,297; php: 5,896; pascal: 4,488; lex: 2,830; lisp: 2,703; sql: 1,810; ruby: 683; awk: 200; sed: 56
file content (52 lines) | stat: -rw-r--r-- 2,017 bytes parent folder | download | duplicates (7)
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
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SERVICES_SERVICE_MANAGER_CATALOG_H_
#define SERVICES_SERVICE_MANAGER_CATALOG_H_

#include <map>
#include <vector>

#include "base/macros.h"
#include "services/service_manager/public/cpp/manifest.h"

namespace service_manager {

// Owns the Service Manager's collections of Manifests and provides convenient
// indexes for fast lookup by name and resolution of parent-child relationships.
class Catalog {
 public:
  // Constructs a catalog over a set of Manifests to use for lookup.
  explicit Catalog(const std::vector<Manifest>& manifests);
  ~Catalog();

  // Returns manifest data for the service named by |service_name|. If no
  // service is known by that name, this returns null.
  const Manifest* GetManifest(const Manifest::ServiceName& service_name);

  // Returns manifest data for the parent of the service named by
  // |service_name|. If the named service has no parent (i.e. it's not packaged
  // within another service) then this returns null.
  const Manifest* GetParentManifest(const Manifest::ServiceName& service_name);

 private:
  // The set of all top-level manifests known to the Service Manager.
  const std::vector<Manifest> manifests_;

  // Maintains a mapping from service name to manifest for quick lookup of any
  // manifest regardless of whether it's packaged. The values in this map refer
  // to objects owned by |manifests_| above.
  const std::map<Manifest::ServiceName, const Manifest*> manifest_map_;

  // Maintains a mapping from service name to parent manifest for quick
  // reverse-lookup of packaged service relationships. The values in this map
  // refer to objects owned by |manifests_| above.
  const std::map<Manifest::ServiceName, const Manifest*> parent_manifest_map_;

  DISALLOW_COPY_AND_ASSIGN(Catalog);
};

}  // namespace service_manager

#endif  // SERVICES_SERVICE_MANAGER_CATALOG_H_