Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012-2014 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 _COMMANDLISTENER_H__ |
| 18 | #define _COMMANDLISTENER_H__ |
| 19 | |
| 20 | #include <sysutils/FrameworkListener.h> |
| 21 | #include "LogCommand.h" |
| 22 | #include "LogBuffer.h" |
| 23 | #include "LogReader.h" |
| 24 | #include "LogListener.h" |
| 25 | |
Mark Salyzyn | 11e55cb | 2015-03-10 16:45:17 -0700 | [diff] [blame] | 26 | // See main.cpp for implementation |
| 27 | void reinit_signal_handler(int /*signal*/); |
| 28 | |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 29 | class CommandListener : public FrameworkListener { |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 30 | |
| 31 | public: |
| 32 | CommandListener(LogBuffer *buf, LogReader *reader, LogListener *swl); |
| 33 | virtual ~CommandListener() {} |
| 34 | |
| 35 | private: |
Mark Salyzyn | dfc47e8 | 2014-03-24 10:26:47 -0700 | [diff] [blame] | 36 | static int getLogSocket(); |
| 37 | |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 38 | class ShutdownCmd : public LogCommand { |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 39 | LogReader &mReader; |
| 40 | LogListener &mSwl; |
| 41 | |
| 42 | public: |
Andreas Gampe | d75564f | 2015-07-27 11:04:37 -0700 | [diff] [blame] | 43 | ShutdownCmd(LogReader *reader, LogListener *swl); |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 44 | virtual ~ShutdownCmd() {} |
| 45 | int runCommand(SocketClient *c, int argc, char ** argv); |
| 46 | }; |
| 47 | |
| 48 | #define LogBufferCmd(name) \ |
| 49 | class name##Cmd : public LogCommand { \ |
| 50 | LogBuffer &mBuf; \ |
| 51 | public: \ |
| 52 | name##Cmd(LogBuffer *buf); \ |
| 53 | virtual ~name##Cmd() {} \ |
| 54 | int runCommand(SocketClient *c, int argc, char ** argv); \ |
| 55 | }; |
| 56 | |
| 57 | LogBufferCmd(Clear) |
| 58 | LogBufferCmd(GetBufSize) |
Mark Salyzyn | dfa7a07 | 2014-02-11 12:29:31 -0800 | [diff] [blame] | 59 | LogBufferCmd(SetBufSize) |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 60 | LogBufferCmd(GetBufSizeUsed) |
Mark Salyzyn | 34facab | 2014-02-06 14:48:50 -0800 | [diff] [blame] | 61 | LogBufferCmd(GetStatistics) |
Mark Salyzyn | dfa7a07 | 2014-02-11 12:29:31 -0800 | [diff] [blame] | 62 | LogBufferCmd(GetPruneList) |
| 63 | LogBufferCmd(SetPruneList) |
Mark Salyzyn | 11e55cb | 2015-03-10 16:45:17 -0700 | [diff] [blame] | 64 | |
| 65 | class ReinitCmd : public LogCommand { |
| 66 | public: |
| 67 | ReinitCmd(); |
| 68 | virtual ~ReinitCmd() {} |
| 69 | int runCommand(SocketClient *c, int argc, char ** argv); |
| 70 | }; |
| 71 | |
Mark Salyzyn | 0175b07 | 2014-02-26 09:50:16 -0800 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | #endif |