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 26 class CommandListener : public FrameworkListener { 27 LogBuffer &mBuf; 28 29 public: 30 CommandListener(LogBuffer *buf, LogReader *reader, LogListener *swl); 31 virtual ~CommandListener() {} 32 33 private: 34 static int getLogSocket(); 35 36 class ShutdownCmd : public LogCommand { 37 LogBuffer &mBuf; 38 LogReader &mReader; 39 LogListener &mSwl; 40 41 public: 42 ShutdownCmd(LogBuffer *buf, LogReader *reader, LogListener *swl); 43 virtual ~ShutdownCmd() {} 44 int runCommand(SocketClient *c, int argc, char ** argv); 45 }; 46 47 #define LogBufferCmd(name) \ 48 class name##Cmd : public LogCommand { \ 49 LogBuffer &mBuf; \ 50 public: \ 51 name##Cmd(LogBuffer *buf); \ 52 virtual ~name##Cmd() {} \ 53 int runCommand(SocketClient *c, int argc, char ** argv); \ 54 }; 55 56 LogBufferCmd(Clear) 57 LogBufferCmd(GetBufSize) 58 LogBufferCmd(SetBufSize) 59 LogBufferCmd(GetBufSizeUsed) 60 LogBufferCmd(GetStatistics) 61 LogBufferCmd(GetPruneList) 62 LogBufferCmd(SetPruneList) 63 }; 64 65 #endif 66