source: NonGTP/Xerces/xerces/include/xercesc/framework/psvi/XSParticle.hpp @ 358

Revision 358, 5.9 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 2003,2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * $Log: XSParticle.hpp,v $
19 * Revision 1.6  2004/09/08 13:56:09  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.5  2003/12/01 23:23:26  neilg
23 * fix for bug 25118; thanks to Jeroen Witmond
24 *
25 * Revision 1.4  2003/11/21 17:34:04  knoaman
26 * PSVI update
27 *
28 * Revision 1.3  2003/11/14 22:47:53  neilg
29 * fix bogus log message from previous commit...
30 *
31 * Revision 1.2  2003/11/14 22:33:30  neilg
32 * Second phase of schema component model implementation. 
33 * Implement XSModel, XSNamespaceItem, and the plumbing necessary
34 * to connect them to the other components.
35 * Thanks to David Cargill.
36 *
37 * Revision 1.1  2003/09/16 14:33:36  neilg
38 * PSVI/schema component model classes, with Makefile/configuration changes necessary to build them
39 *
40 */
41
42#if !defined(XSPARTICLE_HPP)
43#define XSPARTICLE_HPP
44
45#include <xercesc/framework/psvi/XSObject.hpp>
46
47XERCES_CPP_NAMESPACE_BEGIN
48
49/**
50 * This class describes all properties of a Schema Particle
51 * component.
52 * This is *always* owned by the validator /parser object from which
53 * it is obtained. 
54 */
55
56// forward declarations
57class XSElementDeclaration;
58class XSModelGroup;
59class XSWildcard;
60
61class XMLPARSER_EXPORT XSParticle : public XSObject
62{
63public:
64
65    // possible terms of this particle
66    enum TERM_TYPE {
67        /*
68         * an empty particle
69         */
70        TERM_EMPTY          = 0,
71        /*
72         * the particle has element content
73         */
74        TERM_ELEMENT        = XSConstants::ELEMENT_DECLARATION,
75        /*
76         * the particle's content is a model group
77         */
78        TERM_MODELGROUP     = XSConstants::MODEL_GROUP_DEFINITION,
79        /*
80         * the particle's content is a wildcard
81         */
82        TERM_WILDCARD       = XSConstants::WILDCARD
83    };
84
85    //  Constructors and Destructor
86    // -----------------------------------------------------------------------
87    /** @name Constructors */
88    //@{
89
90    /**
91      * The default constructor
92      *
93      * @param  termType
94      * @param  xsModel
95      * @param  particleTerm
96      * @param  minOccurs
97      * @param  maxOccurs
98      * @param  manager     The configurable memory manager
99      */
100    XSParticle
101    (
102        TERM_TYPE              termType
103        , XSModel* const       xsModel
104        , XSObject* const      particleTerm
105        , int                  minOccurs
106        , int                  maxOccurs
107        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
108    );
109
110    //@};
111
112    /** @name Destructor */
113    //@{
114    ~XSParticle();
115    //@}
116
117    //---------------------
118    /** @name XSParticle methods */
119    //@{
120
121    /**
122     * [min occurs]: determines the minimum number of terms that can occur.
123     */
124    int getMinOccurs() const;
125
126    /**
127     * [max occurs] determines the maximum number of terms that can occur. To
128     * query for value of unbounded use <code>maxOccursUnbounded</code>.
129     */
130    int getMaxOccurs() const;
131
132    /**
133     * [max occurs] whether the maxOccurs value is unbounded.
134     */
135    bool getMaxOccursUnbounded() const;
136
137    /**
138     * Returns the type of the [term]: one of
139     * TERM_EMPTY, TERM_ELEMENT, TERM_MODELGROUP, or TERM_WILDCARD.
140     */
141    TERM_TYPE getTermType() const;
142
143    /**
144     * If this particle has an [element declaration] for its term,
145     * this method returns that declaration; otherwise, it returns 0.
146     * @returns The element declaration that is the [term] of this Particle
147     * if and only if getTermType() == TERM_ELEMENT.
148     */
149    XSElementDeclaration *getElementTerm();
150
151    /**
152     * If this particle has a [model group] for its term,
153     * this method returns that definition; otherwise, it returns 0.
154     * @returns The model group that is the [term] of this Particle
155     * if and only if getTermType() == TERM_MODELGROUP.
156     */
157    XSModelGroup *getModelGroupTerm();
158
159    /**
160     * If this particle has an [wildcard] for its term,
161     * this method returns that declaration; otherwise, it returns 0.
162     * @returns The wildcard declaration that is the [term] of this Particle
163     * if and only if getTermType() == TERM_WILDCARD.
164     */
165    XSWildcard *getWildcardTerm();
166
167    //@}
168
169    //----------------------------------
170    /** methods needed by implementation */
171    //@{
172
173    //@}
174private:
175
176    // -----------------------------------------------------------------------
177    //  Unimplemented constructors and operators
178    // -----------------------------------------------------------------------
179    XSParticle(const XSParticle&);
180    XSParticle & operator=(const XSParticle &);
181
182protected:
183
184    // -----------------------------------------------------------------------
185    //  data members
186    // -----------------------------------------------------------------------
187    TERM_TYPE fTermType;
188    int       fMinOccurs;
189    int       fMaxOccurs;
190    XSObject* fTerm;
191};
192
193inline int XSParticle::getMinOccurs() const
194{
195    return fMinOccurs;
196}
197
198inline int XSParticle::getMaxOccurs() const
199{
200    return fMaxOccurs;
201}
202
203inline bool XSParticle::getMaxOccursUnbounded() const
204{
205    return (fMaxOccurs == -1);
206}
207
208inline XSParticle::TERM_TYPE XSParticle::getTermType() const
209{
210    return fTermType;
211}
212
213XERCES_CPP_NAMESPACE_END
214
215#endif
Note: See TracBrowser for help on using the repository browser.