blob: 1c764414537adda95f07baa78ca7abf71fe58553 [file] [log] [blame]
Steven Morelandf1a35f72016-08-17 08:41:49 -07001/*
2 * Copyright (C) 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 DECLARATION_H_
18#define DECLARATION_H_
19
20#include <android-base/macros.h>
21#include <android-base/logging.h>
22#include <string>
23#include <vector>
Iliyan Malcheva72e0d22016-09-09 11:03:08 -070024#include <hidl-util/Formatter.h>
Steven Morelandf1a35f72016-08-17 08:41:49 -070025
26namespace android {
27
28struct AST;
29
30struct Declaration {
31 Declaration(const std::string &name);
32 virtual ~Declaration();
33
34 const std::string &getName() const;
Steven Moreland95b46232016-09-20 14:46:55 -070035 virtual void setName(const std::string &name);
36
37 void forceCamelCase();
38 void forcePascalCase();
Steven Morelandf1a35f72016-08-17 08:41:49 -070039
40 const std::string& getComment() const;
41 void setComment(const std::string &comment);
42
43 std::string getInterfaceName() const;
44
45 void generateCommentText(Formatter &out) const;
46
47 virtual const std::string decType() const = 0;
48
49 /* for example "int test;" */
50 virtual void generateSource(Formatter &out) const = 0;
51
52 /* for example "int test" in fun(int test, float jeff) */
53 virtual void generateParameterSource(Formatter &out) const;
54
55 virtual void processContents(AST &ast) = 0;
56
57private:
58 std::string mName;
59 std::string mComment;
60
61 DISALLOW_COPY_AND_ASSIGN(Declaration);
62};
63
64} // namespace android
65
66#endif // DECLARATION_H_