Android-cuttlefish cvd tool
selector.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024 The Android Open Source Project
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 <utility>
20
26
27namespace cuttlefish {
28namespace selector {
29
31 const SelectorOptions& selectors);
32
33// Selects a single group based on the request's selector options. Asks the user
34// to manually choose a single group if multiple groups match the selector
35// options and stdin is a terminal.
36Result<LocalInstanceGroup> SelectGroup(const InstanceManager& instance_manager,
37 const CommandRequest& request);
38
39// Selects a single instance based on the request's selector options. Asks the
40// user to manually choose a single instance if multiple instances match the
41// selector options and stdin is a terminal. Also returns the group the
42// selected instance belongs to.
43Result<std::pair<LocalInstance, LocalInstanceGroup>> SelectInstance(
44 const InstanceManager& instance_manager, const CommandRequest& request);
45
46// Selects all instances matching the request's selector options.
47//
48// Returns a vector of pairs, where each pair contains a matching
49// LocalInstanceGroup and a vector of its matching LocalInstance member
50// instances. Unlike SelectInstance, this method does not fail or prompt the
51// user if multiple instances match.
52Result<std::vector<std::pair<LocalInstanceGroup, std::vector<LocalInstance>>>>
53SelectInstances(const InstanceManager& instance_manager,
54 const CommandRequest& request);
55
56} // namespace selector
57} // namespace cuttlefish
std::vector< LocalInstance > Filter(const std::vector< LocalInstance > &instances, std::function< bool(const LocalInstance &)> predicate)
Definition: local_instance_group.cpp:42
Result< std::pair< LocalInstance, LocalInstanceGroup > > SelectInstance(const InstanceManager &instance_manager, const CommandRequest &request)
Definition: selector.cpp:207
Result< LocalInstanceGroup > SelectGroup(const InstanceManager &instance_manager, const CommandRequest &request)
Definition: selector.cpp:191
InstanceDatabase::Filter BuildFilterFromSelectors(const SelectorOptions &selectors)
Definition: selector.cpp:177
Result< std::vector< std::pair< LocalInstanceGroup, std::vector< LocalInstance > > > > SelectInstances(const InstanceManager &instance_manager, const CommandRequest &request)
Definition: selector.cpp:226
Definition: alloc_driver.h:20