1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: typemanager.hxx,v $
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 ************************************************************************/
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
48 typedef ::std::hash_map
50 ::rtl::OString
, // Typename
51 RTTypeClass
, // TypeClass
57 struct TypeManagerImpl
70 virtual ~TypeManager();
72 TypeManager( const TypeManager
& value
)
73 : m_pImpl( value
.m_pImpl
)
78 TypeManager
& operator = ( const TypeManager
& value
)
81 m_pImpl
= value
.m_pImpl
;
86 virtual sal_Bool
init(sal_Bool
/*bMerge*/, const StringVector
& /*regFiles*/)
88 virtual sal_Bool
init(const ::rtl::OString
& /*registryName*/)
91 virtual sal_Bool
isValidType(const ::rtl::OString
& /*name*/)
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; }
111 TypeManagerImpl
* m_pImpl
;
114 struct RegistryTypeManagerImpl
116 RegistryTypeManagerImpl()
117 : m_pMergedRegistry(NULL
)
119 , m_isMerged(sal_False
)
122 T2TypeClassMap m_t2TypeClass
;
123 RegistryList m_registries
;
124 Registry
* m_pMergedRegistry
;
125 ::rtl::OString m_base
;
129 class RegistryTypeManager
: public TypeManager
132 RegistryTypeManager();
133 virtual ~RegistryTypeManager();
135 RegistryTypeManager( const RegistryTypeManager
& value
)
137 , m_pImpl( value
.m_pImpl
)
142 RegistryTypeManager& operator = ( const RegistryTypeManager& value )
145 m_pImpl = value.m_pImpl;
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(); }
165 RegistryKey
searchTypeKey(const ::rtl::OString
& name
);
166 void freeRegistries();
172 RegistryTypeManagerImpl
* m_pImpl
;
175 #endif // _CODEMAKER_TYPEMANAGER_HXX_