FDO API Reference Feature Data Objects

SchemaAttributeDictionary.h

Go to the documentation of this file.
00001 #ifndef _SCHEMAATTRIBUTEDICTIONARY_H_
00002 #define _SCHEMAATTRIBUTEDICTIONARY_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 
00027 class FdoSchemaElement;
00028 class FdoSchemaXmlContext;
00029 
00030 /// \brief
00031 /// The FdoSchemaAttributeDictionary class maintains a dictionary of named 
00032 /// attributes that provide a generic extensibility mechanism for objects
00033 /// in the feature schema. This mechanism can be used to dynamically extend 
00034 /// schema elements in either an application- or provider-specific manner.
00035 class FdoSchemaAttributeDictionary : 
00036     public FdoIDisposable,
00037     public virtual FdoXmlSaxHandler
00038 {
00039     friend class FdoSchemaElement;
00040 
00041 protected:
00042 /// \cond DOXYGEN-IGNORE
00043     FdoSchemaAttributeDictionary()
00044     {
00045     }   
00046     FdoSchemaAttributeDictionary(FdoSchemaElement& parent);
00047 
00048     virtual ~FdoSchemaAttributeDictionary();
00049 
00050     virtual void Dispose();
00051 
00052     /// Write this SAD to XML.
00053     virtual void _writeXml( FdoSchemaXmlContext* pContext );
00054 /// \endcond
00055 
00056 public:
00057     /// \brief
00058     /// Gets the number of attributes in the dictionary.
00059     /// 
00060     /// \return
00061     /// Returns the number of attributes in the dictionary
00062     /// 
00063     FDO_API FdoInt32 GetCount();
00064 
00065     /// \brief
00066     /// Gets an array containing all of the attribute names in the dictionary.
00067     /// 
00068     /// \param length 
00069     /// Output number of attribute names
00070     /// 
00071     /// \return
00072     /// Returns an array containing all of the attribute names in the dictionary
00073     /// 
00074     FDO_API FdoString** GetAttributeNames(FdoInt32& length);
00075 
00076     /// \brief
00077     /// Gets the value of the specified attribute.
00078     /// 
00079     /// \param name 
00080     /// Input attribute name
00081     /// 
00082     /// \return
00083     /// Returns the value of the specified attribute
00084     /// 
00085     FDO_API FdoString* GetAttributeValue(FdoString* name);
00086 
00087     /// \brief
00088     /// Sets the value of the specified attribute.
00089     /// 
00090     /// \param name 
00091     /// Input name
00092     /// \param value 
00093     /// Input value
00094     /// 
00095     /// \return
00096     /// Returns nothing
00097     /// 
00098     FDO_API void SetAttributeValue(FdoString* name, FdoString* value);
00099 
00100     /// \brief
00101     /// Returns true if the dictionary contains the specified attribute.
00102     /// 
00103     /// \param name 
00104     /// Input attribute name
00105     /// 
00106     /// \return
00107     /// Returns true if the dictionary contains the specified attribute
00108     /// 
00109     FDO_API bool ContainsAttribute(FdoString* name);
00110 
00111     /// \brief
00112     /// Adds the specified attribute with the specified value to the dictionary.
00113     /// 
00114     /// \param name 
00115     /// Input name
00116     /// \param value 
00117     /// Input value
00118     /// 
00119     /// \return
00120     /// Returns nothing
00121     /// 
00122     FDO_API void Add(FdoString* name, FdoString* value);
00123 
00124     /// \brief
00125     /// Removes the specified attribute and its value from the dictionary.
00126     /// 
00127     /// \param name 
00128     /// Input name
00129     /// 
00130     /// \return
00131     /// Returns nothing
00132     /// 
00133     FDO_API void Remove(FdoString* name);
00134 
00135     /// \brief
00136     /// Clears all attributes and values from the dictionary.
00137     /// 
00138     /// \return
00139     /// Returns nothing
00140     /// 
00141     FDO_API void Clear();
00142 
00143 /// \cond DOXYGEN-IGNORE
00144     /// Public non-API functions for XML support
00145 
00146     /// Handle the start of a dictionary element
00147     virtual FdoXmlSaxHandler* XmlStartElement(
00148         FdoXmlSaxContext* context, 
00149         FdoString* uri, 
00150         FdoString* name, 
00151         FdoString* qname, 
00152         FdoXmlAttributeCollection* atts
00153     );
00154 
00155     /// Handle the end of a dictionary element
00156     virtual FdoBoolean XmlEndElement(
00157         FdoXmlSaxContext* context, 
00158         FdoString* uri, 
00159         FdoString* name, 
00160         FdoString* qname
00161     );
00162 
00163 
00164 private:
00165     FdoInt32            m_alloc;
00166     FdoInt32            m_used;
00167     wchar_t**           m_names;
00168     wchar_t**           m_values;
00169     FdoSchemaElement*   m_parent;
00170 
00171     /// SAX Handler for reading dictionary element values
00172     FdoXmlCharDataHandlerP        m_XmlContentHandler;
00173     /// When deserializing from XML, contains the name of the 
00174     /// current SAD item.
00175     FdoStringP                    m_nextName;
00176 
00177 
00178 protected:
00179     /// FdoFeatureSchema::RejectChanges() support
00180     virtual void    _StartChanges();
00181     virtual void    _BeginChangeProcessing();
00182     virtual void    _AcceptChanges();
00183     virtual void    _RejectChanges();
00184     virtual void    _EndChangeProcessing();
00185     unsigned int        m_changeInfoState;
00186     FdoInt32            m_allocCHANGED;
00187     FdoInt32            m_usedCHANGED;
00188     wchar_t**           m_namesCHANGED;
00189     wchar_t**           m_valuesCHANGED;
00190 
00191     /// States stored in the m_changeInfoState bitfield flag
00192     static const unsigned int   CHANGEINFO_PRESENT      = 0x00000001;
00193     static const unsigned int   CHANGEINFO_PROCESSING   = 0x00000002;
00194     static const unsigned int   CHANGEINFO_PROCESSED    = 0x00000004;
00195 /// \endcond
00196 };
00197 
00198 /// \brief
00199 /// FdoSADP is a FdoPtr on FdoSchemaAttributeDictionary, provided for convenience.
00200 typedef FdoPtr<FdoSchemaAttributeDictionary> FdoSADP;
00201 
00202 
00203 #endif
00204 
00205 

Comments or suggestions? Send us feedback.