blob: af56a9c1560d499b9b9e6503921845dd37ec14f0 [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
San Mehatc4a895b2009-06-23 21:10:57 -070025#include "Property.h"
San Mehat3c5a6f02009-05-22 15:36:13 -070026
27class PropertyManager {
San Mehatc4a895b2009-06-23 21:10:57 -070028 PropertyNamespaceCollection *mNamespaces;
29 pthread_mutex_t mLock;
San Mehat3c5a6f02009-05-22 15:36:13 -070030
31public:
32 PropertyManager();
San Mehatc4a895b2009-06-23 21:10:57 -070033 virtual ~PropertyManager();
34 int attachProperty(const char *ns, Property *p);
35 int detachProperty(const char *ns, Property *p);
36
37 android::List<char *> *createPropertyList(const char *prefix);
San Mehat3c5a6f02009-05-22 15:36:13 -070038
39 int set(const char *name, const char *value);
40 const char *get(const char *name, char *buffer, size_t max);
San Mehatc4a895b2009-06-23 21:10:57 -070041
42private:
43 PropertyNamespace *lookupNamespace_UNLOCKED(const char *ns);
44 Property *lookupProperty_UNLOCKED(PropertyNamespace *ns, const char *name);
45 int doSet(Property *p, int idx, const char *value);
46 int doGet(Property *p, int idx, char *buffer, size_t max);
San Mehat3c5a6f02009-05-22 15:36:13 -070047};
48
49#endif