source: tags/VUT/0.4/GtpVisibilityPreprocessor/support/xerces/include/xercesc/validators/schema/identity/IdentityConstraint.hpp @ 358

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

xerces added

Line 
1/*
2 * Copyright 2001-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 * $Id: IdentityConstraint.hpp,v 1.8 2004/09/08 13:56:59 peiyongz Exp $
19 */
20
21#if !defined(IDENTITYCONSTRAINT_HPP)
22#define IDENTITYCONSTRAINT_HPP
23
24
25/**
26  * The class act as a base class for schema identity constraints.
27  */
28
29// ---------------------------------------------------------------------------
30//  Includes
31// ---------------------------------------------------------------------------
32#include <xercesc/util/RefVectorOf.hpp>
33#include <xercesc/validators/schema/identity/IC_Field.hpp>
34
35#include <xercesc/internal/XSerializable.hpp>
36
37XERCES_CPP_NAMESPACE_BEGIN
38
39// ---------------------------------------------------------------------------
40//  Forward Declarations
41// ---------------------------------------------------------------------------
42class IC_Selector;
43
44class VALIDATORS_EXPORT IdentityConstraint : public XSerializable, public XMemory
45{
46public:
47    // -----------------------------------------------------------------------
48    //  Constants
49    // -----------------------------------------------------------------------
50    enum ICType {
51        UNIQUE = 0,
52        KEY = 1,
53        KEYREF = 2,
54        UNKNOWN
55    };
56
57    // -----------------------------------------------------------------------
58    //  Constructors/Destructor
59    // -----------------------------------------------------------------------
60        virtual ~IdentityConstraint();
61
62    // -----------------------------------------------------------------------
63    //  operators
64    // -----------------------------------------------------------------------
65    bool operator== (const IdentityConstraint& other) const;
66    bool operator!= (const IdentityConstraint& other) const;
67
68        // -----------------------------------------------------------------------
69    //  Getter methods
70    // -----------------------------------------------------------------------
71    virtual short getType() const = 0;
72    int           getFieldCount() const;
73    XMLCh*        getIdentityConstraintName() const;
74    XMLCh*        getElementName() const;
75    IC_Selector*  getSelector() const;
76    int           getNamespaceURI() const;
77
78        // -----------------------------------------------------------------------
79    //  Setter methods
80    // -----------------------------------------------------------------------
81    void setSelector(IC_Selector* const selector);
82    void setNamespaceURI(int uri);
83
84        // -----------------------------------------------------------------------
85    //  Access methods
86    // -----------------------------------------------------------------------
87    void addField(IC_Field* const field);
88    const IC_Field* getFieldAt(const unsigned int index) const;
89    IC_Field* getFieldAt(const unsigned int index);
90
91    /***
92     * Support for Serialization/De-serialization
93     ***/
94    DECL_XSERIALIZABLE(IdentityConstraint)
95
96        static void                storeIC(XSerializeEngine&         serEng
97                                     , IdentityConstraint* const ic);
98
99        static IdentityConstraint* loadIC(XSerializeEngine& serEng);
100
101protected:
102    // -----------------------------------------------------------------------
103    //  Constructors/Destructor
104    // -----------------------------------------------------------------------
105    IdentityConstraint(const XMLCh* const identityConstraintName,
106                       const XMLCh* const elementName,
107                                           MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
108
109private:
110    // -----------------------------------------------------------------------
111    //  Unimplemented contstructors and operators
112    // -----------------------------------------------------------------------
113    IdentityConstraint(const IdentityConstraint& other);
114    IdentityConstraint& operator= (const IdentityConstraint& other);
115
116    // -----------------------------------------------------------------------
117    //  CleanUp methods
118    // -----------------------------------------------------------------------
119    void cleanUp();
120
121    // -----------------------------------------------------------------------
122    //  Data members
123    //
124    //  fIdentityConstraintName
125    //      The identity constraint name
126    //
127    //  fElemName
128    //      The element name
129    //
130    //  fSelector
131    //      The selector information
132    //
133    //  fFields
134    //      The field(s) information
135    // -----------------------------------------------------------------------
136    XMLCh*                 fIdentityConstraintName;
137    XMLCh*                 fElemName;
138    IC_Selector*           fSelector;
139    RefVectorOf<IC_Field>* fFields;
140    MemoryManager*         fMemoryManager;
141    int                    fNamespaceURI;
142};
143
144
145// ---------------------------------------------------------------------------
146//  IdentityConstraint: Getter methods
147// ---------------------------------------------------------------------------
148inline int IdentityConstraint::getFieldCount() const {
149
150    if (fFields) {
151        return fFields->size();
152    }
153
154    return 0;
155}
156
157inline XMLCh* IdentityConstraint::getIdentityConstraintName() const {
158
159    return fIdentityConstraintName;
160}
161
162inline XMLCh* IdentityConstraint::getElementName() const {
163
164    return fElemName;
165}
166
167inline IC_Selector* IdentityConstraint::getSelector() const {
168
169    return fSelector;
170}
171
172inline int IdentityConstraint::getNamespaceURI() const
173{
174    return fNamespaceURI;
175}
176
177// ---------------------------------------------------------------------------
178//  IdentityConstraint: Setter methods
179// ---------------------------------------------------------------------------
180inline void IdentityConstraint::setNamespaceURI(int uri)
181{
182    fNamespaceURI = uri;
183}
184
185// ---------------------------------------------------------------------------
186//  IdentityConstraint: Access methods
187// ---------------------------------------------------------------------------
188inline void IdentityConstraint::addField(IC_Field* const field) {
189
190    if (!fFields) {
191        fFields = new (fMemoryManager) RefVectorOf<IC_Field>(4, true, fMemoryManager);
192    }
193
194    fFields->addElement(field);
195}
196
197inline const IC_Field* IdentityConstraint::getFieldAt(const unsigned int index) const {
198
199    if (fFields) {
200        return (fFields->elementAt(index));
201    }
202
203    return 0;
204}
205
206inline IC_Field* IdentityConstraint::getFieldAt(const unsigned int index) {
207
208    if (fFields) {
209        return (fFields->elementAt(index));
210    }
211
212    return 0;
213}
214
215XERCES_CPP_NAMESPACE_END
216
217#endif
218
219/**
220  * End of file IdentityConstraint.hpp
221  */
222
Note: See TracBrowser for help on using the repository browser.