1 /*
2  * Copyright 2016 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 #ifndef VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_PROFILER_HALHIDLPROFILERCODEGEN_H_
18 #define VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_PROFILER_HALHIDLPROFILERCODEGEN_H_
19 
20 #include "code_gen/profiler/ProfilerCodeGenBase.h"
21 
22 namespace android {
23 namespace vts {
24 /**
25  * Class that generates the profiler code for Hidl HAL.
26  */
27 class HalHidlProfilerCodeGen : public ProfilerCodeGenBase {
28  public:
HalHidlProfilerCodeGen()29   HalHidlProfilerCodeGen() : ProfilerCodeGenBase(){};
30 
31  protected:
32   virtual void GenerateProfilerForScalarVariable(Formatter& out,
33     const VariableSpecificationMessage& val, const std::string& arg_name,
34     const std::string& arg_value) override;
35 
36   virtual void GenerateProfilerForStringVariable(Formatter& out,
37     const VariableSpecificationMessage& val, const std::string& arg_name,
38     const std::string& arg_value) override;
39 
40   virtual void GenerateProfilerForEnumVariable(Formatter& out,
41     const VariableSpecificationMessage& val, const std::string& arg_name,
42     const std::string& arg_value) override;
43 
44   virtual void GenerateProfilerForVectorVariable(Formatter& out,
45     const VariableSpecificationMessage& val, const std::string& arg_name,
46     const std::string& arg_value) override;
47 
48   virtual void GenerateProfilerForArrayVariable(Formatter& out,
49     const VariableSpecificationMessage& val, const std::string& arg_name,
50     const std::string& arg_value) override;
51 
52   virtual void GenerateProfilerForStructVariable(Formatter& out,
53     const VariableSpecificationMessage& val, const std::string& arg_name,
54     const std::string& arg_value) override;
55 
56   virtual void GenerateProfilerForUnionVariable(Formatter& out,
57     const VariableSpecificationMessage& val, const std::string& arg_name,
58     const std::string& arg_value) override;
59 
60   virtual void GenerateProfilerForSafeUnionVariable(
61       Formatter& out, const VariableSpecificationMessage& val,
62       const std::string& arg_name, const std::string& arg_value) override;
63 
64   virtual void GenerateProfilerForHidlCallbackVariable(Formatter& out,
65     const VariableSpecificationMessage& val, const std::string& arg_name,
66     const std::string& arg_value) override;
67 
68   virtual void GenerateProfilerForHidlInterfaceVariable(Formatter& out,
69       const VariableSpecificationMessage& val, const std::string& arg_name,
70       const std::string& arg_value) override;
71 
72   virtual void GenerateProfilerForMaskVariable(Formatter& out,
73       const VariableSpecificationMessage& val, const std::string& arg_name,
74       const std::string& arg_value) override;
75 
76   virtual void GenerateProfilerForHandleVariable(
77       Formatter& out, const VariableSpecificationMessage& val,
78       const std::string& arg_name, const std::string& arg_value) override;
79 
80   virtual void GenerateProfilerForHidlMemoryVariable(Formatter& out,
81       const VariableSpecificationMessage& val, const std::string& arg_name,
82       const std::string& arg_value) override;
83 
84   virtual void GenerateProfilerForPointerVariable(Formatter& out,
85       const VariableSpecificationMessage& val, const std::string& arg_name,
86       const std::string& arg_value) override;
87 
88   virtual void GenerateProfilerForFMQSyncVariable(Formatter& out,
89       const VariableSpecificationMessage& val, const std::string& arg_name,
90       const std::string& arg_value) override;
91 
92   virtual void GenerateProfilerForFMQUnsyncVariable(Formatter& out,
93       const VariableSpecificationMessage& val, const std::string& arg_name,
94       const std::string& arg_value) override;
95 
96   virtual void GenerateProfilerForMethod(Formatter& out,
97     const FunctionSpecificationMessage& method) override;
98 
99   virtual void GenerateHeaderIncludeFiles(Formatter& out,
100     const ComponentSpecificationMessage& message) override;
101   virtual void GenerateSourceIncludeFiles(Formatter& out,
102     const ComponentSpecificationMessage& message) override;
103   void GenerateUsingDeclaration(Formatter& out,
104     const ComponentSpecificationMessage& message) override;
105   void GenerateMacros(Formatter& out,
106     const ComponentSpecificationMessage& message) override;
107   virtual void GenerateProfilerCheck(
108       Formatter& out, const ComponentSpecificationMessage& message) override;
109   virtual void GenerateLocalVariableDefinition(Formatter& out,
110     const ComponentSpecificationMessage& message) override;
111 
112  private:
113   DISALLOW_COPY_AND_ASSIGN (HalHidlProfilerCodeGen);
114 };
115 
116 }  // namespace vts
117 }  // namespace android
118 #endif  // VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_PROFILER_HALHIDLPROFILERCODEGEN_H_
119