• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifdef __ANDROID__
25 #include <benchmark.pb.h>
26 #else
27 #include "schema/benchmark.pb.h"
28 #endif
29 
30 namespace dittosuite {
31 
32 class InstructionFactory {
33  public:
34   static std::unique_ptr<InstructionSet> CreateFromProtoInstructionSet(
35       const std::list<int>& thread_ids, int repeat,
36       const dittosuiteproto::InstructionSet& proto_instruction_set);
37   static std::unique_ptr<Instruction> CreateFromProtoInstruction(
38       const std::list<int>& thread_ids, const dittosuiteproto::Instruction& proto_instruction);
39   static int GenerateThreadId();
40 
41  private:
42   InstructionFactory();
43 
44   static Reseeding ConvertReseeding(dittosuiteproto::Reseeding proto_reseeding);
45   static Order ConvertOrder(dittosuiteproto::Order proto_order);
46   static int ConvertReadFAdvise(Order access_order,
47                                 dittosuiteproto::ReadFile_ReadFAdvise proto_fadvise);
48 
49   static int current_thread_id_;
50 };
51 
52 }  // namespace dittosuite
53