source: NonGTP/Xerces/xerces-c_2_8_0/include/xercesc/framework/psvi/XSParticle.hpp @ 2674

Revision 2674, 5.2 KB checked in by mattausch, 16 years ago (diff)
Line 
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: XSParticle.hpp 568078 2007-08-21 11:43:25Z amassari $
20 */
21
22#if !defined(XSPARTICLE_HPP)
23#define XSPARTICLE_HPP
24
25#include <xercesc/framework/psvi/XSObject.hpp>
26
27XERCES_CPP_NAMESPACE_BEGIN
28
29/**
30 * This class describes all properties of a Schema Particle
31 * component.
32 * This is *always* owned by the validator /parser object from which
33 * it is obtained. 
34 */
35
36// forward declarations
37class XSElementDeclaration;
38class XSModelGroup;
39class XSWildcard;
40
41class XMLPARSER_EXPORT XSParticle : public XSObject
42{
43public:
44
45    // possible terms of this particle
46    enum TERM_TYPE {
47        /*
48         * an empty particle
49         */
50        TERM_EMPTY          = 0,
51        /*
52         * the particle has element content
53         */
54        TERM_ELEMENT        = XSConstants::ELEMENT_DECLARATION,
55        /*
56         * the particle's content is a model group
57         */
58        TERM_MODELGROUP     = XSConstants::MODEL_GROUP_DEFINITION,
59        /*
60         * the particle's content is a wildcard
61         */
62        TERM_WILDCARD       = XSConstants::WILDCARD
63    };
64
65    //  Constructors and Destructor
66    // -----------------------------------------------------------------------
67    /** @name Constructors */
68    //@{
69
70    /**
71      * The default constructor
72      *
73      * @param  termType
74      * @param  xsModel
75      * @param  particleTerm
76      * @param  minOccurs
77      * @param  maxOccurs
78      * @param  manager     The configurable memory manager
79      */
80    XSParticle
81    (
82        TERM_TYPE              termType
83        , XSModel* const       xsModel
84        , XSObject* const      particleTerm
85        , int                  minOccurs
86        , int                  maxOccurs
87        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
88    );
89
90    //@};
91
92    /** @name Destructor */
93    //@{
94    ~XSParticle();
95    //@}
96
97    //---------------------
98    /** @name XSParticle methods */
99    //@{
100
101    /**
102     * [min occurs]: determines the minimum number of terms that can occur.
103     */
104    int getMinOccurs() const;
105
106    /**
107     * [max occurs] determines the maximum number of terms that can occur. To
108     * query for value of unbounded use <code>maxOccursUnbounded</code>.
109     */
110    int getMaxOccurs() const;
111
112    /**
113     * [max occurs] whether the maxOccurs value is unbounded.
114     */
115    bool getMaxOccursUnbounded() const;
116
117    /**
118     * Returns the type of the [term]: one of
119     * TERM_EMPTY, TERM_ELEMENT, TERM_MODELGROUP, or TERM_WILDCARD.
120     */
121    TERM_TYPE getTermType() const;
122
123    /**
124     * If this particle has an [element declaration] for its term,
125     * this method returns that declaration; otherwise, it returns 0.
126     * @returns The element declaration that is the [term] of this Particle
127     * if and only if getTermType() == TERM_ELEMENT.
128     */
129    XSElementDeclaration *getElementTerm();
130
131    /**
132     * If this particle has a [model group] for its term,
133     * this method returns that definition; otherwise, it returns 0.
134     * @returns The model group that is the [term] of this Particle
135     * if and only if getTermType() == TERM_MODELGROUP.
136     */
137    XSModelGroup *getModelGroupTerm();
138
139    /**
140     * If this particle has an [wildcard] for its term,
141     * this method returns that declaration; otherwise, it returns 0.
142     * @returns The wildcard declaration that is the [term] of this Particle
143     * if and only if getTermType() == TERM_WILDCARD.
144     */
145    XSWildcard *getWildcardTerm();
146
147    //@}
148
149    //----------------------------------
150    /** methods needed by implementation */
151    //@{
152
153    //@}
154private:
155
156    // -----------------------------------------------------------------------
157    //  Unimplemented constructors and operators
158    // -----------------------------------------------------------------------
159    XSParticle(const XSParticle&);
160    XSParticle & operator=(const XSParticle &);
161
162protected:
163
164    // -----------------------------------------------------------------------
165    //  data members
166    // -----------------------------------------------------------------------
167    TERM_TYPE fTermType;
168    int       fMinOccurs;
169    int       fMaxOccurs;
170    XSObject* fTerm;
171};
172
173inline int XSParticle::getMinOccurs() const
174{
175    return fMinOccurs;
176}
177
178inline int XSParticle::getMaxOccurs() const
179{
180    return fMaxOccurs;
181}
182
183inline bool XSParticle::getMaxOccursUnbounded() const
184{
185    return (fMaxOccurs == -1);
186}
187
188inline XSParticle::TERM_TYPE XSParticle::getTermType() const
189{
190    return fTermType;
191}
192
193XERCES_CPP_NAMESPACE_END
194
195#endif
Note: See TracBrowser for help on using the repository browser.