Home | History | Annotate | Download | only in logd
      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 // See main.cpp for implementation
     27 void reinit_signal_handler(int /*signal*/);
     28 
     29 class CommandListener : public FrameworkListener {
     30     LogBuffer &mBuf;
     31 
     32 public:
     33     CommandListener(LogBuffer *buf, LogReader *reader, LogListener *swl);
     34     virtual ~CommandListener() {}
     35 
     36 private:
     37     static int getLogSocket();
     38 
     39     class ShutdownCmd : public LogCommand {
     40         LogBuffer &mBuf;
     41         LogReader &mReader;
     42         LogListener &mSwl;
     43 
     44     public:
     45         ShutdownCmd(LogBuffer *buf, LogReader *reader, LogListener *swl);
     46         virtual ~ShutdownCmd() {}
     47         int runCommand(SocketClient *c, int argc, char ** argv);
     48     };
     49 
     50 #define LogBufferCmd(name)                                       \
     51     class name##Cmd : public LogCommand {                        \
     52         LogBuffer &mBuf;                                         \
     53     public:                                                      \
     54         name##Cmd(LogBuffer *buf);                               \
     55         virtual ~name##Cmd() {}                                  \
     56         int runCommand(SocketClient *c, int argc, char ** argv); \
     57     };
     58 
     59     LogBufferCmd(Clear)
     60     LogBufferCmd(GetBufSize)
     61     LogBufferCmd(SetBufSize)
     62     LogBufferCmd(GetBufSizeUsed)
     63     LogBufferCmd(GetStatistics)
     64     LogBufferCmd(GetPruneList)
     65     LogBufferCmd(SetPruneList)
     66 
     67     class ReinitCmd : public LogCommand {
     68     public:
     69         ReinitCmd();
     70         virtual ~ReinitCmd() {}
     71         int runCommand(SocketClient *c, int argc, char ** argv);
     72     };
     73 
     74 };
     75 
     76 #endif
     77