merge the formfield patch from ooo-build
[ooovba.git] / rdbmaker / inc / codemaker / typemanager.hxx
blob08a73ce5e28dd114214fe6fd272b9ea03d8a3325
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: typemanager.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include <hash_map>
32 #ifndef _CODEMAKER_TYPEMANAGER_HXX_
33 #define _CODEMAKER_TYPEMANAGER_HXX_
34 #include <codemaker/registry.hxx>
36 typedef ::std::list< Registry* > RegistryList;
38 #if defined( _MSC_VER ) && ( _MSC_VER < 1200 )
39 typedef ::std::__hash_map__
41 ::rtl::OString, // Typename
42 RTTypeClass, // TypeClass
43 HashString,
44 EqualString,
45 NewAlloc
46 > T2TypeClassMap;
47 #else
48 typedef ::std::hash_map
50 ::rtl::OString, // Typename
51 RTTypeClass, // TypeClass
52 HashString,
53 EqualString
54 > T2TypeClassMap;
55 #endif
57 struct TypeManagerImpl
59 TypeManagerImpl()
60 : m_refCount(0)
63 sal_Int32 m_refCount;
64 };
66 class TypeManager
68 public:
69 TypeManager();
70 virtual ~TypeManager();
72 TypeManager( const TypeManager& value )
73 : m_pImpl( value.m_pImpl )
75 acquire();
78 TypeManager& operator = ( const TypeManager& value )
80 release();
81 m_pImpl = value.m_pImpl;
82 acquire();
83 return *this;
86 virtual sal_Bool init(sal_Bool /*bMerge*/, const StringVector& /*regFiles*/)
87 { return sal_False; }
88 virtual sal_Bool init(const ::rtl::OString& /*registryName*/)
89 { return sal_False; }
91 virtual sal_Bool isValidType(const ::rtl::OString& /*name*/)
92 { return sal_False; }
94 virtual RegistryKey getTypeKey(const ::rtl::OString& /*name*/)
95 { return RegistryKey(); }
96 virtual TypeReader getTypeReader(const ::rtl::OString& /*name*/)
97 { return TypeReader(); }
98 virtual RTTypeClass getTypeClass(const ::rtl::OString& /*name*/)
99 { return RT_TYPE_INVALID; }
101 virtual void setBase(const ::rtl::OString& /*base*/) {}
102 virtual ::rtl::OString getBase() { return ::rtl::OString(); }
104 virtual sal_Int32 getSize() { return 0; }
106 protected:
107 sal_Int32 acquire();
108 sal_Int32 release();
110 protected:
111 TypeManagerImpl* m_pImpl;
114 struct RegistryTypeManagerImpl
116 RegistryTypeManagerImpl()
117 : m_pMergedRegistry(NULL)
118 , m_base("/")
119 , m_isMerged(sal_False)
122 T2TypeClassMap m_t2TypeClass;
123 RegistryList m_registries;
124 Registry* m_pMergedRegistry;
125 ::rtl::OString m_base;
126 sal_Bool m_isMerged;
129 class RegistryTypeManager : public TypeManager
131 public:
132 RegistryTypeManager();
133 virtual ~RegistryTypeManager();
135 RegistryTypeManager( const RegistryTypeManager& value )
136 : TypeManager(value)
137 , m_pImpl( value.m_pImpl )
139 acquire();
142 RegistryTypeManager& operator = ( const RegistryTypeManager& value )
144 release();
145 m_pImpl = value.m_pImpl;
146 acquire();
147 return *this;
150 using TypeManager::init;
151 sal_Bool init(sal_Bool bMerge, const StringVector& regFiles);
153 sal_Bool isValidType(const ::rtl::OString& name)
154 { return searchTypeKey(name).isValid(); }
155 RegistryKey getTypeKey(const ::rtl::OString& name)
156 { return searchTypeKey(name); }
157 TypeReader getTypeReader(const ::rtl::OString& name);
158 RTTypeClass getTypeClass(const ::rtl::OString& name);
160 void setBase(const ::rtl::OString& base);
161 ::rtl::OString getBase() { return m_pImpl->m_base; }
163 sal_Int32 getSize() { return m_pImpl->m_t2TypeClass.size(); }
164 protected:
165 RegistryKey searchTypeKey(const ::rtl::OString& name);
166 void freeRegistries();
168 void acquire();
169 void release();
171 protected:
172 RegistryTypeManagerImpl* m_pImpl;
175 #endif // _CODEMAKER_TYPEMANAGER_HXX_