blob: cd1c306ba8ed54253f99cb1981c7e4938da1ede2 [file] [log] [blame]
Mark Salyzyn0175b072014-02-26 09:50:16 -08001/*
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
26class CommandListener : public FrameworkListener {
27 LogBuffer &mBuf;
28
29public:
30 CommandListener(LogBuffer *buf, LogReader *reader, LogListener *swl);
31 virtual ~CommandListener() {}
32
33private:
Mark Salyzyndfc47e82014-03-24 10:26:47 -070034 static int getLogSocket();
35
Mark Salyzyn0175b072014-02-26 09:50:16 -080036 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)
Mark Salyzyndfa7a072014-02-11 12:29:31 -080058 LogBufferCmd(SetBufSize)
Mark Salyzyn0175b072014-02-26 09:50:16 -080059 LogBufferCmd(GetBufSizeUsed)
Mark Salyzyn34facab2014-02-06 14:48:50 -080060 LogBufferCmd(GetStatistics)
Mark Salyzyndfa7a072014-02-11 12:29:31 -080061 LogBufferCmd(GetPruneList)
62 LogBufferCmd(SetPruneList)
Mark Salyzyn0175b072014-02-26 09:50:16 -080063};
64
65#endif