1 // Copyright (C) 2021 The Android Open Source Project
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 #pragma once
16 
17 #include <cstdint>
18 #include <memory>
19 #include <random>
20 #include <vector>
21 
22 #include <ditto/instruction.h>
23 
24 namespace dittosuite {
25 
26 class InstructionSet : public Instruction {
27  public:
28   inline static const std::string kName = "instruction_set";
29 
30   explicit InstructionSet(const Params& params,
31                           std::vector<std::unique_ptr<Instruction>> instructions, int list_key,
32                           int item_key, Order order, Reseeding reseeding, uint32_t seed);
33   explicit InstructionSet(const Params& params,
34                           std::vector<std::unique_ptr<Instruction>> instructions);
35 
36   std::unique_ptr<Result> CollectResults(const std::string& prefix) override;
37 
38  private:
39   void SetUp() override;
40   void SetUpSingle() override;
41   void RunSingle() override;
42   void RunInstructions();
43 
44   std::vector<std::unique_ptr<Instruction>> instructions_;
45   int list_key_;
46   int item_key_;
47   Order access_order_;
48   Reseeding reseeding_;
49   uint32_t seed_;
50   std::mt19937_64 gen_;
51 };
52 
53 }  // namespace dittosuite
54