blob: 10d0b2aa9a05b2063deefb172f4ab839776abda4 [file] [log] [blame]
San Mehat3c5a6f02009-05-22 15:36:13 -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
17#ifndef _PROPERTY_MANAGER_H
18#define _PROPERTY_MANAGER_H
19
20#include <errno.h>
21#include <pthread.h>
22
23#include <utils/List.h>
24
25#include "IPropertyProvider.h"
26
27class PropertyPair {
28private:
29 char *mName;
30 IPropertyProvider *mPp;
31
32public:
33 PropertyPair(const char *name, IPropertyProvider *pp);
34 virtual ~PropertyPair();
35
36 const char *getName() { return mName; }
37 IPropertyProvider *getProvider() { return mPp; }
38};
39
40typedef android::List<PropertyPair *> PropertyPairCollection;
41
42class PropertyManager {
43 PropertyPairCollection *mPropertyPairs;
44 pthread_mutex_t mLock;
45
46public:
47 PropertyManager();
48 virtual ~PropertyManager();
49 int registerProperty(const char *name, IPropertyProvider *pp);
50 int unregisterProperty(const char *name);
51 android::List<char *> *createPropertyList();
52
53 int set(const char *name, const char *value);
54 const char *get(const char *name, char *buffer, size_t max);
55};
56
57#endif