FDO API Reference Feature Data Objects

SchemaElement.h

Go to the documentation of this file.
00001 #ifndef _SCHEMAELEMENT_H_
00002 #define _SCHEMAELEMENT_H_
00003 
00004 //
00005 // Copyright (C) 2004-2006  Autodesk, Inc.
00006 // 
00007 // This library is free software; you can redistribute it and/or
00008 // modify it under the terms of version 2.1 of the GNU Lesser
00009 // General Public License as published by the Free Software Foundation.
00010 // 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 // 
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019 //
00020 
00021 #ifdef _WIN32
00022 #pragma once
00023 #endif
00024 
00025 #include <FdoStd.h>
00026 #include <Fdo/Schema/SchemaAttributeDictionary.h>
00027 #include <Fdo/Schema/SchemaElementState.h>
00028 
00029 class FdoFeatureSchema;
00030 class FdoPropertyDefinition;
00031 class FdoSchemaXmlContext;
00032 class FdoSchemaXmlError;
00033 
00034 template <class OBJ> class FdoSchemaCollection;
00035 
00036 /// \brief
00037 /// FdoSchemaElement is an abstract class that acts as a base class for all classes
00038 /// in the Schema package.
00039 class FdoSchemaElement : 
00040     public FdoIDisposable,
00041     public virtual FdoXmlSaxHandler
00042 {
00043     friend class FdoFeatureSchema;
00044     template <class OBJ> friend class FdoSchemaCollection;
00045     friend class FdoSchemaAttributeDictionary;
00046     friend class FdoPropertyDefinitionCollection;
00047     friend class FdoDataPropertyDefinitionCollection;
00048     friend class FdoNetworkNodeFeatureClass;
00049     friend class FdoNetworkFeatureClass;
00050     friend class FdoNetworkLinkFeatureClass;
00051 
00052 protected:
00053 /// \cond DOXYGEN-IGNORE
00054     /// Constructs a default instance of an FdoSchemaElement.
00055     FdoSchemaElement();
00056 
00057     /// Constructs an instance of an FdoSchemaElement using the specified arguments.
00058     FdoSchemaElement(FdoString* name, FdoString* description);
00059 
00060     virtual ~FdoSchemaElement();
00061 
00062     /// Write this element to XML.
00063     virtual void _writeXml( FdoSchemaXmlContext* pContext );
00064 /// \endcond
00065 
00066 public:
00067     /// \brief
00068     /// Gets the parent of this FdoSchemaElement or null if this object has not
00069     /// been added to a parent object.
00070     /// 
00071     /// \return
00072     /// Returns FdoSchemaElement of parent
00073     /// 
00074     FDO_API virtual FdoSchemaElement* GetParent();
00075 
00076     /// \brief
00077     /// Gets the FdoFeatureSchema this object is a part of. Returns null if this
00078     /// object has not been added to a feature schema.
00079     /// 
00080     /// \return
00081     /// Returns FdoFeatureSchema this object is a part of
00082     /// 
00083     FDO_API virtual FdoFeatureSchema* GetFeatureSchema();
00084 
00085     /// \brief
00086     /// Returns the current state of the schema element.
00087     /// 
00088     /// \return
00089     /// Returns the current state of the schema element
00090     /// 
00091     FDO_API FdoSchemaElementState GetElementState();
00092 
00093     /// \brief
00094     /// Gets an FdoSchemaAttributeDictionary that contains the attributes 
00095     /// associated with this FdoSchemaElement.
00096     /// 
00097     /// \return
00098     /// Returns an FdoSchemaAttributeDictionary
00099     /// 
00100     FDO_API FdoSchemaAttributeDictionary* GetAttributes();
00101 
00102     /// \brief
00103     /// Gets the name of the schema object.
00104     /// 
00105     /// \return
00106     /// Returns the name of the schema object
00107     /// 
00108     FDO_API virtual FdoString* GetName();
00109 
00110     /// \brief
00111     /// Gets the fully qualified name of this schema element
00112     /// 
00113     /// \return
00114     /// Default implementation simply returns the element name
00115     /// 
00116     FDO_API virtual FdoStringP GetQualifiedName();
00117 
00118     /// \brief
00119     /// Sets the name of the schema object.
00120     /// 
00121     /// \param value 
00122     /// Input the name of the schema object
00123     /// 
00124     /// \return
00125     /// Returns nothing
00126     /// 
00127     FDO_API virtual void SetName(FdoString* value);
00128 
00129     /// \brief
00130     /// Indicates that this object allows its name
00131     /// to change. This function is defined so that this class can 
00132     /// be a FdoNamedCollection element.
00133     /// 
00134     /// \return
00135     /// Returns true
00136     /// 
00137     FDO_API virtual FdoBoolean CanSetName()
00138     {
00139         return true;
00140     }
00141 
00142 
00143     /// \brief
00144     /// Gets the description of the schema object.
00145     /// 
00146     /// \return
00147     /// Returns the description of the schema object
00148     /// 
00149     FDO_API virtual FdoString* GetDescription();
00150 
00151     /// \brief
00152     /// Sets the description of the schema object.
00153     /// 
00154     /// \param value 
00155     /// Input the description of the schema object
00156     /// 
00157     /// \return
00158     /// Returns nothing
00159     /// 
00160     FDO_API virtual void SetDescription(FdoString* value);
00161 
00162     /// \brief
00163     /// Marks the schema element for deletion by setting the element state to
00164     /// FdoSchemaElementState_Deleted. If the schema elements current state is
00165     /// FdoSchemaElementState_Added then the element is physically removed. If
00166     /// the current state is FdoSchemaElementState_Detached this method does
00167     /// nothing.
00168     /// 
00169     /// \return
00170     /// Returns nothing
00171     /// 
00172     FDO_API void Delete();
00173 
00174 /// \cond DOXYGEN-IGNORE
00175     /// Public non-API functions for XML support
00176 
00177     /// Update a schema element from the given element.
00178     virtual void Set( FdoSchemaElement* pElement, FdoSchemaXmlContext* pContext );
00179 
00180     /// Initialize this property from its XML attributes
00181     virtual void InitFromXml(FdoSchemaXmlContext* pContext, FdoXmlAttributeCollection* attrs);
00182 
00183     /// Handle the start of a sub-element
00184     virtual FdoXmlSaxHandler* XmlStartElement(
00185         FdoXmlSaxContext* context, 
00186         FdoString* uri, 
00187         FdoString* name, 
00188         FdoString* qname, 
00189         FdoXmlAttributeCollection* atts
00190     );
00191 
00192     /// Handle the end of a sub-element
00193     virtual FdoBoolean XmlEndElement(
00194         FdoXmlSaxContext* context, 
00195         FdoString* uri, 
00196         FdoString* name, 
00197         FdoString* qname
00198     );
00199 
00200 protected:
00201     /// Sets the parent of this SchemaObject. Can only be called from within the
00202     /// Schema package.
00203     virtual void SetParent(FdoSchemaElement* value);
00204 
00205     /// Sets the current state of the schema element. This is a package private
00206     /// method that can only be called from within the Schema package.
00207     void SetElementState(FdoSchemaElementState value);
00208 
00209     /// Notification method called whenever a property of this element is removed
00210     virtual void PropertyRemoved(const FdoPropertyDefinition* property);
00211 
00212     /// Is this a property of this element?
00213     virtual bool IsProperty(const FdoPropertyDefinition* property);
00214 
00215     /// Does this element have a base class?
00216     virtual bool IsSubClass();
00217 
00218     /// Throws an exception if the given name is not a valid 
00219     /// schema element name.
00220     void VldName( FdoString* name );
00221 
00222 private:
00223     FdoSchemaElement*               m_parent;
00224 
00225     /// The name of the schema object. This name is used to reference the schema
00226     /// object within the scope of the containing schema object.
00227     wchar_t*                        m_name;
00228 
00229     /// Optional description of the schema object.
00230     wchar_t*                        m_description;
00231 
00232     FdoSchemaAttributeDictionary*   m_attributes;
00233 
00234     FdoSchemaElementState           m_state;
00235 
00236 
00237 protected:
00238     /// FdoFeatureSchema::RejectChanges() support
00239     virtual void    _StartChanges();
00240     virtual void    _BeginChangeProcessing();
00241     virtual void    _AcceptChanges();
00242     virtual void    _RejectChanges();
00243     virtual void    _EndChangeProcessing();
00244     unsigned int                    m_changeInfoState;
00245     FdoSchemaElement*               m_parentCHANGED;
00246     wchar_t*                        m_nameCHANGED;
00247     wchar_t*                        m_descriptionCHANGED;
00248 
00249     /// States stored in the m_changeInfoState bitfield flag
00250     static const unsigned int   CHANGEINFO_PRESENT      = 0x00000001;
00251     static const unsigned int   CHANGEINFO_PROCESSING   = 0x00000002;
00252     static const unsigned int   CHANGEINFO_PROCESSED    = 0x00000004;
00253 
00254     /// SAX Handler for reading simple sub-element contents
00255     FdoXmlCharDataHandlerP        m_XmlContentHandler;
00256 
00257     /// SAX Handler for reading error sub-elements
00258     /// Errors are generated by the XSL transformation that 
00259     /// converts the Feature Schema XML from external to internal
00260     /// format before it is read.
00261     FdoPtr<FdoSchemaXmlError>     m_XmlErrorHandler;
00262 /// \endcond
00263 
00264 };
00265 
00266 /// \brief
00267 /// FdoSchemaElementP is a FdoPtr on FdoSchemaElement, provided for convenience.
00268 typedef FdoPtr<FdoSchemaElement> FdoSchemaElementP;
00269 
00270 #endif
00271 
00272 

Comments or suggestions? Send us feedback.