Mathias Agopian | 4ea13dc | 2013-05-06 20:20:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 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 | |
Martijn Coenen | f75a23d | 2016-08-01 11:55:17 +0200 | [diff] [blame] | 17 | #ifndef ANDROID_HARDWARE_BUFFEREDTEXTOUTPUT_H |
| 18 | #define ANDROID_HARDWARE_BUFFEREDTEXTOUTPUT_H |
Mathias Agopian | 4ea13dc | 2013-05-06 20:20:50 -0700 | [diff] [blame] | 19 | |
Steven Moreland | 507238e | 2020-07-14 22:12:20 +0000 | [diff] [blame] | 20 | #include "TextOutput.h" |
| 21 | |
Mathias Agopian | 4ea13dc | 2013-05-06 20:20:50 -0700 | [diff] [blame] | 22 | #include <utils/threads.h> |
Colin Cross | dbe88e3 | 2013-07-23 14:52:34 -0700 | [diff] [blame] | 23 | #include <sys/uio.h> |
Mathias Agopian | 4ea13dc | 2013-05-06 20:20:50 -0700 | [diff] [blame] | 24 | |
| 25 | // --------------------------------------------------------------------------- |
| 26 | namespace android { |
Martijn Coenen | f75a23d | 2016-08-01 11:55:17 +0200 | [diff] [blame] | 27 | namespace hardware { |
Mathias Agopian | 4ea13dc | 2013-05-06 20:20:50 -0700 | [diff] [blame] | 28 | |
| 29 | class BufferedTextOutput : public TextOutput |
| 30 | { |
| 31 | public: |
| 32 | //** Flags for constructor */ |
| 33 | enum { |
| 34 | MULTITHREADED = 0x0001 |
| 35 | }; |
| 36 | |
Chih-Hung Hsieh | 6b684f4 | 2018-12-20 15:42:22 -0800 | [diff] [blame] | 37 | explicit BufferedTextOutput(uint32_t flags = 0); |
Mathias Agopian | 4ea13dc | 2013-05-06 20:20:50 -0700 | [diff] [blame] | 38 | virtual ~BufferedTextOutput(); |
| 39 | |
| 40 | virtual status_t print(const char* txt, size_t len); |
| 41 | virtual void moveIndent(int delta); |
| 42 | |
| 43 | virtual void pushBundle(); |
| 44 | virtual void popBundle(); |
| 45 | |
| 46 | protected: |
| 47 | virtual status_t writeLines(const struct iovec& vec, size_t N) = 0; |
| 48 | |
| 49 | private: |
| 50 | struct BufferState; |
| 51 | struct ThreadState; |
| 52 | |
Mathias Agopian | 4ea13dc | 2013-05-06 20:20:50 -0700 | [diff] [blame] | 53 | BufferState*getBuffer() const; |
| 54 | |
| 55 | uint32_t mFlags; |
| 56 | const int32_t mSeq; |
| 57 | const int32_t mIndex; |
| 58 | |
| 59 | Mutex mLock; |
| 60 | BufferState* mGlobalState; |
| 61 | }; |
| 62 | |
| 63 | // --------------------------------------------------------------------------- |
Steven Moreland | 7173a4c | 2019-09-26 15:55:02 -0700 | [diff] [blame] | 64 | } // namespace hardware |
| 65 | } // namespace android |
Mathias Agopian | 4ea13dc | 2013-05-06 20:20:50 -0700 | [diff] [blame] | 66 | |
Martijn Coenen | f75a23d | 2016-08-01 11:55:17 +0200 | [diff] [blame] | 67 | #endif // ANDROID_HARDWARE_BUFFEREDTEXTOUTPUT_H |