FDO API Reference Feature Data Objects

Flags.h

Go to the documentation of this file.
00001 #ifndef FDO_XML_FLAGS_H
00002 #define FDO_XML_FLAGS_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 #include <FdoStd.h>
00022 
00023 class FdoPhysicalSchemaMappingCollection;
00024 
00025 /// \brief
00026 /// FdoXmlFlags defines various options for serializing and deserializing
00027 /// FDO element to and from XML Documents.
00028 class FdoXmlFlags : public FdoIDisposable
00029 {
00030 public:
00031     /// \brief
00032     /// The FdoXmlFlags::ErrorLevel determines how strict the error reporting 
00033     /// is when a Feature Schema is read from an XML Document. For each errorLevel a 
00034     /// certain level of round-trip fidelity is guaranteed if the read succeeds.
00035     /// 
00036     /// \param ErrorLevel_High 
00037     /// the read fails with an exception when the 
00038     /// Feature Schema cannot be read without alteration. If the Feature Schema 
00039     /// is read successfully from document A and then written to document B, 
00040     /// documents A and B are guaranteed to be identical. This errorLevel should be 
00041     /// used when no alterations to the Feature Schema can be tolerated
00042     /// \param ErrorLevel_Normal 
00043     /// fails if the Feature Schema cannot be read 
00044     /// without changing the domain of its conforming instance documents. If the 
00045     /// Feature Schema is read successfully from document A and then written to 
00046     /// document B, any instance document that conforms to the document A schema 
00047     /// will also conform to the document B schema. Any instance document that does
00048     /// not conform to A does not conform to B. However, documents A and B will not 
00049     /// necessarily be identical.
00050     /// \param ErrorLevel_Low 
00051     /// similar to ErrorLevel_Normal except that the 
00052     /// instance document domain is allowed to grow. If the Feature Schema is read 
00053     /// successfully from document A and then written to document B, any instance 
00054     /// document that conforms to the document A schema will also conform to the 
00055     /// document B schema. However a document that does not conform to the A schema 
00056     /// may or may not conform to the B schema.
00057     /// \param ErrorLevel_VeryLow 
00058     /// the read succeeds even if no level of 
00059     /// round-trip fidelity is maintained. If the Feature Schema is read successfully 
00060     /// from document A and then written to document B, any instance document that
00061     /// conforms to the document A schema may or may not conform to the document B 
00062     /// schema. A document that does not conform to the A schema may or may not 
00063     /// conform to the B schema. This errorLevel is useful for reading schemas from 
00064     /// external sources into FDO when it doesn’t matter how much the schemas are 
00065     /// altered during the read.
00066     /// 
00067     enum ErrorLevel {
00068         ErrorLevel_High,
00069         ErrorLevel_Normal,
00070         ErrorLevel_Low,
00071         ErrorLevel_VeryLow
00072     };
00073 
00074     /// \brief
00075     /// Constructs an FdoXmlFlags object.
00076     /// 
00077     /// \param url 
00078     /// Input When writing  Feature Schemas, this specifies the 
00079     /// prefix for the target namespace for any schemas that are written. The XML 
00080     /// format for Feature Schemas is OGC GML, so a targetNamespace for the 
00081     /// xs:schema element is required. This namespace will be http://[url]/[schema_name].
00082     /// \param errorLevel 
00083     /// Input The error level for reading feature schemas.
00084     /// \param nameAdjust 
00085     /// Input true: apply name adjustment to all elements. 
00086     /// false: apply name adjustment only to elements with fdo:nameAdjust="true"
00087     /// 
00088     /// \return
00089     /// Returns FdoXmlFlags
00090     /// 
00091     FDO_API static FdoXmlFlags* Create( 
00092         FdoString* url = L"fdo.osgeo.org/schemas/feature",
00093         ErrorLevel errorLevel = ErrorLevel_Normal,
00094         FdoBoolean nameAdjust = true
00095     );
00096 
00097     /// \brief
00098     /// Sets the target namespace prefix, see FdoXmlFlags::Create().
00099     /// 
00100     /// \param url 
00101     /// Input the target namespace prefix.
00102     /// 
00103     FDO_API void SetUrl( FdoString* url );
00104 
00105     /// \brief
00106     /// Gets the target namespace prefix, see FdoXmlFlags::Create().
00107     /// 
00108     /// \return
00109     /// Returns the target namespace prefix.
00110     /// 
00111     FDO_API FdoString* GetUrl() const;
00112 
00113     /// \brief
00114     /// Sets the error level, see FdoXmlFlags::Create().
00115     /// 
00116     /// \param url 
00117     /// Input the error level.
00118     /// 
00119     FDO_API void SetErrorLevel( ErrorLevel errorLevel );
00120 
00121     /// \brief
00122     /// Gets the current error level, see FdoXmlFlags::Create().
00123     /// 
00124     /// \return
00125     /// Returns the error level.
00126     /// 
00127     FDO_API ErrorLevel GetErrorLevel() const;
00128 
00129     /// \brief
00130     /// Sets the name adjustment flag, see FdoXmlFlags::Create().
00131     /// 
00132     /// \param url 
00133     /// Input the name adjustment flag.
00134     /// 
00135     FDO_API void SetNameAdjust( FdoBoolean nameAdjust );
00136 
00137     /// \brief
00138     /// Gets the name adjustment flag, see FdoXmlFlags::Create().
00139     /// 
00140     /// \return
00141     /// Returns the name adjustment flag.
00142     /// 
00143     FDO_API FdoBoolean GetNameAdjust() const;
00144 
00145     /// \brief
00146     /// Sets the Schema Name as Prefix flag. This flag controls how
00147     /// an FDO Feature Schema name is generated when the schema is read
00148     /// from GML.
00149     /// 
00150     /// \param schemaNameAsPrefix 
00151     /// Input when true, the Feature Schema 
00152     /// name is set to the prefix from the xmlns namespace declaration for 
00153     /// the schema's targetNamespace. The target namespace prefix flag on this 
00154     /// object is ignored
00155     /// in this case. If no suitable namespace declaration can be found,
00156     /// the Feature Schema name is set as if this flag were false.
00157     /// Schemas cannot be round-tripped when this flag is true. Therefore, it
00158     /// may only be set to true when the current ErrorLevel is VeryLow.
00159     /// Caution must be observed when using this flag. Unpredictable results
00160     /// can occur if a GML Schema uses different prefixes for its 
00161     /// targetNamespace in different parts of the schema.
00162     /// 
00163     FDO_API void SetSchemaNameAsPrefix( FdoBoolean schemaNameAsPrefix );
00164 
00165     /// \brief
00166     /// Gets the Schema Name as Prefix flag.
00167     /// 
00168     /// \return
00169     /// Returns the Schema Name as Prefix flag.
00170     /// 
00171     FDO_API FdoBoolean GetSchemaNameAsPrefix() const;
00172 
00173     /// \brief
00174     /// Sets the Use GML ID flag.
00175     /// 
00176     /// \param schemaNameAsPrefix 
00177     /// Input when true, the feature id ( fid in GML 2, gml:id in GML 3)
00178     /// becomes the identity property of all feature classes.
00179     /// 
00180     FDO_API void SetUseGmlId( FdoBoolean schemaNameAsPrefix );
00181 
00182     /// \brief
00183     /// Gets the Use GML ID flag.
00184     /// 
00185     /// \return
00186     /// Returns the Use GML ID flag.
00187     /// 
00188     FDO_API FdoBoolean GetUseGmlId() const;
00189 
00190     /// \brief
00191     /// Sets the Schema Mapping Overrides for translating schemas 
00192     /// between GML and FDO. 
00193     /// 
00194     /// \param mappings 
00195     /// Input the Schema Mapping Overrides. This collection
00196     /// can contain an FdoXmlSchemaMapping element for each Feature Schema that
00197     /// may be written or read. When a Feature Schema is read or written to or 
00198     /// from GML, this collection is checked for an FdoXmlSchemaMapping item named 
00199     /// the same as the feature schema. If present, the hints in this item 
00200     /// affect how the feature schema is read or written. The Schema Mapping 
00201     /// Overrides also control how features are read since they 
00202     /// can override the default correspondences between feature class names 
00203     /// and their GML element names.
00204     /// 
00205     FDO_API void SetSchemaMappings( FdoPhysicalSchemaMappingCollection* mappings );
00206 
00207     /// \brief
00208     /// Gets the current Schema Mapping Overrides.
00209     /// 
00210     /// \return
00211     /// Returns FdoXmlSchemaMappingCollection*.
00212     /// 
00213     FDO_API FdoPhysicalSchemaMappingCollection* GetSchemaMappings() const;
00214 
00215 protected:
00216     /// default constructor to keep linux from complaining
00217     FdoXmlFlags() {}
00218     FDO_API FdoXmlFlags( FdoString* url, ErrorLevel errorLevel, FdoBoolean nameAdjust );
00219     FDO_API virtual ~FdoXmlFlags();
00220 
00221 /// \cond DOXYGEN-IGNORE
00222     //Deletes myself
00223     FDO_API virtual void Dispose();
00224 /// \endcond
00225 
00226 private:
00227     ErrorLevel mErrorLevel;
00228     FdoStringP mUrl;
00229     FdoBoolean mNameAdjust;
00230     FdoBoolean mSchemaNameAsPrefix;
00231     FdoBoolean mUseGmlId;
00232     FdoPhysicalSchemaMappingCollection* mSchemaMappings;
00233 };
00234 
00235 /// \brief
00236 /// FdoXmlFlagsP is a FdoPtr on FdoXmlFlags, provided for convenience.
00237 typedef FdoPtr<FdoXmlFlags> FdoXmlFlagsP;
00238 
00239 #endif
00240 
00241 

Comments or suggestions? Send us feedback.