• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 "Property.h"
26 
27 class PropertyManager {
28     PropertyNamespaceCollection *mNamespaces;
29     pthread_mutex_t    mLock;
30 
31 public:
32     PropertyManager();
33     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);
38 
39     int set(const char *name, const char *value);
40     const char *get(const char *name, char *buffer, size_t max);
41 
42 private:
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);
47 };
48 
49 #endif
50