- Main Page
- Related Pages
- Modules
- Classes
- Files

# ClassDefinition.h

Go to the documentation of this file.

    00001 #ifndef _CLASSDEFINITION_H_
    00002 #define _CLASSDEFINITION_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/ClassCapabilities.h>
    00027 #include <Fdo/Schema/ClassType.h>
    00028 #include <Fdo/Schema/DataPropertyDefinitionCollection.h>
    00029 #include <Fdo/Schema/PropertyDefinitionCollection.h>
    00030 #include <Fdo/Schema/ReadOnlyPropertyDefinitionCollection.h>
    00031 #include <Fdo/Schema/ReadOnlyDataPropertyDefinitionCollection.h>
    00032 #include <Fdo/Schema/UniqueConstraintCollection.h>
    00033
    00034 class FdoReadOnlyPropertyDefinitionCollection;
    00035 class FdoReadOnlyDataPropertyDefinitionCollection;
    00036 class FdoIDisposableCollection;
    00037 class FdoUniqueConstraintCollection;
    00038
    00039 /// \brief
    00040 /// FdoClassDefinition is an abstract class that derives from FdoSchemaElement.
    00041 /// FdoClassDefinition is a base class for all concrete class types (e.g., FdoClass,
    00042 /// FdoFeatureClass) in the Schema package.
    00043 class FdoClassDefinition : public FdoSchemaElement
    00044 {
    00045     template <class OBJ> friend class FdoSchemaCollection;
    00046     friend class FdoRelationEnd;
    00047     friend class FdoRelation;
    00048     friend class FdoObjectPropertyDefinition;
    00049
    00050 /// \cond DOXYGEN-IGNORE
    00051 protected:
    00052     /// Constructs a default instance of a ClassDefinition.
    00053     FdoClassDefinition();
    00054
    00055     /// Constructs an instance of a ClassDefinition using the specified
    00056     /// arguments.
    00057     FdoClassDefinition(FdoString* name, FdoString* description);
    00058
    00059     virtual ~FdoClassDefinition();
    00060 /// \endcond
    00061
    00062 public:
    00063     /// \brief
    00064     /// This is an abstract operation that must be implemented by derived classes to return
    00065     /// the concrete class type.
    00066     ///
    00067     /// \return
    00068     /// Returns FdoClassType
    00069     ///
    00070     FDO_API virtual FdoClassType GetClassType();
    00071
    00072     /// \brief
    00073     /// Gets the base FdoClassDefinition this class is derived from.
    00074     ///
    00075     /// \return
    00076     /// Returns the base FdoClassDefinition
    00077     ///
    00078     FDO_API FdoClassDefinition* GetBaseClass();
    00079
    00080     /// \brief
    00081     /// Sets the base FdoClassDefinition this class is derived from.
    00082     ///
    00083     /// \param value
    00084     /// Input FdoClassDefinition this class is derived from
    00085     ///
    00086     /// \return
    00087     /// Returns nothing
    00088     ///
    00089     FDO_API void SetBaseClass(FdoClassDefinition* value);
    00090
    00091     /// \brief
    00092     /// Gets the abstraction state of the FdoClassDefinition. Classes marked as abstract
    00093     /// cannot be created via FDO commands and cannot be used as properties of
    00094     /// another class.
    00095     ///
    00096     /// \return
    00097     /// Returns if the FdoClassDefinition is abstract
    00098     ///
    00099     FDO_API bool GetIsAbstract();
    00100
    00101     /// \brief
    00102     /// Sets the abstraction state of the FdoClassDefinition. Classes marked as abstract
    00103     /// cannot be created via FDO commands and cannot be used as properties of
    00104     /// another class.
    00105     ///
    00106     /// \param value
    00107     /// Input the abstraction state
    00108     ///
    00109     /// \return
    00110     /// Returns nothing
    00111     ///
    00112     FDO_API void SetIsAbstract(bool value);
    00113
    00114     /// \brief
    00115     /// Sets the base properties of this class.  All elements of the
    00116     /// input collection must also be properties of the class.
    00117     ///
    00118     /// \param value
    00119     /// Input collection of FdoPropertyDefinition values
    00120     ///
    00121     /// \return
    00122     /// Returns nothing
    00123     ///
    00124     FDO_API void SetBaseProperties(FdoPropertyDefinitionCollection* value);
    00125
    00126     /// \brief
    00127     /// Returns an FdoReadOnlyPropertyDefinitionCollection containing the properties
    00128     /// defined by base classes or by the concrete class type, itself. This
    00129     /// collection is only populated when the FdoClassDefinition is returned by the
    00130     /// DescribeSchema command.
    00131     ///
    00132     /// \return
    00133     /// Returns FdoReadOnlyPropertyDefinitionCollection
    00134     ///
    00135     FDO_API FdoReadOnlyPropertyDefinitionCollection* GetBaseProperties();
    00136
    00137     /// \brief
    00138     /// Returns an FdoDataPropertyDefinitionCollection containing references to the
    00139     /// data properties that can be used to uniquely identify instances of the
    00140     /// class. The contained properties must already be defined in either the
    00141     /// properties or baseProperties collection. If GetBaseClass() returns non
    00142     /// null then this collection must be empty.
    00143     ///
    00144     /// \return
    00145     /// Returns DataPropertyDefinitionCollection
    00146     ///
    00147     FDO_API FdoDataPropertyDefinitionCollection* GetIdentityProperties();
    00148
    00149     /// \brief
    00150     /// Returns an FdoReadOnlyDataPropertyDefinitionCollection containing the identity
    00151     /// properties for the base class.
    00152     ///
    00153     /// \return
    00154     /// Returns ReadOnlyDataPropertyDefinitionCollection
    00155     ///
    00156     FDO_API FdoReadOnlyDataPropertyDefinitionCollection* GetBaseIdentityProperties();
    00157
    00158     /// \brief
    00159     /// Returns an FdoPropertyCollection containing the FdoDataProperties,
    00160     /// FdoClassProperties, and FdoGeometricProperties defined for this class.
    00161     ///
    00162     /// \return
    00163     /// Returns FdoPropertyDefinitionCollection
    00164     ///
    00165     FDO_API FdoPropertyDefinitionCollection* GetProperties();
    00166
    00167     /// \brief
    00168     /// Gets the fully qualified name of this class
    00169     ///
    00170     /// \return
    00171     /// Returns {schema_name}:{class_name}
    00172     ///
    00173     FDO_API virtual FdoStringP GetQualifiedName();
    00174
    00175     /// \brief
    00176     /// Gets the computed state of the FdoClassDefinition. Computed classes cannot be made persistent or added to
    00177     /// FDO schema. The computed classes are used as a transient classes that can be returned by a feature or data reader.
    00178     /// They describe the result of a select expression, select function and select distinct.
    00179     ///
    00180     /// \return
    00181     /// Returns if the FdoClassDefinition is a computed class
    00182     ///
    00183     FDO_API bool GetIsComputed();
    00184
    00185     /// \brief
    00186     /// Sets the computed state of the FdoClassDefinition. This is an internal method that
    00187     /// can only be called by providers. Application should not use this method.
    00188     ///
    00189     /// \param value
    00190     /// Input the computed state
    00191     ///
    00192     /// \return
    00193     /// Returns nothing
    00194     ///
    00195     FDO_API void SetIsComputed(bool value);
    00196
    00197     /// \brief
    00198     /// Gets the class-specific capabilities for this class.
    00199     ///
    00200     /// \return
    00201     /// Returns the capabilities. The Class Capabilities are connection
    00202     /// datastore dependent so they are only defined when this object was
    00203     /// created by a DescribeSchema command. The returned capabilities are the
    00204     /// ones for this command's connection.
    00205     /// Returns NULL if this object was not created by a DescribeSchema command.
    00206     ///
    00207     FDO_API FdoClassCapabilities* GetCapabilities();
    00208
    00209     /// \brief
    00210     /// Sets the class-specific capabilities for this class.
    00211     /// This function must only be called by an FDO Provider. It would be
    00212     /// typically called by the DescribeSchema command implementation.
    00213     ///
    00214     /// \param capabilities
    00215     /// Input the class capabilities.
    00216     ///
    00217     FDO_API void SetCapabilities(FdoClassCapabilities* capabilities);
    00218
    00219     /// \brief
    00220     /// Gets a FdoUniqueConstraintCollection containing all unique constraints applied to properties of this class.
    00221     /// The contained properties must already be defined in either the
    00222     /// properties or baseProperties collections.
    00223     ///
    00224     /// \return
    00225     /// A FdoUniqueConstraintCollection containing all unique constraints defined for properties of this class.
    00226     ///
    00227     FDO_API FdoUniqueConstraintCollection* GetUniqueConstraints();
    00228
    00229 /// \cond DOXYGEN-IGNORE
    00230
    00231     // Public non-API functions for XML and Schema Merge support
    00232
    00233     // Update a class definition from the given definition.
    00234     virtual void Set( FdoClassDefinition* pClass, FdoSchemaMergeContext* pContext );
    00235
    00236     // Checks referenced elements.
    00237     // Adds errors to the given merge context if the base class or any identity properties
    00238     // are marked for delete.
    00239     // Also checks references for each class property.
    00240     virtual void CheckReferences( FdoSchemaMergeContext* pContext );
    00241
    00242     /// Initialize the class from its XML attributes
    00243     virtual void InitFromXml(FdoString* classTypeName, FdoSchemaXmlContext* pContext, FdoXmlAttributeCollection* attrs);
    00244     virtual void InitFromXml(FdoSchemaXmlContext* pContext, FdoXmlAttributeCollection* attrs);
    00245
    00246     /// Handle sub-elements such as properties
    00247     /// Element start
    00248     virtual FdoXmlSaxHandler* XmlStartElement(
    00249         FdoXmlSaxContext* context,
    00250         FdoString* uri,
    00251         FdoString* name,
    00252         FdoString* qname,
    00253         FdoXmlAttributeCollection* atts
    00254     );
    00255     /// Element end
    00256     virtual FdoBoolean XmlEndElement(
    00257         FdoXmlSaxContext* context,
    00258         FdoString* uri,
    00259         FdoString* name,
    00260         FdoString* qname
    00261     );
    00262
    00263     /// Serialize this class to XML.
    00264     virtual void _writeXml( FdoSchemaXmlContext* pContext );
    00265
    00266     /// Serialize the base properties ( properties from base classes )
    00267     /// These functions are only called for classes that are represented in XML
    00268     /// by a complexType restriction.
    00269
    00270     /// Wrap base properties in <BaseProperties> element
    00271     void writeXmlBaseProperties( FdoSchemaXmlContext* pContext );
    00272     /// Just write base properties, don't wrap them.
    00273     void _writeXmlBaseProperties( FdoSchemaXmlContext* pContext );
    00274
    00275 private:
    00276     bool                                        m_isAbstract;
    00277     FdoClassDefinition*                         m_baseClass;
    00278     FdoReadOnlyPropertyDefinitionCollection*    m_baseProperties;
    00279     FdoDataPropertyDefinitionCollection*        m_identityProperties;
    00280     FdoPropertyDefinitionCollection*            m_properties;
    00281     FdoUniqueConstraintCollection*              m_uniqueConstraints;
    00282
    00283     FdoStringsP                                 m_idPropNames;
    00284     FdoStringsP                                 m_consPropNames;
    00285
    00286     bool                                        m_bProperties;
    00287
    00288     /// This is a special property that is used by non-persisted classes only.
    00289     bool                                        m_isComputed;
    00290
    00291     FdoClassCapabilitiesP                       m_capabilities;
    00292
    00293     FdoStringsP                                 m_propNameScopes;
    00294     FdoBoolean                                  m_bFirstAssocSubProp;
    00295
    00296     /// Initialize the private members of this class (avoid duplication in multiple constructors):
    00297     void Init();
    00298
    00299 protected:
    00300     /// Notification method called whenever a property of this element is removed
    00301     virtual void PropertyRemoved(const FdoPropertyDefinition* property);
    00302
    00303     /// Is this a property of this element?
    00304     virtual bool IsProperty(const FdoPropertyDefinition* property);
    00305
    00306     /// Does this class have a base class?
    00307     virtual bool IsSubClass();
    00308
    00309     /// FdoFeatureSchema::RejectChanges() support
    00310     virtual void    _StartChanges();
    00311     virtual void    _BeginChangeProcessing();
    00312     virtual void    _AcceptChanges();
    00313     virtual void    _RejectChanges();
    00314     virtual void    _EndChangeProcessing();
    00315     bool                                        m_isAbstractCHANGED;
    00316     FdoClassDefinition*                         m_baseClassCHANGED;
    00317     FdoReadOnlyPropertyDefinitionCollection*    m_basePropertiesCHANGED;
    00318     FdoUniqueConstraintCollection*              m_uniqueConstraintsCHANGED;
    00319 /// \endcond
    00320 };
    00321
    00322 /// \ingroup (typedefs)
    00323 /// \brief
    00324 /// FdoClassDefinitionP is a FdoPtr on FdoClassDefinition, provided for convenience.
    00325 typedef FdoPtr<FdoClassDefinition> FdoClassDefinitionP;
    00326
    00327 #endif
    00328
    00329

Please send us your comment about this page