blob: c8042aa7453a13ca2130e274d283bc769046f5ad [file] [log] [blame]
Mathias Agopian4ea13dc2013-05-06 20:20:50 -07001/*
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 Coenenf75a23d2016-08-01 11:55:17 +020017#ifndef ANDROID_HARDWARE_BUFFEREDTEXTOUTPUT_H
18#define ANDROID_HARDWARE_BUFFEREDTEXTOUTPUT_H
Mathias Agopian4ea13dc2013-05-06 20:20:50 -070019
Steven Moreland507238e2020-07-14 22:12:20 +000020#include "TextOutput.h"
21
Mathias Agopian4ea13dc2013-05-06 20:20:50 -070022#include <utils/threads.h>
Colin Crossdbe88e32013-07-23 14:52:34 -070023#include <sys/uio.h>
Mathias Agopian4ea13dc2013-05-06 20:20:50 -070024
25// ---------------------------------------------------------------------------
26namespace android {
Martijn Coenenf75a23d2016-08-01 11:55:17 +020027namespace hardware {
Mathias Agopian4ea13dc2013-05-06 20:20:50 -070028
29class BufferedTextOutput : public TextOutput
30{
31public:
32 //** Flags for constructor */
33 enum {
34 MULTITHREADED = 0x0001
35 };
36
Chih-Hung Hsieh6b684f42018-12-20 15:42:22 -080037 explicit BufferedTextOutput(uint32_t flags = 0);
Mathias Agopian4ea13dc2013-05-06 20:20:50 -070038 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
46protected:
47 virtual status_t writeLines(const struct iovec& vec, size_t N) = 0;
48
49private:
50 struct BufferState;
51 struct ThreadState;
52
Mathias Agopian4ea13dc2013-05-06 20:20:50 -070053 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 Moreland7173a4c2019-09-26 15:55:02 -070064} // namespace hardware
65} // namespace android
Mathias Agopian4ea13dc2013-05-06 20:20:50 -070066
Martijn Coenenf75a23d2016-08-01 11:55:17 +020067#endif // ANDROID_HARDWARE_BUFFEREDTEXTOUTPUT_H