blob: ae37426f5161a22b48a7153d6481eeb2899b9e36 [file] [log] [blame]
San Mehatdc266072009-05-06 11:16:52 -07001/*
2 * Copyright (C) 2008 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#ifndef _CONTROLLER_H
17#define _CONTROLLER_H
18
San Mehat48765672009-05-20 15:28:43 -070019#include <unistd.h>
20#include <sys/types.h>
21
San Mehatdc266072009-05-06 11:16:52 -070022#include "../../../frameworks/base/include/utils/List.h"
23
San Mehat48765672009-05-20 15:28:43 -070024#include "PropertyCollection.h"
25
San Mehatdc266072009-05-06 11:16:52 -070026class Controller {
27private:
28 const char *mName;
San Mehat48765672009-05-20 15:28:43 -070029 const char *mPropertyPrefix;
30 PropertyCollection *mProperties;
31 bool mEnabled;
San Mehatdc266072009-05-06 11:16:52 -070032
33public:
San Mehat48765672009-05-20 15:28:43 -070034 Controller(const char *name, const char *prefix);
San Mehatdc266072009-05-06 11:16:52 -070035 virtual ~Controller() {}
36
37 virtual int start();
38 virtual int stop();
39
San Mehat48765672009-05-20 15:28:43 -070040 virtual const PropertyCollection &getProperties();
41 virtual int setProperty(const char *name, char *value);
42 virtual const char *getProperty(const char *name, char *buffer, size_t maxsize);
San Mehatdc266072009-05-06 11:16:52 -070043
San Mehat48765672009-05-20 15:28:43 -070044 const char *getName() { return mName; }
45 const char *getPropertyPrefix() { return mPropertyPrefix; }
San Mehatdc266072009-05-06 11:16:52 -070046
47protected:
48 int loadKernelModule(char *modpath, const char *args);
49 bool isKernelModuleLoaded(const char *modtag);
50 int unloadKernelModule(const char *modtag);
51
San Mehat48765672009-05-20 15:28:43 -070052 int registerProperty(const char *name);
53 int unregisterProperty(const char *name);
54
San Mehatdc266072009-05-06 11:16:52 -070055private:
56 void *loadFile(char *filename, unsigned int *_size);
San Mehat48765672009-05-20 15:28:43 -070057
58 virtual int enable() = 0;
59 virtual int disable() = 0;
60
San Mehatdc266072009-05-06 11:16:52 -070061};
62
63typedef android::List<Controller *> ControllerCollection;
64#endif