[2674] | 1 | /* |
---|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
| 3 | * contributor license agreements. See the NOTICE file distributed with |
---|
| 4 | * this work for additional information regarding copyright ownership. |
---|
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
| 6 | * (the "License"); you may not use this file except in compliance with |
---|
| 7 | * the License. You may obtain a copy of the License at |
---|
| 8 | * |
---|
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 10 | * |
---|
| 11 | * Unless required by applicable law or agreed to in writing, software |
---|
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 14 | * See the License for the specific language governing permissions and |
---|
| 15 | * limitations under the License. |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | /* |
---|
| 19 | * $Id: XSObjectFactory.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #if !defined(XSOBJECTFACTORY_HPP) |
---|
| 23 | #define XSOBJECTFACTORY_HPP |
---|
| 24 | |
---|
| 25 | #include <xercesc/framework/psvi/XSConstants.hpp> |
---|
| 26 | #include <xercesc/util/RefHashTableOf.hpp> |
---|
| 27 | |
---|
| 28 | XERCES_CPP_NAMESPACE_BEGIN |
---|
| 29 | |
---|
| 30 | class XSObject; |
---|
| 31 | class XSAttributeUse; |
---|
| 32 | class XSAttributeDeclaration; |
---|
| 33 | class XSModel; |
---|
| 34 | class XSElementDeclaration; |
---|
| 35 | class XSSimpleTypeDefinition; |
---|
| 36 | class XSComplexTypeDefinition; |
---|
| 37 | class XSModelGroupDefinition; |
---|
| 38 | class XSAttributeGroupDefinition; |
---|
| 39 | class XSWildcard; |
---|
| 40 | class XSParticle; |
---|
| 41 | class XSAnnotation; |
---|
| 42 | class XSNamespaceItem; |
---|
| 43 | class XSNotationDeclaration; |
---|
| 44 | class SchemaAttDef; |
---|
| 45 | class SchemaElementDecl; |
---|
| 46 | class DatatypeValidator; |
---|
| 47 | class ContentSpecNode; |
---|
| 48 | class ComplexTypeInfo; |
---|
| 49 | class XercesGroupInfo; |
---|
| 50 | class XercesAttGroupInfo; |
---|
| 51 | class XSIDCDefinition; |
---|
| 52 | class IdentityConstraint; |
---|
| 53 | class XMLNotationDecl; |
---|
| 54 | |
---|
| 55 | /** |
---|
| 56 | * Factory class to create various XSObject(s) |
---|
| 57 | * Used by XSModel |
---|
| 58 | */ |
---|
| 59 | class XMLPARSER_EXPORT XSObjectFactory : public XMemory |
---|
| 60 | { |
---|
| 61 | public: |
---|
| 62 | // ----------------------------------------------------------------------- |
---|
| 63 | // Constructors and Destructor |
---|
| 64 | // ----------------------------------------------------------------------- |
---|
| 65 | XSObjectFactory(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
---|
| 66 | ~XSObjectFactory(); |
---|
| 67 | |
---|
| 68 | private: |
---|
| 69 | // ----------------------------------------------------------------------- |
---|
| 70 | // Unimplemented constructors and destructor |
---|
| 71 | // ----------------------------------------------------------------------- |
---|
| 72 | XSObjectFactory(const XSObjectFactory&); |
---|
| 73 | XSObjectFactory& operator=(const XSObjectFactory&); |
---|
| 74 | |
---|
| 75 | // ----------------------------------------------------------------------- |
---|
| 76 | // factory methods |
---|
| 77 | // ----------------------------------------------------------------------- |
---|
| 78 | XSParticle* createModelGroupParticle |
---|
| 79 | ( |
---|
| 80 | const ContentSpecNode* const node |
---|
| 81 | , XSModel* const xsModel |
---|
| 82 | ); |
---|
| 83 | |
---|
| 84 | XSAttributeDeclaration* addOrFind |
---|
| 85 | ( |
---|
| 86 | SchemaAttDef* const attDef |
---|
| 87 | , XSModel* const xsModel |
---|
| 88 | , XSComplexTypeDefinition* const enclosingTypeDef = 0 |
---|
| 89 | ); |
---|
| 90 | |
---|
| 91 | XSSimpleTypeDefinition* addOrFind |
---|
| 92 | ( |
---|
| 93 | DatatypeValidator* const validator |
---|
| 94 | , XSModel* const xsModel |
---|
| 95 | , bool isAnySimpleType = false |
---|
| 96 | ); |
---|
| 97 | |
---|
| 98 | XSElementDeclaration* addOrFind |
---|
| 99 | ( |
---|
| 100 | SchemaElementDecl* const elemDecl |
---|
| 101 | , XSModel* const xsModel |
---|
| 102 | , XSComplexTypeDefinition* const enclosingTypeDef = 0 |
---|
| 103 | ); |
---|
| 104 | |
---|
| 105 | XSComplexTypeDefinition* addOrFind |
---|
| 106 | ( |
---|
| 107 | ComplexTypeInfo* const typeInfo |
---|
| 108 | , XSModel* const xsModel |
---|
| 109 | ); |
---|
| 110 | |
---|
| 111 | XSIDCDefinition* addOrFind |
---|
| 112 | ( |
---|
| 113 | IdentityConstraint* const ic |
---|
| 114 | , XSModel* const xsModel |
---|
| 115 | ); |
---|
| 116 | |
---|
| 117 | XSNotationDeclaration* addOrFind |
---|
| 118 | ( |
---|
| 119 | XMLNotationDecl* const notDecl |
---|
| 120 | , XSModel* const xsModel |
---|
| 121 | ); |
---|
| 122 | |
---|
| 123 | XSAttributeUse* createXSAttributeUse |
---|
| 124 | ( |
---|
| 125 | XSAttributeDeclaration* const xsAttDecl |
---|
| 126 | , XSModel* const xsModel |
---|
| 127 | ); |
---|
| 128 | XSWildcard* createXSWildcard |
---|
| 129 | ( |
---|
| 130 | SchemaAttDef* const attDef |
---|
| 131 | , XSModel* const xsModel |
---|
| 132 | ); |
---|
| 133 | |
---|
| 134 | XSWildcard* createXSWildcard |
---|
| 135 | ( |
---|
| 136 | const ContentSpecNode* const rootNode |
---|
| 137 | , XSModel* const xsModel |
---|
| 138 | ); |
---|
| 139 | |
---|
| 140 | XSModelGroupDefinition* createXSModelGroupDefinition |
---|
| 141 | ( |
---|
| 142 | XercesGroupInfo* const groupInfo |
---|
| 143 | , XSModel* const xsModel |
---|
| 144 | ); |
---|
| 145 | |
---|
| 146 | XSAttributeGroupDefinition* createXSAttGroupDefinition |
---|
| 147 | ( |
---|
| 148 | XercesAttGroupInfo* const attGroupInfo |
---|
| 149 | , XSModel* const xsModel |
---|
| 150 | ); |
---|
| 151 | |
---|
| 152 | // ----------------------------------------------------------------------- |
---|
| 153 | // Helper methods |
---|
| 154 | // ----------------------------------------------------------------------- |
---|
| 155 | // creates a particle corresponding to an element |
---|
| 156 | XSParticle* createElementParticle |
---|
| 157 | ( |
---|
| 158 | const ContentSpecNode* const rootNode |
---|
| 159 | , XSModel* const xsModel |
---|
| 160 | ); |
---|
| 161 | |
---|
| 162 | // creates a particle corresponding to a wildcard |
---|
| 163 | XSParticle* createWildcardParticle |
---|
| 164 | ( |
---|
| 165 | const ContentSpecNode* const rootNode |
---|
| 166 | , XSModel* const xsModel |
---|
| 167 | ); |
---|
| 168 | |
---|
| 169 | XSAnnotation* getAnnotationFromModel |
---|
| 170 | ( |
---|
| 171 | XSModel* const xsModel |
---|
| 172 | , const void* const key |
---|
| 173 | ); |
---|
| 174 | |
---|
| 175 | void buildAllParticles |
---|
| 176 | ( |
---|
| 177 | const ContentSpecNode* const rootNode |
---|
| 178 | , XSParticleList* const particleList |
---|
| 179 | , XSModel* const xsModel |
---|
| 180 | ); |
---|
| 181 | |
---|
| 182 | void buildChoiceSequenceParticles |
---|
| 183 | ( |
---|
| 184 | const ContentSpecNode* const rootNode |
---|
| 185 | , XSParticleList* const particleList |
---|
| 186 | , XSModel* const xsModel |
---|
| 187 | ); |
---|
| 188 | |
---|
| 189 | void putObjectInMap |
---|
| 190 | ( |
---|
| 191 | void* key |
---|
| 192 | , XSObject* const object |
---|
| 193 | ); |
---|
| 194 | |
---|
| 195 | XSObject* getObjectFromMap |
---|
| 196 | ( |
---|
| 197 | void* key |
---|
| 198 | ); |
---|
| 199 | |
---|
| 200 | void processFacets |
---|
| 201 | ( |
---|
| 202 | DatatypeValidator* const dv |
---|
| 203 | , XSModel* const xsModel |
---|
| 204 | , XSSimpleTypeDefinition* const xsST |
---|
| 205 | ); |
---|
| 206 | |
---|
| 207 | void processAttUse |
---|
| 208 | ( |
---|
| 209 | SchemaAttDef* const attDef |
---|
| 210 | , XSAttributeUse* const xsAttUse |
---|
| 211 | ); |
---|
| 212 | |
---|
| 213 | bool isMultiValueFacetDefined(DatatypeValidator* const dv); |
---|
| 214 | |
---|
| 215 | // make XSModel our friend |
---|
| 216 | friend class XSModel; |
---|
| 217 | |
---|
| 218 | // ----------------------------------------------------------------------- |
---|
| 219 | // Private Data Members |
---|
| 220 | // |
---|
| 221 | // fMemoryManager |
---|
| 222 | // The memory manager used to create various XSObject(s). |
---|
| 223 | // ----------------------------------------------------------------------- |
---|
| 224 | MemoryManager* fMemoryManager; |
---|
| 225 | RefHashTableOf<XSObject>* fXercesToXSMap; |
---|
| 226 | RefVectorOf<XSObject>* fDeleteVector; |
---|
| 227 | }; |
---|
| 228 | |
---|
| 229 | inline XSObject* XSObjectFactory::getObjectFromMap(void* key) |
---|
| 230 | { |
---|
| 231 | return fXercesToXSMap->get(key); |
---|
| 232 | } |
---|
| 233 | |
---|
| 234 | |
---|
| 235 | XERCES_CPP_NAMESPACE_END |
---|
| 236 | |
---|
| 237 | #endif |
---|