Chris Phoenix | dbd9044 | 2016-04-28 16:03:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015, 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 HIDL_IO_DELEGATE_H_ |
| 18 | #define HIDL_IO_DELEGATE_H_ |
| 19 | |
| 20 | // #include <android-base/macros.h> |
| 21 | |
| 22 | #include <memory> |
| 23 | #include <string> |
| 24 | #include <vector> |
| 25 | |
| 26 | #include "code_writer.h" |
| 27 | #include "line_reader.h" |
| 28 | |
| 29 | namespace android { |
| 30 | namespace hidl { |
| 31 | |
| 32 | class IoDelegate { |
| 33 | public: |
| 34 | IoDelegate() = default; |
| 35 | virtual ~IoDelegate() = default; |
| 36 | |
| 37 | // Returns a unique_ptr to the contents of |filename|. |
| 38 | // Will append the optional |content_suffix| to the returned contents. |
| 39 | virtual std::unique_ptr<std::string> GetFileContents( |
| 40 | const std::string& filename, |
| 41 | const std::string& content_suffix = "") const; |
| 42 | |
| 43 | virtual std::unique_ptr<LineReader> GetLineReader( |
| 44 | const std::string& file_path) const; |
| 45 | |
| 46 | virtual bool FileIsReadable(const std::string& path) const; |
| 47 | |
| 48 | virtual bool CreatedNestedDirs( |
| 49 | const std::string& base_dir, |
| 50 | const std::vector<std::string>& nested_subdirs) const; |
| 51 | |
| 52 | bool CreatePathForFile(const std::string& path) const; |
| 53 | |
| 54 | virtual std::unique_ptr<CodeWriter> GetCodeWriter( |
| 55 | const std::string& file_path) const; |
| 56 | |
| 57 | virtual void RemovePath(const std::string& file_path) const; |
| 58 | |
| 59 | private: |
| 60 | DISALLOW_COPY_AND_ASSIGN(IoDelegate); |
| 61 | }; // class IoDelegate |
| 62 | |
| 63 | } // namespace android |
| 64 | } // namespace hidl |
| 65 | |
| 66 | #endif // HIDL_IO_DELEGATE_H_ |