blob: bc749325efda10ff00aaa6e11a4b15c3a791f706 [file] [log] [blame]
Andreas Huber5345ec22016-07-29 13:33:27 -07001#ifndef COORDINATOR_H_
2
3#define COORDINATOR_H_
4
5#include <android-base/macros.h>
Andreas Hubere61e3f72016-08-03 10:22:03 -07006#include <functional>
Andreas Huber5345ec22016-07-29 13:33:27 -07007#include <string>
8#include <utils/KeyedVector.h>
9
10namespace android {
11
12struct AST;
13struct FQName;
Andreas Huber0e00de42016-08-03 09:56:02 -070014struct RefType;
Andreas Huber5345ec22016-07-29 13:33:27 -070015
16struct Coordinator {
Andreas Huberdc981332016-07-29 15:46:54 -070017 Coordinator(const std::string &interfacesPath);
Andreas Huber5345ec22016-07-29 13:33:27 -070018 ~Coordinator();
19
Andreas Huber68f24592016-07-29 14:53:48 -070020 AST *parse(const FQName &fqName);
Andreas Huber5345ec22016-07-29 13:33:27 -070021
Andreas Huber0e00de42016-08-03 09:56:02 -070022 RefType *lookupType(const FQName &fqName) const;
Andreas Huber5345ec22016-07-29 13:33:27 -070023
Andreas Huber881227d2016-08-02 14:20:21 -070024 std::string getPackagePath(
25 const FQName &fqName, bool relative = false) const;
Andreas Huber5345ec22016-07-29 13:33:27 -070026
Andreas Hubere61e3f72016-08-03 10:22:03 -070027 // Iterate over all cached ASTs and abort if any callback returns an error.
28 using for_each_cb = std::function<status_t(const AST *ast)>;
29 status_t forEachAST(for_each_cb cb) const;
30
Andreas Huber5345ec22016-07-29 13:33:27 -070031private:
Andreas Huberdc981332016-07-29 15:46:54 -070032 std::string mInterfacesPath;
Andreas Huber68f24592016-07-29 14:53:48 -070033 KeyedVector<FQName, AST *> mCache;
Andreas Huber5345ec22016-07-29 13:33:27 -070034
35 DISALLOW_COPY_AND_ASSIGN(Coordinator);
36};
37
38} // namespace android
39
40#endif // COORDINATOR_H_