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

Comments or suggestions? Send us feedback.