1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 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 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 // -*- c++ -*- 19 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 20 21 // Oscl Registry Serv Impl 22 23 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 24 25 /*! \addtogroup osclutil OSCL Util 26 * 27 * @{ 28 */ 29 /*! 30 * \file oscl_registry_serv_impl.h 31 * \brief Server-side implementation of OsclRegistry interfaces. 32 * 33 */ 34 35 36 #ifndef OSCL_REGISTRY_SERV_IMPL_H_INCLUDED 37 #define OSCL_REGISTRY_SERV_IMPL_H_INCLUDED 38 39 #include "oscl_base.h" 40 #include "osclconfig_proc.h" 41 42 #include "oscl_registry_types.h" 43 44 /*! 45 ** OS-independent declarations. 46 */ 47 48 #include "oscl_string.h" 49 #include "oscl_vector.h" 50 #include "oscl_mem.h" 51 52 /*! 53 ** Data for each registered component. 54 */ 55 class OsclComponentRegistryElement 56 { 57 public: 58 OsclComponentRegistryElement(OSCL_String&, OsclComponentFactory); 59 OsclComponentRegistryElement(const OsclComponentRegistryElement&); 60 OsclComponentRegistryElement& operator=(const OsclComponentRegistryElement& src); 61 ~OsclComponentRegistryElement(); 62 63 bool Match(OSCL_String& aStr, bool aExact); 64 65 OSCL_String* iId;//use a pointer here instead of a container for efficiency 66 //since this element is used in an oscl vector. 67 OsclComponentFactory iFactory; 68 uint32 iComponentId; 69 }; 70 71 72 /*! 73 ** Registry 74 */ 75 class OsclComponentRegistryData 76 { 77 public: 78 OsclComponentRegistryElement* Find(OSCL_String&, bool aExact); 79 Oscl_Vector<OsclComponentRegistryElement, OsclMemAllocator> iVec; 80 }; 81 82 /*! 83 ** Thread-safe singleton registry object. 84 */ 85 #include "oscl_mutex.h" 86 class OsclComponentRegistry 87 { 88 public: 89 OsclComponentRegistry(); 90 ~OsclComponentRegistry(); 91 int32 Register(uint32& aId, OSCL_String&, OsclComponentFactory); 92 int32 Unregister(OSCL_String&); 93 int32 Unregister(uint32); 94 OsclComponentFactory FindExact(OSCL_String&); 95 void FindHierarchical(OSCL_String& , Oscl_Vector<OsclRegistryAccessElement, OsclMemAllocator>&); 96 void OpenSession(); 97 void CloseSession(); 98 99 OsclComponentRegistryData iData; 100 OsclMutex iMutex; 101 102 uint32 iComponentIdCounter; 103 104 uint32 iNumSessions; 105 }; 106 107 108 #endif //OSCL_REGISTRY_IMPL_H_INCLUDED 109 /*! @} */ 110 111 112