Scope.h revision 39fa71827738f6c1340e4523946fe9bf704eef3a
1#ifndef SCOPE_H_
2
3#define SCOPE_H_
4
5#include "NamedType.h"
6
7#include <utils/KeyedVector.h>
8#include <vector>
9
10namespace android {
11
12struct Formatter;
13struct Interface;
14
15struct Scope : public NamedType {
16    Scope();
17
18    bool addType(const char *localName, Type *type, std::string *errorMsg);
19
20    Type *lookupType(const char *name) const;
21
22    bool isScope() const override;
23
24    // Returns the single interface or NULL.
25    Interface *getInterface() const;
26
27    bool containsSingleInterface(std::string *ifaceName) const;
28
29    std::string pickUniqueAnonymousName() const;
30
31    std::string getJavaType() const override;
32
33    status_t emitTypeDeclarations(Formatter &out) const override;
34    status_t emitJavaTypeDeclarations(Formatter &out) const override;
35
36    status_t emitTypeDefinitions(
37            Formatter &out, const std::string prefix) const override;
38
39    const std::vector<Type *> &getSubTypes() const;
40
41    status_t emitVtsTypeDeclarations(Formatter &out) const override;
42
43    bool isJavaCompatible() const override;
44
45private:
46    std::vector<Type *> mTypes;
47    KeyedVector<std::string, size_t> mTypeIndexByName;
48
49    DISALLOW_COPY_AND_ASSIGN(Scope);
50};
51
52}  // namespace android
53
54#endif  // SCOPE_H_
55
56