San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 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 | |
San Mehat | c4a895b | 2009-06-23 21:10:57 -0700 | [diff] [blame^] | 25 | #include "Property.h" |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 26 | |
| 27 | class PropertyManager { |
San Mehat | c4a895b | 2009-06-23 21:10:57 -0700 | [diff] [blame^] | 28 | PropertyNamespaceCollection *mNamespaces; |
| 29 | pthread_mutex_t mLock; |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 30 | |
| 31 | public: |
| 32 | PropertyManager(); |
San Mehat | c4a895b | 2009-06-23 21:10:57 -0700 | [diff] [blame^] | 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); |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 38 | |
| 39 | int set(const char *name, const char *value); |
| 40 | const char *get(const char *name, char *buffer, size_t max); |
San Mehat | c4a895b | 2009-06-23 21:10:57 -0700 | [diff] [blame^] | 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); |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | #endif |