Android-cuttlefish cvd tool
num_instances_parser.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 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 <stdint.h>
20
21#include <vector>
22
26
27namespace cuttlefish {
28namespace selector {
29
30// Extracts the number of instances to create and the optionally requested
31// instance ids from a number of flags and selector options.
33 public:
34 std::vector<Flag> Flags(const selector::SelectorOptions&);
35
36 // These will only return the default values until the command line arguments
37 // are parsed by the flags returned from the Flags function.
38 size_t NumInstances() const;
39 std::vector<uint32_t> InstanceIds() const;
40
41 private:
42 Result<void> Validate() const;
43
44 std::optional<size_t> num_instance_names_;
45 std::optional<size_t> num_instances_;
46 std::optional<unsigned> base_instance_num_;
47 std::optional<std::vector<unsigned>> instance_nums_;
48};
49} // namespace selector
50} // namespace cuttlefish
Definition: num_instances_parser.h:32
size_t NumInstances() const
Definition: num_instances_parser.cpp:34
std::optional< size_t > num_instance_names_
Definition: num_instances_parser.h:44
std::optional< unsigned > base_instance_num_
Definition: num_instances_parser.h:46
std::vector< Flag > Flags(const selector::SelectorOptions &)
Definition: num_instances_parser.cpp:62
Result< void > Validate() const
Definition: num_instances_parser.cpp:85
std::vector< uint32_t > InstanceIds() const
Definition: num_instances_parser.cpp:48
std::optional< std::vector< unsigned > > instance_nums_
Definition: num_instances_parser.h:47
std::optional< size_t > num_instances_
Definition: num_instances_parser.h:45
Definition: alloc_driver.h:20
tl::expected< T, StackTraceError > Result
Definition: result_type.h:30
Definition: selector_common_parser.h:28