00001 #ifndef _DATAPROPERTYDEFINITION_H_ 00002 #define _DATAPROPERTYDEFINITION_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/ObjectType.h> 00028 #include <Fdo/Schema/DataType.h> 00029 #include <Fdo/Schema/PropertyType.h> 00030 #include <Fdo/Schema/PropertyValueConstraint.h> 00031 00032 /// \brief 00033 /// The FdoDataPropertyDefinition class derives from FdoPropertyDefinition and represents simple 00034 /// values or collections of simple values. FdoDataPropertyDefinitions can take on 00035 /// any of the data types listed in the FdoDataType enumeration. 00036 class FdoDataPropertyDefinition : public FdoPropertyDefinition 00037 { 00038 template <class OBJ> friend class FdoSchemaCollection; 00039 friend class FdoObjectPropertyDefinition; 00040 00041 /// \cond DOXYGEN-IGNORE 00042 protected: 00043 /// Constructs a default instance of an FdoDataPropertyDefinition. 00044 FdoDataPropertyDefinition(); 00045 00046 /// Constructs an instance of an FdoDataPropertyDefinition using the specified arguments 00047 FdoDataPropertyDefinition(FdoString* name, FdoString* description, bool system = false); 00048 00049 /// Common initialization code called by all constructors: 00050 void Init(); 00051 00052 virtual ~FdoDataPropertyDefinition(); 00053 00054 virtual void Dispose(); 00055 /// \endcond 00056 00057 public: 00058 /// \brief 00059 /// Constructs a default instance of an FdoDataPropertyDefinition. 00060 /// 00061 /// \return 00062 /// Returns FdoDataPropertyDefinition 00063 /// 00064 FDO_API static FdoDataPropertyDefinition* Create(); 00065 00066 /// \brief 00067 /// Constructs an instance of an FdoDataPropertyDefinition using the specified arguments 00068 /// 00069 /// \param name 00070 /// Input name 00071 /// \param description 00072 /// Input description 00073 /// \param system 00074 /// Input true if this is a system generated property, otherwise falseds. 00075 /// 00076 /// \return 00077 /// Returns FdoDataPropertyDefinition 00078 /// 00079 FDO_API static FdoDataPropertyDefinition* Create(FdoString* name, FdoString* description, bool system = false); 00080 00081 /// \brief 00082 /// Gets the concrete property type. 00083 /// 00084 /// \return 00085 /// Returns the concrete property type 00086 /// 00087 FDO_API virtual FdoPropertyType GetPropertyType(); 00088 00089 /// \brief 00090 /// Gets the FdoDataType of this property. 00091 /// 00092 /// \return 00093 /// Returns FdoDataType of this property 00094 /// 00095 FDO_API FdoDataType GetDataType(); 00096 00097 /// \brief 00098 /// Sets the FdoDataType of this property. 00099 /// 00100 /// \param dataType 00101 /// Input the FdoDataType of this property 00102 /// 00103 /// \return 00104 /// Returns nothing 00105 /// 00106 FDO_API void SetDataType(FdoDataType dataType); 00107 00108 /// \brief 00109 /// Returns a Boolean value that indicates if this property is read-only. 00110 /// 00111 /// \return 00112 /// Returns a Boolean value 00113 /// 00114 FDO_API bool GetReadOnly(); 00115 00116 /// \brief 00117 /// Sets a Boolean value that indicates if this property is read-only. 00118 /// 00119 /// \param value 00120 /// Input a Boolean value that indicates if this property is read-only 00121 /// 00122 /// \return 00123 /// Returns nothing 00124 /// 00125 FDO_API void SetReadOnly(bool value); 00126 00127 /// \brief 00128 /// Gets the length of a String, BLOB, or CLOB data property. This value 00129 /// does not apply to any other FdoDataType. 00130 /// 00131 /// \return 00132 /// Returns the length of a String, BLOB, or CLOB data property 00133 /// 00134 FDO_API FdoInt32 GetLength(); 00135 00136 /// \brief 00137 /// Sets the length of a String, BLOB, or CLOB data property. This value is 00138 /// ignored for all other FdoDataType values. 00139 /// 00140 /// \param value 00141 /// Input the length of a String, BLOB, or CLOB data property 00142 /// 00143 /// \return 00144 /// Returns nothing 00145 /// 00146 FDO_API void SetLength(FdoInt32 value); 00147 00148 /// \brief 00149 /// Gets the precision (total number of digits) of a decimal data property. 00150 /// This value does not apply to any other FdoDataType. 00151 /// 00152 /// \return 00153 /// Returns the precision 00154 /// 00155 FDO_API FdoInt32 GetPrecision(); 00156 00157 /// \brief 00158 /// Sets the precision (total number of digits) of a decimal data property. 00159 /// This value is ignored for all other FdoDataType values. 00160 /// 00161 /// \param value 00162 /// Input the precision 00163 /// 00164 /// \return 00165 /// Returns nothing 00166 /// 00167 FDO_API void SetPrecision(FdoInt32 value); 00168 00169 /// \brief 00170 /// Gets the scale (number of digits to the right of the decimal point) of a 00171 /// decimal data property. This value does not apply to any other FdoDataType. 00172 /// 00173 /// \return 00174 /// Returns the scale 00175 /// 00176 FDO_API FdoInt32 GetScale(); 00177 00178 /// \brief 00179 /// Sets the scale (number of digits to the right of the decimal point) of a 00180 /// decimal data property. This value is ignored for all other FdoDataType values. 00181 /// 00182 /// \param value 00183 /// Input the scale 00184 /// 00185 /// \return 00186 /// Returns nothing 00187 /// 00188 FDO_API void SetScale(FdoInt32 value); 00189 00190 /// \brief 00191 /// Returns a Boolean value that indicates if this property's value can be 00192 /// null. 00193 /// 00194 /// \return 00195 /// Returns a Boolean value 00196 /// 00197 FDO_API bool GetNullable(); 00198 00199 /// \brief 00200 /// Sets a Boolean value that indicates if this property's value can be 00201 /// null. 00202 /// 00203 /// \param value 00204 /// Input a Boolean value that indicates if this property's value can be 00205 /// null 00206 /// 00207 /// \return 00208 /// Returns nothing 00209 /// 00210 FDO_API void SetNullable(bool value); 00211 00212 /// \brief 00213 /// Gets the default value for this property. The default value is used when 00214 /// an instance of the containing class is created without specifying a value 00215 /// for this property. 00216 /// 00217 /// \return 00218 /// Returns the default value 00219 /// 00220 FDO_API FdoString* GetDefaultValue(); 00221 00222 /// \brief 00223 /// Sets the default value for this property. The default value is used when 00224 /// an instance of the containing class is created without specifying a value 00225 /// for this property. 00226 /// 00227 /// \param value 00228 /// Input the default value. Required format depends on the DataType for this 00229 /// property. If FdoDataType_String then it can be any string. All single and 00230 /// double quote characters are treated as literals, rather than delimiters. 00231 /// For other data types, it must be in FDO Expression format. For example, 00232 /// DateTime default values must be "TIMESTAMP 'YYYY-MM-DD HH24:MM:SS'" or 00233 /// "DATE 'YYYY-MM-DD'". 00234 /// 00235 /// \return 00236 /// Returns nothing 00237 /// 00238 FDO_API void SetDefaultValue(FdoString* value); 00239 00240 /// \brief 00241 /// Sets a Boolean value that indicates if this is an autogenerated property. 00242 /// 00243 /// \param value 00244 /// Input a Boolean value that indicates if this property should 00245 /// be automatically generated by the provider. If true, then the provider will auto-generate 00246 /// unique id values for objects of the class containing this property. 00247 /// The provider will set the attribute properties to read-only. 00248 /// If the provider does not support auto-generation or if the data types of the 00249 /// property is not supported for unique id generation by the provider, then the provider will 00250 /// throw an AutoGenerationException. If false, then the provider will not autogenerate values. 00251 /// 00252 /// \return 00253 /// Returns nothing 00254 /// 00255 FDO_API void SetIsAutoGenerated(bool value); 00256 00257 /// \brief 00258 /// Returns a Boolean value that indicates if this is an autogenerated property. 00259 /// 00260 /// \return 00261 /// Returns a Boolean value. 00262 /// 00263 FDO_API bool GetIsAutoGenerated(); 00264 00265 /// \brief 00266 /// Returns the value constraint of this data property. 00267 /// 00268 /// \return 00269 /// Returns the FdoPropertyValueConstraint or NULL if not set. 00270 /// 00271 FDO_API FdoPropertyValueConstraint* GetValueConstraint(); 00272 00273 /// \brief 00274 /// Sets the value constraint of this data property. 00275 /// 00276 /// \param value 00277 /// Set the value constraint of this data property. 00278 /// 00279 /// \return 00280 /// Returns nothing 00281 /// 00282 FDO_API void SetValueConstraint( FdoPropertyValueConstraint* value ); 00283 00284 /// \cond DOXYGEN-IGNORE 00285 // Public non-API functions for XML and Schema Merge support 00286 00287 // Update this property from the given property. 00288 virtual void Set( FdoPropertyDefinition* pProperty, FdoSchemaMergeContext* pContext ); 00289 00290 /// Initialize this property from its XML attributes 00291 virtual void InitFromXml(FdoString* propertyTypeName, FdoSchemaXmlContext* pContext, FdoXmlAttributeCollection* attrs); 00292 00293 /// read the geometric types from XML sub-elements. 00294 /// Element start 00295 virtual FdoXmlSaxHandler* XmlStartElement( 00296 FdoXmlSaxContext* context, 00297 FdoString* uri, 00298 FdoString* name, 00299 FdoString* qname, 00300 FdoXmlAttributeCollection* atts 00301 ); 00302 /// Element end 00303 virtual FdoBoolean XmlEndElement( 00304 FdoXmlSaxContext* context, 00305 FdoString* uri, 00306 FdoString* name, 00307 FdoString* qname 00308 ); 00309 00310 /// Serialize this property to XML. 00311 virtual void _writeXml( FdoSchemaXmlContext* pContext ); 00312 00313 private: 00314 // Called when a default value failed validation 00315 void ThrowDefaultValueError( FdoString* defaultValue ); 00316 00317 00318 FdoDataType m_dataType; 00319 bool m_readOnly; 00320 FdoInt32 m_length; 00321 FdoInt32 m_precision; 00322 FdoInt32 m_scale; 00323 bool m_nullable; 00324 wchar_t* m_defaultValue; 00325 bool m_autogenerated; 00326 FdoPropertyValueConstraint *m_propertyValueConstraint; 00327 00328 protected: 00329 /// FdoFeatureSchema::RejectChanges() support 00330 virtual void _StartChanges(); 00331 virtual void _RejectChanges(); 00332 virtual void _AcceptChanges(); 00333 FdoDataType m_dataTypeCHANGED; 00334 bool m_readOnlyCHANGED; 00335 FdoInt32 m_lengthCHANGED; 00336 FdoInt32 m_precisionCHANGED; 00337 FdoInt32 m_scaleCHANGED; 00338 bool m_nullableCHANGED; 00339 wchar_t* m_defaultValueCHANGED; 00340 bool m_autogeneratedCHANGED; 00341 FdoPropertyValueConstraint *m_propertyValueConstraintCHANGED; 00342 /// \endcond 00343 }; 00344 00345 /// \ingroup (typedefs) 00346 /// \brief 00347 /// FdoDataPropertyP is a FdoPtr on FdoDataPropertyDefinition, provided for convenience. 00348 typedef FdoPtr<FdoDataPropertyDefinition> FdoDataPropertyP; 00349 00350 #endif 00351 00352