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. The following list contains example argument values for the FDO data types: 00229 /// \li Boolean: \c "True" or \c "False" 00230 /// \li Byte: \c "255" 00231 /// \li DateTime: \c "01/16/2008" 00232 /// \li Single/Double: \c "1.0" 00233 /// \li Int16/Int32/Int64: \c "5" 00234 /// \li String: \c "a string" 00235 /// \li BLOB/CLOB: not supported 00236 /// 00237 /// \return 00238 /// Returns nothing 00239 /// 00240 FDO_API void SetDefaultValue(FdoString* value); 00241 00242 /// \brief 00243 /// Sets a Boolean value that indicates if this is an autogenerated property. 00244 /// 00245 /// \param value 00246 /// Input a Boolean value that indicates if this property should 00247 /// be automatically generated by the provider. If true, then the provider will auto-generate 00248 /// unique id values for objects of the class containing this property. 00249 /// The provider will set the attribute properties to read-only. 00250 /// If the provider does not support auto-generation or if the data types of the 00251 /// property is not supported for unique id generation by the provider, then the provider will 00252 /// throw an AutoGenerationException. If false, then the provider will not autogenerate values. 00253 /// 00254 /// \return 00255 /// Returns nothing 00256 /// 00257 FDO_API void SetIsAutoGenerated(bool value); 00258 00259 /// \brief 00260 /// Returns a Boolean value that indicates if this is an autogenerated property. 00261 /// 00262 /// \return 00263 /// Returns a Boolean value. 00264 /// 00265 FDO_API bool GetIsAutoGenerated(); 00266 00267 /// \brief 00268 /// Returns the value constraint of this data property. 00269 /// 00270 /// \return 00271 /// Returns the FdoPropertyValueConstraint or NULL if not set. 00272 /// 00273 FDO_API FdoPropertyValueConstraint* GetValueConstraint(); 00274 00275 /// \brief 00276 /// Sets the value constraint of this data property. 00277 /// 00278 /// \param value 00279 /// Set the value constraint of this data property. 00280 /// 00281 /// \return 00282 /// Returns nothing 00283 /// 00284 FDO_API void SetValueConstraint( FdoPropertyValueConstraint* value ); 00285 00286 /// \cond DOXYGEN-IGNORE 00287 // Public non-API functions for XML and Schema Merge support 00288 00289 // Update this property from the given property. 00290 virtual void Set( FdoPropertyDefinition* pProperty, FdoSchemaMergeContext* pContext ); 00291 00292 /// Initialize this property from its XML attributes 00293 virtual void InitFromXml(FdoString* propertyTypeName, FdoSchemaXmlContext* pContext, FdoXmlAttributeCollection* attrs); 00294 00295 /// read the geometric types from XML sub-elements. 00296 /// Element start 00297 virtual FdoXmlSaxHandler* XmlStartElement( 00298 FdoXmlSaxContext* context, 00299 FdoString* uri, 00300 FdoString* name, 00301 FdoString* qname, 00302 FdoXmlAttributeCollection* atts 00303 ); 00304 /// Element end 00305 virtual FdoBoolean XmlEndElement( 00306 FdoXmlSaxContext* context, 00307 FdoString* uri, 00308 FdoString* name, 00309 FdoString* qname 00310 ); 00311 00312 /// Serialize this property to XML. 00313 virtual void _writeXml( FdoSchemaXmlContext* pContext ); 00314 00315 private: 00316 FdoDataType m_dataType; 00317 bool m_readOnly; 00318 FdoInt32 m_length; 00319 FdoInt32 m_precision; 00320 FdoInt32 m_scale; 00321 bool m_nullable; 00322 wchar_t* m_defaultValue; 00323 bool m_autogenerated; 00324 FdoPropertyValueConstraint *m_propertyValueConstraint; 00325 00326 protected: 00327 /// FdoFeatureSchema::RejectChanges() support 00328 virtual void _StartChanges(); 00329 virtual void _RejectChanges(); 00330 virtual void _AcceptChanges(); 00331 FdoDataType m_dataTypeCHANGED; 00332 bool m_readOnlyCHANGED; 00333 FdoInt32 m_lengthCHANGED; 00334 FdoInt32 m_precisionCHANGED; 00335 FdoInt32 m_scaleCHANGED; 00336 bool m_nullableCHANGED; 00337 wchar_t* m_defaultValueCHANGED; 00338 bool m_autogeneratedCHANGED; 00339 FdoPropertyValueConstraint *m_propertyValueConstraintCHANGED; 00340 /// \endcond 00341 }; 00342 00343 /// \ingroup (typedefs) 00344 /// \brief 00345 /// FdoDataPropertyP is a FdoPtr on FdoDataPropertyDefinition, provided for convenience. 00346 typedef FdoPtr<FdoDataPropertyDefinition> FdoDataPropertyP; 00347 00348 #endif 00349 00350