source: NonGTP/Xerces/xercesc/internal/XSObjectFactory.hpp @ 188

Revision 188, 9.1 KB checked in by mattausch, 19 years ago (diff)

added xercesc to support

Line 
1/*
2 * The Apache Software License, Version 1.1
3 *
4 * Copyright (c) 2003 The Apache Software Foundation.  All rights
5 * reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in
16 *    the documentation and/or other materials provided with the
17 *    distribution.
18 *
19 * 3. The end-user documentation included with the redistribution,
20 *    if any, must include the following acknowledgment:
21 *       "This product includes software developed by the
22 *        Apache Software Foundation (http://www.apache.org/)."
23 *    Alternately, this acknowledgment may appear in the software itself,
24 *    if and wherever such third-party acknowledgments normally appear.
25 *
26 * 4. The names "Xerces" and "Apache Software Foundation" must
27 *    not be used to endorse or promote products derived from this
28 *    software without prior written permission. For written
29 *    permission, please contact apache\@apache.org.
30 *
31 * 5. Products derived from this software may not be called "Apache",
32 *    nor may "Apache" appear in their name, without prior written
33 *    permission of the Apache Software Foundation.
34 *
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46 * SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Software Foundation, and was
51 * originally based on software copyright (c) 2001, International
52 * Business Machines, Inc., http://www.ibm.com .  For more information
53 * on the Apache Software Foundation, please see
54 * <http://www.apache.org/>.
55 */
56
57/*
58 * $Log: XSObjectFactory.hpp,v $
59 * Revision 1.8  2004/01/07 02:33:56  knoaman
60 * PSVI: inherit facets from base type
61 *
62 * Revision 1.7  2003/12/29 16:15:41  knoaman
63 * More PSVI updates
64 *
65 * Revision 1.6  2003/12/24 17:42:02  knoaman
66 * Misc. PSVI updates
67 *
68 * Revision 1.5  2003/12/17 20:50:35  knoaman
69 * PSVI: fix for annotation of attributes in attributeGroup/derived types
70 *
71 * Revision 1.4  2003/11/25 18:11:54  knoaman
72 * Make XSObjectFactory inherit from XMemory. Thanks to David Cargill.
73 *
74 * Revision 1.3  2003/11/24 15:45:36  knoaman
75 * PSVI: finish construction of XSSimpleTypeDefinition
76 *
77 * Revision 1.2  2003/11/23 16:21:40  knoaman
78 * PSVI: create local elements of complex types
79 *
80 * Revision 1.1  2003/11/21 17:11:24  knoaman
81 * Initial revision
82 *
83 */
84
85#if !defined(XSOBJECTFACTORY_HPP)
86#define XSOBJECTFACTORY_HPP
87
88#include <xercesc/framework/psvi/XSConstants.hpp>
89#include <xercesc/util/RefHashTableOf.hpp>
90
91XERCES_CPP_NAMESPACE_BEGIN
92
93class XSObject;
94class XSAttributeUse;
95class XSAttributeDeclaration;
96class XSModel;
97class XSElementDeclaration;
98class XSSimpleTypeDefinition;
99class XSComplexTypeDefinition;
100class XSModelGroupDefinition;
101class XSAttributeGroupDefinition;
102class XSWildcard;
103class XSParticle;
104class XSAnnotation;
105class XSNamespaceItem;
106class XSNotationDeclaration;
107class SchemaAttDef;
108class SchemaElementDecl;
109class DatatypeValidator;
110class ContentSpecNode;
111class ComplexTypeInfo;
112class XercesGroupInfo;
113class XercesAttGroupInfo;
114class XSIDCDefinition;
115class IdentityConstraint;
116class XMLNotationDecl;
117
118/**
119 * Factory class to create various XSObject(s)
120 * Used by XSModel
121 */
122class XMLPARSER_EXPORT XSObjectFactory : public XMemory
123{
124public:
125    // -----------------------------------------------------------------------
126    //  Constructors and Destructor
127    // -----------------------------------------------------------------------
128    XSObjectFactory(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
129    ~XSObjectFactory();
130
131private:
132    // -----------------------------------------------------------------------
133    //  Unimplemented constructors and destructor
134    // -----------------------------------------------------------------------
135    XSObjectFactory(const XSObjectFactory&);
136    XSObjectFactory& operator=(const XSObjectFactory&);
137
138    // -----------------------------------------------------------------------
139    //  factory methods
140    // -----------------------------------------------------------------------
141    XSParticle* createModelGroupParticle
142    (
143        const ContentSpecNode* const node
144        , XSModel* const             xsModel
145    );
146
147    XSAttributeDeclaration* addOrFind
148    (
149        SchemaAttDef* const attDef
150        , XSModel* const xsModel
151        , XSComplexTypeDefinition* const enclosingTypeDef = 0
152    );
153
154    XSSimpleTypeDefinition* addOrFind
155    (
156        DatatypeValidator* const validator
157        , XSModel* const xsModel
158        , bool isAnySimpleType = false
159    );
160
161    XSElementDeclaration* addOrFind
162    (
163        SchemaElementDecl* const elemDecl
164        , XSModel* const xsModel
165        , XSComplexTypeDefinition* const enclosingTypeDef = 0
166    );
167
168    XSComplexTypeDefinition* addOrFind
169    (
170        ComplexTypeInfo* const typeInfo
171        , XSModel* const xsModel
172    );
173
174    XSIDCDefinition* addOrFind
175    (
176        IdentityConstraint* const ic
177        , XSModel* const xsModel
178    );
179
180    XSNotationDeclaration* addOrFind
181    (
182        XMLNotationDecl* const notDecl
183        , XSModel* const xsModel
184    );
185
186    XSAttributeUse* createXSAttributeUse
187    (
188        XSAttributeDeclaration* const xsAttDecl
189        , XSModel* const xsModel
190    );
191    XSWildcard* createXSWildcard
192    (
193        SchemaAttDef* const attDef
194        , XSModel* const xsModel
195    );
196
197    XSWildcard* createXSWildcard
198    (
199        const ContentSpecNode* const rootNode
200        , XSModel* const xsModel
201    );
202
203    XSModelGroupDefinition* createXSModelGroupDefinition
204    (
205        XercesGroupInfo* const groupInfo
206        , XSModel* const xsModel
207    );
208
209    XSAttributeGroupDefinition* createXSAttGroupDefinition
210    (
211        XercesAttGroupInfo* const attGroupInfo
212        , XSModel* const xsModel
213    );
214
215    // -----------------------------------------------------------------------
216    //  Helper methods
217    // -----------------------------------------------------------------------
218    // creates a particle corresponding to an element
219    XSParticle* createElementParticle
220    (
221        const ContentSpecNode* const rootNode
222        , XSModel* const             xsModel
223    );
224
225    // creates a particle corresponding to a wildcard
226    XSParticle* createWildcardParticle
227    (
228        const ContentSpecNode* const rootNode
229        , XSModel* const             xsModel
230    );
231
232    XSAnnotation* getAnnotationFromModel
233    (
234        XSModel* const xsModel
235        , const void* const key
236    );
237
238    void buildAllParticles
239    (
240        const ContentSpecNode* const rootNode
241        , XSParticleList* const particleList
242        , XSModel* const xsModel
243    );
244
245    void buildChoiceSequenceParticles
246    (
247        const ContentSpecNode* const rootNode
248        , XSParticleList* const particleList
249        , XSModel* const xsModel
250    );
251
252    void putObjectInMap
253    (
254        void* key
255        , XSObject* const object
256    );
257
258    XSObject* getObjectFromMap
259    (
260        void* key
261    );
262
263    void processFacets
264    (
265        DatatypeValidator* const dv
266        , XSModel* const xsModel
267        , XSSimpleTypeDefinition* const xsST
268    );
269
270    void processAttUse
271    (
272        SchemaAttDef* const attDef
273        , XSAttributeUse* const xsAttUse
274    );
275
276    bool isMultiValueFacetDefined(DatatypeValidator* const dv);
277
278    // make XSModel our friend
279    friend class XSModel;
280
281    // -----------------------------------------------------------------------
282    //  Private Data Members
283    //
284    //  fMemoryManager
285    //      The memory manager used to create various XSObject(s).
286    // -----------------------------------------------------------------------
287    MemoryManager*            fMemoryManager;
288    RefHashTableOf<XSObject>* fXercesToXSMap;
289    RefVectorOf<XSObject>*    fDeleteVector;
290};
291
292inline XSObject* XSObjectFactory::getObjectFromMap(void* key)
293{
294    return fXercesToXSMap->get(key);
295}
296
297
298XERCES_CPP_NAMESPACE_END
299
300#endif
Note: See TracBrowser for help on using the repository browser.