blob: bd7bce0ffe8ad5cebc31c961d936427903e44ab3 [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>
24#include "../Formatter.h"
25
26namespace android {
27
28struct AST;
29
30struct Declaration {
31 Declaration(const std::string &name);
32 virtual ~Declaration();
33
34 const std::string &getName() const;
35 void setName(const std::string &name);
36
37 const std::string& getComment() const;
38 void setComment(const std::string &comment);
39
40 std::string getInterfaceName() const;
41
42 void generateCommentText(Formatter &out) const;
43
44 virtual const std::string decType() const = 0;
45
46 /* for example "int test;" */
47 virtual void generateSource(Formatter &out) const = 0;
48
49 /* for example "int test" in fun(int test, float jeff) */
50 virtual void generateParameterSource(Formatter &out) const;
51
52 virtual void processContents(AST &ast) = 0;
53
54private:
55 std::string mName;
56 std::string mComment;
57
58 DISALLOW_COPY_AND_ASSIGN(Declaration);
59};
60
61} // namespace android
62
63#endif // DECLARATION_H_