xref: /aosp_15_r20/test/dittosuite/include/ditto/instruction_factory.h (revision 6fa2df46f119dce7527f5beb2814eca0e6f886ac)
1*6fa2df46SAndroid Build Coastguard Worker // Copyright (C) 2021 The Android Open Source Project
2*6fa2df46SAndroid Build Coastguard Worker //
3*6fa2df46SAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License");
4*6fa2df46SAndroid Build Coastguard Worker // you may not use this file except in compliance with the License.
5*6fa2df46SAndroid Build Coastguard Worker // You may obtain a copy of the License at
6*6fa2df46SAndroid Build Coastguard Worker //
7*6fa2df46SAndroid Build Coastguard Worker //      http://www.apache.org/licenses/LICENSE-2.0
8*6fa2df46SAndroid Build Coastguard Worker //
9*6fa2df46SAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software
10*6fa2df46SAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS,
11*6fa2df46SAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*6fa2df46SAndroid Build Coastguard Worker // See the License for the specific language governing permissions and
13*6fa2df46SAndroid Build Coastguard Worker // limitations under the License.
14*6fa2df46SAndroid Build Coastguard Worker 
15*6fa2df46SAndroid Build Coastguard Worker #pragma once
16*6fa2df46SAndroid Build Coastguard Worker 
17*6fa2df46SAndroid Build Coastguard Worker #include <list>
18*6fa2df46SAndroid Build Coastguard Worker #include <string>
19*6fa2df46SAndroid Build Coastguard Worker 
20*6fa2df46SAndroid Build Coastguard Worker #include <ditto/instruction.h>
21*6fa2df46SAndroid Build Coastguard Worker #include <ditto/instruction_set.h>
22*6fa2df46SAndroid Build Coastguard Worker #include <ditto/read_write_file.h>
23*6fa2df46SAndroid Build Coastguard Worker 
24*6fa2df46SAndroid Build Coastguard Worker #include <benchmark.pb.h>
25*6fa2df46SAndroid Build Coastguard Worker 
26*6fa2df46SAndroid Build Coastguard Worker namespace dittosuite {
27*6fa2df46SAndroid Build Coastguard Worker 
28*6fa2df46SAndroid Build Coastguard Worker class InstructionFactory {
29*6fa2df46SAndroid Build Coastguard Worker  public:
30*6fa2df46SAndroid Build Coastguard Worker   static std::unique_ptr<InstructionSet> CreateFromProtoInstructionSet(
31*6fa2df46SAndroid Build Coastguard Worker       const dittosuite::Instruction::Params& params, const std::list<int>& thread_ids,
32*6fa2df46SAndroid Build Coastguard Worker       const dittosuiteproto::InstructionSet& proto_instruction_set);
33*6fa2df46SAndroid Build Coastguard Worker   static std::unique_ptr<Instruction> CreateFromProtoInstruction(
34*6fa2df46SAndroid Build Coastguard Worker       const std::list<int>& thread_ids, const dittosuiteproto::Instruction& proto_instruction);
35*6fa2df46SAndroid Build Coastguard Worker   static int GenerateThreadId();
36*6fa2df46SAndroid Build Coastguard Worker 
37*6fa2df46SAndroid Build Coastguard Worker  private:
38*6fa2df46SAndroid Build Coastguard Worker   InstructionFactory();
39*6fa2df46SAndroid Build Coastguard Worker 
40*6fa2df46SAndroid Build Coastguard Worker   static Reseeding ConvertReseeding(dittosuiteproto::Reseeding proto_reseeding);
41*6fa2df46SAndroid Build Coastguard Worker   static Order ConvertOrder(dittosuiteproto::Order proto_order);
42*6fa2df46SAndroid Build Coastguard Worker   static int ConvertReadFAdvise(Order access_order,
43*6fa2df46SAndroid Build Coastguard Worker                                 dittosuiteproto::ReadFile_ReadFAdvise proto_fadvise);
44*6fa2df46SAndroid Build Coastguard Worker   static FreePolicy ConvertFreePolicy(const dittosuiteproto::FreePolicy proto_policy);
45*6fa2df46SAndroid Build Coastguard Worker 
46*6fa2df46SAndroid Build Coastguard Worker   static int current_thread_id_;
47*6fa2df46SAndroid Build Coastguard Worker };
48*6fa2df46SAndroid Build Coastguard Worker 
49*6fa2df46SAndroid Build Coastguard Worker }  // namespace dittosuite
50