merge the formfield patch from ooo-build
[ooovba.git] / rdbmaker / inc / codemaker / dependency.hxx
blob54f9a48e6abced45c238b875b50339f3922433af
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: dependency.hxx,v $
10 * $Revision: 1.5 $
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 ************************************************************************/
31 #ifndef _CODEMAKER_DEPENDENCY_HXX_
32 #define _CODEMAKER_DEPENDENCY_HXX_
34 #include <hash_map>
35 #include <registry/registry.hxx>
36 #ifndef __REGISTRY_REFLREAD_HXX__
37 #include <registry/reflread.hxx>
38 #endif
39 #include <codemaker/typemanager.hxx>
40 #include <codemaker/global.hxx>
41 #include <osl/diagnose.h>
43 #define TYPEUSE_NORMAL 0x0001
44 #define TYPEUSE_SUPER 0x0002
45 #define TYPEUSE_MEMBER 0x0004
46 #define TYPEUSE_INPARAM 0x0008
47 #define TYPEUSE_OUTPARAM 0x0010
48 #define TYPEUSE_INOUTPARAM 0x0020
49 #define TYPEUSE_RETURN 0x0040
50 #define TYPEUSE_EXCEPTION 0x0080
51 #define TYPEUSE_SCOPE 0x0100
53 /**
54 * Flag shows the state of the code generation. If the Flag is set
55 * the code for this type is generated.
57 #define CODEGEN_DEFAULT 0x0001
59 struct TypeUsing
61 TypeUsing(const ::rtl::OString& type, sal_uInt16 use)
62 : m_type(type)
63 , m_use(use)
66 ::rtl::OString m_type;
67 sal_uInt16 m_use;
69 sal_Bool operator == (const TypeUsing & typeUsing) const
71 OSL_ASSERT(0);
72 return m_type == typeUsing.m_type && m_use == typeUsing.m_use;
76 struct LessTypeUsing
78 sal_Bool operator()(const TypeUsing& tuse1, const TypeUsing& tuse2) const
80 return (tuse1.m_type < tuse2.m_type);
84 typedef ::std::set< TypeUsing, LessTypeUsing > TypeUsingSet;
87 #if (defined( _MSC_VER ) && ( _MSC_VER < 1200 ))
88 typedef ::std::__hash_map__
90 ::rtl::OString,
91 TypeUsingSet,
92 HashString,
93 EqualString,
94 NewAlloc
95 > DependencyMap;
97 typedef ::std::__hash_map__
99 ::rtl::OString,
100 sal_uInt16,
101 HashString,
102 EqualString,
103 NewAlloc
104 > GenerationMap;
105 #else
106 typedef ::std::hash_map
108 ::rtl::OString,
109 TypeUsingSet,
110 HashString,
111 EqualString
112 > DependencyMap;
114 typedef ::std::hash_map
116 ::rtl::OString,
117 sal_uInt16,
118 HashString,
119 EqualString
120 > GenerationMap;
122 #endif
124 struct TypeDependencyImpl
126 TypeDependencyImpl()
127 : m_refCount(0)
130 sal_Int32 m_refCount;
131 DependencyMap m_dependencies;
132 GenerationMap m_generatedTypes;
135 class TypeDependency
137 public:
138 TypeDependency();
139 ~TypeDependency();
141 TypeDependency( const TypeDependency& value )
142 : m_pImpl( value.m_pImpl )
144 acquire();
147 TypeDependency& operator = ( const TypeDependency& value )
149 release();
150 m_pImpl = value.m_pImpl;
151 acquire();
152 return *this;
155 sal_Bool insert(const ::rtl::OString& type, const ::rtl::OString& depend, sal_uInt16);
156 TypeUsingSet getDependencies(const ::rtl::OString& type);
157 sal_Bool hasDependencies(const ::rtl::OString& type);
159 void setGenerated(const ::rtl::OString& type, sal_uInt16 genFlag=CODEGEN_DEFAULT);
160 sal_Bool isGenerated(const ::rtl::OString& type, sal_uInt16 genFlag=CODEGEN_DEFAULT);
162 sal_Int32 getSize() { return m_pImpl->m_generatedTypes.size(); }
163 protected:
164 void acquire();
165 void release();
167 protected:
168 TypeDependencyImpl* m_pImpl;
171 sal_Bool checkTypeDependencies(TypeManager& typeMgr, TypeDependency& dependencies, const ::rtl::OString& type, sal_Bool bDepend = sal_False);
173 #endif // _CODEMAKER_DEPENDENCY_HXX_