Andreas Huber | 5345ec2 | 2016-07-29 13:33:27 -0700 | [diff] [blame] | 1 | #ifndef COORDINATOR_H_ |
| 2 | |
| 3 | #define COORDINATOR_H_ |
| 4 | |
| 5 | #include <android-base/macros.h> |
Andreas Huber | e61e3f7 | 2016-08-03 10:22:03 -0700 | [diff] [blame^] | 6 | #include <functional> |
Andreas Huber | 5345ec2 | 2016-07-29 13:33:27 -0700 | [diff] [blame] | 7 | #include <string> |
| 8 | #include <utils/KeyedVector.h> |
| 9 | |
| 10 | namespace android { |
| 11 | |
| 12 | struct AST; |
| 13 | struct FQName; |
Andreas Huber | 0e00de4 | 2016-08-03 09:56:02 -0700 | [diff] [blame] | 14 | struct RefType; |
Andreas Huber | 5345ec2 | 2016-07-29 13:33:27 -0700 | [diff] [blame] | 15 | |
| 16 | struct Coordinator { |
Andreas Huber | dc98133 | 2016-07-29 15:46:54 -0700 | [diff] [blame] | 17 | Coordinator(const std::string &interfacesPath); |
Andreas Huber | 5345ec2 | 2016-07-29 13:33:27 -0700 | [diff] [blame] | 18 | ~Coordinator(); |
| 19 | |
Andreas Huber | 68f2459 | 2016-07-29 14:53:48 -0700 | [diff] [blame] | 20 | AST *parse(const FQName &fqName); |
Andreas Huber | 5345ec2 | 2016-07-29 13:33:27 -0700 | [diff] [blame] | 21 | |
Andreas Huber | 0e00de4 | 2016-08-03 09:56:02 -0700 | [diff] [blame] | 22 | RefType *lookupType(const FQName &fqName) const; |
Andreas Huber | 5345ec2 | 2016-07-29 13:33:27 -0700 | [diff] [blame] | 23 | |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 24 | std::string getPackagePath( |
| 25 | const FQName &fqName, bool relative = false) const; |
Andreas Huber | 5345ec2 | 2016-07-29 13:33:27 -0700 | [diff] [blame] | 26 | |
Andreas Huber | e61e3f7 | 2016-08-03 10:22:03 -0700 | [diff] [blame^] | 27 | // 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 Huber | 5345ec2 | 2016-07-29 13:33:27 -0700 | [diff] [blame] | 31 | private: |
Andreas Huber | dc98133 | 2016-07-29 15:46:54 -0700 | [diff] [blame] | 32 | std::string mInterfacesPath; |
Andreas Huber | 68f2459 | 2016-07-29 14:53:48 -0700 | [diff] [blame] | 33 | KeyedVector<FQName, AST *> mCache; |
Andreas Huber | 5345ec2 | 2016-07-29 13:33:27 -0700 | [diff] [blame] | 34 | |
| 35 | DISALLOW_COPY_AND_ASSIGN(Coordinator); |
| 36 | }; |
| 37 | |
| 38 | } // namespace android |
| 39 | |
| 40 | #endif // COORDINATOR_H_ |