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 FdoSchemaMergeContext;
00032 class FdoSchemaXmlContext;
00033 class FdoSchemaXmlError;
00034 
00035 template <class OBJ> class FdoSchemaCollection;
00036 
00037 /// \brief
00038 /// FdoSchemaElement is an abstract class that acts as a base class for all classes
00039 /// in the Schema package.
00040 class FdoSchemaElement : 
00041     public FdoIDisposable,
00042     public virtual FdoXmlSaxHandler
00043 {
00044     friend class FdoFeatureSchema;
00045     template <class OBJ> friend class FdoSchemaCollection;
00046     friend class FdoSchemaAttributeDictionary;
00047     friend class FdoPropertyDefinitionCollection;
00048     friend class FdoDataPropertyDefinitionCollection;
00049     friend class FdoNetworkNodeFeatureClass;
00050     friend class FdoNetworkFeatureClass;
00051     friend class FdoNetworkLinkFeatureClass;
00052 
00053 protected:
00054 /// \cond DOXYGEN-IGNORE
00055     /// Constructs a default instance of an FdoSchemaElement.
00056     FdoSchemaElement();
00057 
00058     /// Constructs an instance of an FdoSchemaElement using the specified arguments.
00059     FdoSchemaElement(FdoString* name, FdoString* description);
00060 
00061     virtual ~FdoSchemaElement();
00062 
00063     /// Write this element to XML.
00064     virtual void _writeXml( FdoSchemaXmlContext* pContext );
00065 /// \endcond
00066 
00067 public:
00068     /// \brief
00069     /// Gets the parent of this FdoSchemaElement or null if this object has not
00070     /// been added to a parent object.
00071     /// 
00072     /// \return
00073     /// Returns FdoSchemaElement of parent
00074     /// 
00075     FDO_API virtual FdoSchemaElement* GetParent();
00076 
00077     /// \brief
00078     /// Gets the FdoFeatureSchema this object is a part of. Returns null if this
00079     /// object has not been added to a feature schema.
00080     /// 
00081     /// \return
00082     /// Returns FdoFeatureSchema this object is a part of
00083     /// 
00084     FDO_API virtual FdoFeatureSchema* GetFeatureSchema();
00085 
00086     /// \brief
00087     /// Returns the current state of the schema element.
00088     /// 
00089     /// \return
00090     /// Returns the current state of the schema element
00091     /// 
00092     FDO_API FdoSchemaElementState GetElementState();
00093 
00094     /// \brief
00095     /// Gets an FdoSchemaAttributeDictionary that contains the attributes 
00096     /// associated with this FdoSchemaElement.
00097     /// 
00098     /// \return
00099     /// Returns an FdoSchemaAttributeDictionary
00100     /// 
00101     FDO_API FdoSchemaAttributeDictionary* GetAttributes();
00102 
00103     /// \brief
00104     /// Gets the name of the schema object.
00105     /// 
00106     /// \return
00107     /// Returns the name of the schema object
00108     /// 
00109     FDO_API virtual FdoString* GetName();
00110 
00111     /// \brief
00112     /// Gets the fully qualified name of this schema element
00113     /// 
00114     /// \return
00115     /// Default implementation simply returns the element name
00116     /// 
00117     FDO_API virtual FdoStringP GetQualifiedName();
00118 
00119     /// \brief
00120     /// Sets the name of the schema object.
00121     /// 
00122     /// \param value 
00123     /// Input the name of the schema object
00124     /// 
00125     /// \return
00126     /// Returns nothing
00127     /// 
00128     FDO_API virtual void SetName(FdoString* value);
00129 
00130     /// \brief
00131     /// Indicates that this object allows its name
00132     /// to change. This function is defined so that this class can 
00133     /// be a FdoNamedCollection element.
00134     /// 
00135     /// \return
00136     /// Returns true
00137     /// 
00138     FDO_API virtual FdoBoolean CanSetName()
00139     {
00140         return true;
00141     }
00142 
00143 
00144     /// \brief
00145     /// Gets the description of the schema object.
00146     /// 
00147     /// \return
00148     /// Returns the description of the schema object
00149     /// 
00150     FDO_API virtual FdoString* GetDescription();
00151 
00152     /// \brief
00153     /// Sets the description of the schema object.
00154     /// 
00155     /// \param value 
00156     /// Input the description of the schema object
00157     /// 
00158     /// \return
00159     /// Returns nothing
00160     /// 
00161     FDO_API virtual void SetDescription(FdoString* value);
00162 
00163     /// \brief
00164     /// Marks the schema element for deletion by setting the element state to
00165     /// FdoSchemaElementState_Deleted. If the schema elements current state is
00166     /// FdoSchemaElementState_Added then the element is physically removed. If
00167     /// the current state is FdoSchemaElementState_Detached this method does
00168     /// nothing.
00169     /// 
00170     /// \return
00171     /// Returns nothing
00172     /// 
00173     FDO_API void Delete();
00174 
00175 /// \cond DOXYGEN-IGNORE
00176     // Public non-API functions for XML and Schema Modification support
00177 
00178     // Update a schema element from the given element.
00179     virtual void Set( FdoSchemaElement* pElement, FdoSchemaMergeContext* pContext );
00180 
00181     // Checks referenced elements and adds errors if any are deleted. 
00182     // Does nothing.
00183     // Sub-classes must override this function if specific references need to be checked.
00184     virtual void CheckReferences( FdoSchemaMergeContext* pContext );
00185 
00186     /// Initialize this property from its XML attributes
00187     virtual void InitFromXml(FdoSchemaXmlContext* pContext, FdoXmlAttributeCollection* attrs);
00188 
00189     /// Handle the start of a sub-element
00190     virtual FdoXmlSaxHandler* XmlStartElement(
00191         FdoXmlSaxContext* context, 
00192         FdoString* uri, 
00193         FdoString* name, 
00194         FdoString* qname, 
00195         FdoXmlAttributeCollection* atts
00196     );
00197 
00198     /// Handle the end of a sub-element
00199     virtual FdoBoolean XmlEndElement(
00200         FdoXmlSaxContext* context, 
00201         FdoString* uri, 
00202         FdoString* name, 
00203         FdoString* qname
00204     );
00205 
00206 protected:
00207     /// Sets the parent of this SchemaObject. Can only be called from within the
00208     /// Schema package.
00209     virtual void SetParent(FdoSchemaElement* value);
00210 
00211     /// Sets the current state of the schema element. This is a package private
00212     /// method that can only be called from within the Schema package.
00213     void SetElementState(FdoSchemaElementState value);
00214 
00215     /// Notification method called whenever a property of this element is removed
00216     virtual void PropertyRemoved(const FdoPropertyDefinition* property);
00217 
00218     /// Is this a property of this element?
00219     virtual bool IsProperty(const FdoPropertyDefinition* property);
00220 
00221     /// Does this element have a base class?
00222     virtual bool IsSubClass();
00223 
00224     /// Throws an exception if the given name is not a valid 
00225     /// schema element name.
00226     void VldName( FdoString* name );
00227 
00228 private:
00229     FdoSchemaElement*               m_parent;
00230 
00231     /// The name of the schema object. This name is used to reference the schema
00232     /// object within the scope of the containing schema object.
00233     wchar_t*                        m_name;
00234 
00235     /// Optional description of the schema object.
00236     wchar_t*                        m_description;
00237 
00238     FdoSchemaAttributeDictionary*   m_attributes;
00239 
00240     FdoSchemaElementState           m_state;
00241 
00242 
00243 protected:
00244     /// FdoFeatureSchema::RejectChanges() support
00245     virtual void    _StartChanges();
00246     virtual void    _BeginChangeProcessing();
00247     virtual void    _AcceptChanges();
00248     virtual void    _RejectChanges();
00249     virtual void    _EndChangeProcessing();
00250     unsigned int                    m_changeInfoState;
00251     FdoSchemaElement*               m_parentCHANGED;
00252     wchar_t*                        m_nameCHANGED;
00253     wchar_t*                        m_descriptionCHANGED;
00254 
00255     /// States stored in the m_changeInfoState bitfield flag
00256     static const unsigned int   CHANGEINFO_PRESENT      = 0x00000001;
00257     static const unsigned int   CHANGEINFO_PROCESSING   = 0x00000002;
00258     static const unsigned int   CHANGEINFO_PROCESSED    = 0x00000004;
00259 
00260     /// SAX Handler for reading simple sub-element contents
00261     FdoXmlCharDataHandlerP        m_XmlContentHandler;
00262 
00263     /// SAX Handler for reading error sub-elements
00264     /// Errors are generated by the XSL transformation that 
00265     /// converts the Feature Schema XML from external to internal
00266     /// format before it is read.
00267     FdoPtr<FdoSchemaXmlError>     m_XmlErrorHandler;
00268 /// \endcond
00269 
00270 };
00271 
00272 /// \brief
00273 /// FdoSchemaElementP is a FdoPtr on FdoSchemaElement, provided for convenience.
00274 typedef FdoPtr<FdoSchemaElement> FdoSchemaElementP;
00275 
00276 #endif
00277 
00278 

Comments or suggestions? Send us feedback.