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 <list> 18 #include <string> 19 20 #include <ditto/instruction.h> 21 #include <ditto/instruction_set.h> 22 #include <ditto/read_write_file.h> 23 24 #include <benchmark.pb.h> 25 26 namespace dittosuite { 27 28 class InstructionFactory { 29 public: 30 static std::unique_ptr<InstructionSet> CreateFromProtoInstructionSet( 31 const dittosuite::Instruction::Params& params, const std::list<int>& thread_ids, 32 const dittosuiteproto::InstructionSet& proto_instruction_set); 33 static std::unique_ptr<Instruction> CreateFromProtoInstruction( 34 const std::list<int>& thread_ids, const dittosuiteproto::Instruction& proto_instruction); 35 static int GenerateThreadId(); 36 37 private: 38 InstructionFactory(); 39 40 static Reseeding ConvertReseeding(dittosuiteproto::Reseeding proto_reseeding); 41 static Order ConvertOrder(dittosuiteproto::Order proto_order); 42 static int ConvertReadFAdvise(Order access_order, 43 dittosuiteproto::ReadFile_ReadFAdvise proto_fadvise); 44 static FreePolicy ConvertFreePolicy(const dittosuiteproto::FreePolicy proto_policy); 45 46 static int current_thread_id_; 47 }; 48 49 } // namespace dittosuite 50