FDO API Reference Feature Data Objects

AssociationPropertyDefinition.h

Go to the documentation of this file.
00001 #ifndef _ASSOCIATIONPROPERTYDEFINITION_H_
00002 #define _ASSOCIATIONPROPERTYDEFINITION_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/PropertyDefinition.h>
00027 #include <Fdo/Schema/DeleteRule.h>
00028 #include <Fdo/Schema/ClassDefinition.h>
00029 #include <Fdo/Schema/PropertyType.h>
00030 #include <Fdo/Schema/DataPropertyDefinitionCollection.h>
00031 
00032 /// \brief
00033 /// The FdoAssociationPropertyDefinition class derives from FdoPropertyDefinition and represents
00034 /// the association between two classes.
00035 /// The class of the associated class must already be defined in the feature
00036 /// schema and cannot be abstract.
00037 class FdoAssociationPropertyDefinition : public FdoPropertyDefinition
00038 {
00039 protected:
00040     /// Constructs a default instance of an FdoAssociationPropertyDefinition. 
00041     FDO_API FdoAssociationPropertyDefinition();
00042 
00043     /// Constructs an instance of an FdoAssociationPropertyDefinition using the specified
00044     /// arguments.
00045     FDO_API FdoAssociationPropertyDefinition(FdoString* name, FdoString* description, bool system = false);
00046 /// \cond DOXYGEN-IGNORE
00047     virtual ~FdoAssociationPropertyDefinition();
00048 
00049     virtual void Dispose();
00050 /// \endcond
00051 
00052 public:
00053     /// \brief
00054     /// Constructs a default instance of an FdoAssociationPropertyDefinition.
00055     /// 
00056     /// \return
00057     /// Returns FdoAssociationPropertyDefinition
00058     /// 
00059     FDO_API static FdoAssociationPropertyDefinition* Create();
00060 
00061     /// \brief
00062     /// Constructs an instance of an FdoAssociationPropertyDefinition using the specified
00063     /// arguments.
00064     /// 
00065     /// \param name 
00066     /// Input name
00067     /// \param description 
00068     /// Input description
00069     /// \param system 
00070     /// Input true if this is a system generated property, false otherwise.
00071     /// \note
00072     /// A client would never set system to true, only a provider.
00073     /// 
00074     /// \return
00075     /// Returns FdoAssociationPropertyDefinition
00076     /// 
00077     FDO_API static FdoAssociationPropertyDefinition* Create(FdoString* name, FdoString* description, bool system = false);
00078 
00079     /// \brief
00080     /// Gets the concrete property type.
00081     /// 
00082     /// \return
00083     /// Returns the concrete property type
00084     /// 
00085     FDO_API virtual FdoPropertyType GetPropertyType();
00086 
00087     /// \brief
00088     /// Gets a reference to the associated class.
00089     /// 
00090     /// \return
00091     /// Returns class definition
00092     /// 
00093     FDO_API FdoClassDefinition* GetAssociatedClass();
00094 
00095     /// \brief
00096     /// Sets a reference to the associated class.
00097     /// 
00098     /// \param value 
00099     /// Input class definition
00100     /// 
00101     /// \return
00102     /// Returns nothing
00103     /// 
00104     FDO_API void SetAssociatedClass(FdoClassDefinition* value);
00105 
00106     /// \brief
00107     /// Gets a reference to an FdoDataPropertyDefinitionCollection which is a collection of 
00108     /// properties of the current class that are used as key for this association. Initially, this 
00109     /// collection is empty. The user can optionally add any number of properties.  If the collection 
00110     /// is left empty, the identity properties of the associated class are added to the current class. 
00111     /// The number, order and types should match the property of the ReverseIdentityProperties collection. 
00112     /// All properties in the collection should already exist in the containing class. 
00113     /// This is needed in case the current class already has properties (foreign keys) that are used 
00114     /// to reference the associated feature.
00115     /// 
00116     /// \return
00117     /// Returns data property definition
00118     /// 
00119     FDO_API FdoDataPropertyDefinitionCollection* GetIdentityProperties();
00120 
00121     /// \brief
00122     /// Gets a reference to an FdoDataPropertyDefinitionCollection used to return a collection 
00123     /// of properties of the associated class that are used as key for this association. 
00124     /// The number, order and types should match the IdentityProperties. If the reverse identity 
00125     /// collection is empty, then the associated class identity properties will be used. 
00126     /// The properties of the collection should already exist on the associated class.
00127     /// 
00128     /// \return
00129     /// Returns data property definition
00130     /// 
00131     FDO_API FdoDataPropertyDefinitionCollection* GetReverseIdentityProperties();
00132 
00133     /// \brief
00134     /// Gets the reverse name of this property. See description of SetReverseName.
00135     /// 
00136     /// \return
00137     /// Returns the reverse name
00138     /// 
00139     FDO_API FdoString* GetReverseName();
00140 
00141     /// \brief
00142     /// This method is used to set the name of this association as seen by the associated 
00143     /// class. This is an optional parameter that can be provided if the navigation back from the 
00144     /// associated class is needed. This property will appear as read-only property on the associated 
00145     /// class. For example let's assume that we have an Accident class that associated to a Road class 
00146     /// by an association called Road? If we wanted to find all the accidents associated to a given 
00147     /// road, we will need to provide a reverse property name of the road association property. 
00148     /// In this case an appropriate value for such a name would be accident. The filter that can be 
00149     /// used to find all the accidents would look like: accident not null.
00150     /// 
00151     /// \param name 
00152     /// Input reverse name
00153     /// 
00154     /// \return
00155     /// Returns nothing
00156     /// 
00157     FDO_API void SetReverseName(FdoString* name);
00158 
00159     /// \brief
00160     /// Gets the delete rule.
00161     /// 
00162     /// \return
00163     /// Returns the delete rule
00164     /// 
00165     FDO_API FdoDeleteRule GetDeleteRule();
00166 
00167     /// \brief
00168     /// Sets the delete rule.
00169     /// 
00170     /// \param value 
00171     /// Input the delete rule
00172     /// 
00173     /// \return
00174     /// Returns nothing
00175     /// 
00176     FDO_API void SetDeleteRule(FdoDeleteRule value);
00177 
00178     /// \brief
00179     /// Gets the lock cascade option. true to cascade the lock otherwise the lock is not cascaded
00180     /// 
00181     /// \return
00182     /// Returns the lock cascade option
00183     /// 
00184     FDO_API bool GetLockCascade();
00185 
00186     /// \brief
00187     /// Sets the lock cascade option.
00188     /// 
00189     /// \param value 
00190     /// Input the lock cascade option.
00191     /// 
00192     /// \return
00193     /// Returns nothing
00194     /// 
00195     FDO_API void SetLockCascade(bool value);
00196 
00197     /// \brief
00198     /// This method is used to verify if this association property is a read-only association 
00199     /// property. A read-only association property is created internally when the reverse name of an 
00200     /// association property is specified. The read-only association property is added automatically 
00201     /// to the associated class and can be used to navigate from the associated class to the 
00202     /// associating class
00203     /// 
00204     /// \return
00205     /// Returns true if the association property is read-only. otherwise false.
00206     /// 
00207     FDO_API bool GetIsReadOnly();
00208 
00209     /// \brief
00210     /// This method is used to set the read-only status of the association property. 
00211     /// This method should only be called by FDO providers to set to read-only the association 
00212     /// property added internally to the associated class that represent the reverse association 
00213     /// property.
00214     /// 
00215     /// \param value 
00216     /// Input the read-only flag
00217     /// 
00218     /// \return
00219     /// Returns nothing.
00220     /// 
00221     FDO_API  void SetIsReadOnly(bool value);
00222 
00223     /// \brief
00224     /// This method is used to return the association multiplicity from the owner class 
00225     /// side. See SetMultiplicity method for description of the possible values.
00226     /// 
00227     /// \return
00228     /// Returns a FdoString that represent the multiplicity.
00229     /// 
00230     FDO_API FdoString* GetMultiplicity();
00231 
00232     /// \brief
00233     /// This method is used to set the association multiplicity from the property owner class side. 
00234     /// The only possible values are 1 or m. If the multiplicity is set to 1, then only one instance
00235     /// of the owning class can be associated to a given instance of the associated class. If the 
00236     /// multiplicity is set to m, then many instances of the owning class can be associated to the 
00237     /// same instance of the associated class.
00238     /// 
00239     /// \param value 
00240     /// The multiplicity from the property owner class side. Valid values are:  1 or m.
00241     /// 
00242     /// \return
00243     /// Returns nothing.
00244     /// 
00245     FDO_API  void SetMultiplicity(FdoString* value);
00246 
00247     /// \brief
00248     /// This method is used to return the association multiplicity from the associated class 
00249     /// side. See SetReverseMultiplicity method for description of the possible values.
00250     /// 
00251     /// \return
00252     /// Returns a FdoString that represent the reverse multiplicity.
00253     /// 
00254     FDO_API FdoString* GetReverseMultiplicity();
00255 
00256     /// \brief
00257     /// This method is used to set the association multiplicity from the associated class side.
00258     /// The only possible values are 0 or 1. If the multiplicity is set to 0, then it is not mandatory 
00259     /// to initialize the association property when a new object is created. If the multiplicity is 
00260     /// set to 1, then the association property must be initialized when a new object is created.
00261     /// 
00262     /// \param value 
00263     /// The multiplicity from the associated class side. Valid values are:  0 or 1.
00264     /// 
00265     /// \return
00266     /// Returns nothing.
00267     /// 
00268     FDO_API  void SetReverseMultiplicity(FdoString* value);
00269 
00270 /// \cond DOXYGEN-IGNORE
00271     /// Public non-API functions for XML support
00272 
00273     /// Update this property from the given property.
00274     virtual void Set( FdoPropertyDefinition* pProperty, FdoSchemaXmlContext* pContext );
00275 
00276     /// Initialize this property from its XML attributes
00277     virtual void InitFromXml(const FdoString* propertyTypeName, FdoSchemaXmlContext* pContext, FdoXmlAttributeCollection* attrs);
00278 
00279     /// Handle sub-elements such as properties
00280     /// Element start
00281     virtual FdoXmlSaxHandler* XmlStartElement(
00282         FdoXmlSaxContext* context, 
00283         FdoString* uri, 
00284         FdoString* name, 
00285         FdoString* qname, 
00286         FdoXmlAttributeCollection* atts
00287     );
00288     /// Element end
00289     virtual FdoBoolean XmlEndElement(
00290         FdoXmlSaxContext* context, 
00291         FdoString* uri, 
00292         FdoString* name, 
00293         FdoString* qname
00294     );
00295 
00296     /// Serialize this property to XML.
00297     virtual void _writeXml( FdoSchemaXmlContext* pContext );
00298 
00299     virtual void SetParent(FdoSchemaElement* value);
00300 
00301 private:
00302     wchar_t*                                m_reverseName;
00303     FdoClassDefinition*                     m_associatedClass;
00304     FdoDeleteRule                           m_deleteRule;
00305     bool                                    m_lockCascade;
00306     bool                                    m_isReadOnly;
00307     wchar_t*                                m_multiplicity;
00308     wchar_t*                                m_reverseMultiplicity;
00309     FdoDataPropertyDefinitionCollection*    m_identityProperties;
00310     FdoDataPropertyDefinitionCollection*    m_identityReverseProperties;
00311 
00312     FdoStringsP                             m_idPropNames;
00313     FdoStringsP                             m_idRvrsPropNames;
00314     FdoDataPropertyDefinition*              m_dataPropertyHandler;
00315     bool                                    m_Default;
00316 
00317 private:
00318     FdoString* DeleteRuleToString(FdoDeleteRule rule);
00319     FdoDeleteRule StringToDeleteRule(FdoString *string);
00320 
00321     /// Used to add a read-only association property to the associated class.
00322     void ModifyAssociatedClass();
00323 
00324 protected:
00325     /// FdoFeatureSchema::RejectChanges() support
00326     virtual void    _StartChanges();
00327     virtual void    _BeginChangeProcessing();
00328     virtual void    _AcceptChanges();
00329     virtual void    _RejectChanges();
00330     virtual void    _EndChangeProcessing();
00331     FdoClassDefinition*                     m_associatedClassCHANGED;
00332     FdoDeleteRule                           m_deleteRuleCHANGED;
00333     bool                                    m_lockCascadeCHANGED;
00334     bool                                    m_isReadOnlyCHANGED;
00335     wchar_t*                                m_multiplicityCHANGED;
00336     wchar_t*                                m_reverseMultiplicityCHANGED;
00337     wchar_t*                                m_reverseNameCHANGED;
00338 /// \endcond
00339 };
00340 
00341 /// \brief
00342 /// FdoAssociationPropertyP is a FdoPtr on FdoAssociationPropertyDefinition, provided for convenience.
00343 typedef FdoPtr<FdoAssociationPropertyDefinition> FdoAssociationPropertyP;
00344 
00345 #endif
00346 
00347 

Comments or suggestions? Send us feedback.