Scope.h revision 85eabdbe56720dcdcf130e5ca83129d47b143768
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(const char *localName);
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
35    status_t emitJavaTypeDeclarations(
36            Formatter &out, bool atTopLevel) const override;
37
38    status_t emitTypeDefinitions(
39            Formatter &out, const std::string prefix) const override;
40
41    const std::vector<Type *> &getSubTypes() const;
42
43    status_t emitVtsTypeDeclarations(Formatter &out) const override;
44
45    bool isJavaCompatible() const override;
46
47    size_t countTypes() const;
48    const Type *typeAt(size_t index, std::string *name) const;
49
50private:
51    std::vector<Type *> mTypes;
52    KeyedVector<std::string, size_t> mTypeIndexByName;
53
54    DISALLOW_COPY_AND_ASSIGN(Scope);
55};
56
57}  // namespace android
58
59#endif  // SCOPE_H_
60
61