FDO API Reference Feature Data Objects

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 protected:
00051 /// \cond DOXYGEN-IGNORE
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     // Public non-API functions for XML and Schema Merge support
00231 
00232     // Update a class definition from the given definition.
00233     virtual void Set( FdoClassDefinition* pClass, FdoSchemaMergeContext* pContext );
00234 
00235     // Checks referenced elements. 
00236     // Adds errors to the given merge context if the base class or any identity properties
00237     // are marked for delete.
00238     // Also checks references for each class property.
00239     virtual void CheckReferences( FdoSchemaMergeContext* pContext );
00240 
00241     /// Initialize the class from its XML attributes
00242     virtual void InitFromXml(const FdoString* classTypeName, FdoSchemaXmlContext* pContext, FdoXmlAttributeCollection* attrs);
00243     virtual void InitFromXml(FdoSchemaXmlContext* pContext, FdoXmlAttributeCollection* attrs);
00244 
00245     /// Handle sub-elements such as properties
00246     /// Element start
00247     virtual FdoXmlSaxHandler* XmlStartElement(
00248         FdoXmlSaxContext* context, 
00249         FdoString* uri, 
00250         FdoString* name, 
00251         FdoString* qname, 
00252         FdoXmlAttributeCollection* atts
00253     );
00254     /// Element end
00255     virtual FdoBoolean XmlEndElement(
00256         FdoXmlSaxContext* context, 
00257         FdoString* uri, 
00258         FdoString* name, 
00259         FdoString* qname
00260     );
00261 
00262     /// Serialize this class to XML.
00263     virtual void _writeXml( FdoSchemaXmlContext* pContext );
00264 
00265     /// Serialize the base properties ( properties from base classes )
00266     /// These functions are only called for classes that are represented in XML
00267     /// by a complexType restriction.
00268 
00269     /// Wrap base properties in <BaseProperties> element
00270     void writeXmlBaseProperties( FdoSchemaXmlContext* pContext );
00271     /// Just write base properties, don't wrap them.
00272     void _writeXmlBaseProperties( FdoSchemaXmlContext* pContext );
00273 
00274 private:
00275     bool                                        m_isAbstract;
00276     FdoClassDefinition*                         m_baseClass;
00277     FdoReadOnlyPropertyDefinitionCollection*    m_baseProperties;
00278     FdoDataPropertyDefinitionCollection*        m_identityProperties;
00279     FdoPropertyDefinitionCollection*            m_properties;
00280     FdoUniqueConstraintCollection*              m_uniqueConstraints;
00281 
00282     FdoStringsP                                 m_idPropNames;
00283     FdoStringsP                                 m_consPropNames; 
00284 
00285     bool                                        m_bProperties;
00286 
00287     /// This is a special property that is used by non-persisted classes only.
00288     bool                                        m_isComputed; 
00289 
00290     FdoClassCapabilitiesP                       m_capabilities;
00291 
00292     FdoStringsP                                 m_propNameScopes;
00293     FdoBoolean                                  m_bFirstAssocSubProp;
00294 
00295     /// Initialize the private members of this class (avoid duplication in multiple constructors):
00296     void Init();
00297 
00298 protected:
00299     /// Notification method called whenever a property of this element is removed
00300     virtual void PropertyRemoved(const FdoPropertyDefinition* property);
00301 
00302     /// Is this a property of this element?
00303     virtual bool IsProperty(const FdoPropertyDefinition* property);
00304 
00305     /// Does this class have a base class?
00306     virtual bool IsSubClass();
00307 
00308     /// FdoFeatureSchema::RejectChanges() support
00309     virtual void    _StartChanges();
00310     virtual void    _BeginChangeProcessing();
00311     virtual void    _AcceptChanges();
00312     virtual void    _RejectChanges();
00313     virtual void    _EndChangeProcessing();
00314     bool                                        m_isAbstractCHANGED;
00315     FdoClassDefinition*                         m_baseClassCHANGED;
00316     FdoReadOnlyPropertyDefinitionCollection*    m_basePropertiesCHANGED;
00317     FdoUniqueConstraintCollection*              m_uniqueConstraintsCHANGED;
00318 /// \endcond
00319 };
00320 
00321 /// \brief
00322 /// FdoClassDefinitionP is a FdoPtr on FdoClassDefinition, provided for convenience.
00323 typedef FdoPtr<FdoClassDefinition> FdoClassDefinitionP;
00324 
00325 #endif
00326 
00327 

Comments or suggestions? Send us feedback.