Property.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 1996-2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00008 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00009 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00010 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00011 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00012 //
00013 //  Use, duplication, or disclosure by the U.S. Government is subject to
00014 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00015 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00016 //  Data and Computer Software), as applicable.
00017 //
00018 
00019 
00020 #ifndef _DWFTK_PROPERTY_H
00021 #define _DWFTK_PROPERTY_H
00022 
00023 
00028 
00029 
00030 #include "dwfcore/STL.h"
00031 #include "dwfcore/Owner.h"
00032 #include "dwfcore/Vector.h"
00033 #include "dwfcore/SkipList.h"
00034 #include "dwfcore/paging/Proxy.h"
00035 
00036 using namespace DWFCore;
00037 
00038 #include "dwf/Toolkit.h"
00039 #include "dwf/package/XML.h"
00040 #include "dwf/package/reader/PackageReader.h"
00041 #include "dwf/package/writer/PackageWriter.h"
00042 
00043 
00044 
00045 namespace DWFToolkit
00046 {
00047 
00058 class DWFProperty : public DWFXMLBuildable
00059 
00060 #ifndef DWFTK_READ_ONLY
00061                   , public DWFXMLSerializable
00062 #endif
00063                   , public IDWFOwnable
00064                   _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00065 {
00066 
00067 public:
00068 
00072     typedef _DWFTK_STD_VECTOR(DWFProperty*) tList;
00076     typedef DWFVectorIterator<DWFProperty*, _DWFTK_STL_ALLOCATOR<DWFProperty*> >             tListIterator;
00080     typedef DWFOrderedVector<DWFProperty*>              tOrderedList;
00084     typedef DWFStringKeyChainedSkipList<DWFProperty*>   tMap;
00089     typedef DWFCachingIterator<DWFProperty*>            tCachingIterator;
00093     typedef DWFIterator<DWFProperty*>                   tIterator;
00094 
00098         typedef pair<DWFString, DWFString>              tAttributePair;
00099         typedef _DWFTK_STD_VECTOR(tAttributePair)       tAttributeList;
00100         typedef std::map<DWFString, tAttributeList>     tAttributeMap;
00101 
00102 public:
00103 
00109     _DWFTK_API
00110     DWFProperty()
00111         throw();
00112 
00123     _DWFTK_API
00124     DWFProperty( const DWFString& zName,
00125                  const DWFString& zValue,
00126                  const DWFString& zCategory = /*NOXLATE*/L"",
00127                  const DWFString& zType = /*NOXLATE*/L"",
00128                  const DWFString& zUnits = /*NOXLATE*/L"" )
00129         throw();
00130 
00136     _DWFTK_API
00137     virtual ~DWFProperty()
00138         throw();
00139 
00146     _DWFTK_API
00147     DWFProperty( const DWFProperty& rProperty )
00148         throw();
00149 
00156     _DWFTK_API
00157     DWFProperty& operator=( const DWFProperty& rProperty )
00158         throw();
00159 
00166     _DWFTK_API
00167     const DWFString& name() const
00168         throw()
00169     {
00170                 return *oPropertyContent->_pszName;
00171     }
00172 
00179     _DWFTK_API
00180     void setName( const DWFString& zName )
00181         throw();
00182 
00189     _DWFTK_API
00190     const DWFString& value() const
00191         throw()
00192     {
00193                 return *oPropertyContent->_pszValue;
00194     }
00195 
00202     _DWFTK_API
00203     void setValue( const DWFString& zValue )
00204         throw();
00205 
00212     _DWFTK_API
00213     const DWFString& category() const
00214         throw()
00215     {
00216                 return *oPropertyContent->_pszCategory;
00217     }
00218 
00225     _DWFTK_API
00226     void setCategory( const DWFString& zCategory )
00227         throw();
00228 
00235     _DWFTK_API
00236     const DWFString& type() const
00237         throw()
00238     {
00239                 return *oPropertyContent->_pszType;
00240     }
00241 
00248     _DWFTK_API
00249     void setType( const DWFString& zType )
00250         throw();
00251 
00258     _DWFTK_API
00259     const DWFString& units() const
00260         throw()
00261     {
00262                 return *oPropertyContent->_pszUnits;
00263     }
00264 
00271     _DWFTK_API
00272     void setUnits( const DWFString& zUnits )
00273         throw();
00274 
00278     _DWFTK_API
00279     virtual void parseAttributeList( const char** ppAttributeList )
00280         throw( DWFException );
00281 
00285         _DWFTK_API
00286         const tAttributeMap& getCustomizedAttributeList()
00287                 throw();
00288 
00292     _DWFTK_API
00293     virtual void own( DWFOwner& rOwner )
00294         throw( DWFException );
00295 
00299     _DWFTK_API
00300     virtual bool disown( DWFOwner& rOwner, bool bForget )
00301         throw( DWFException );
00302 
00306     _DWFTK_API
00307     virtual DWFOwner* owner()
00308         throw( DWFException );
00309 
00313     _DWFTK_API
00314     virtual void observe( DWFOwner& rObserver )
00315         throw( DWFException );
00316 
00320     _DWFTK_API
00321     virtual bool unobserve( DWFOwner& rObserver )
00322         throw( DWFException );
00323 
00327         _DWFTK_API
00328     void _notifyDelete()
00329         throw();
00330 
00349     _DWFTK_API
00350     void addXMLAttribute( const DWFXMLNamespace&    rNamespace,
00351                           const DWFString&          zName,
00352                           const DWFString&          zValue )
00353        throw( DWFException );
00354 
00355 #ifndef DWFTK_READ_ONLY
00359     _DWFTK_API
00360     void serializeXML( DWFXMLSerializer& rSerializer, unsigned int nFlags )
00361         throw( DWFException );
00362 
00363 #endif
00364 
00365 private:
00366 
00368         struct tPropertyContent
00369         {
00370                 tPropertyContent();
00371 
00372                 tPropertyContent(const tPropertyContent& rhs);
00373 
00374                 tPropertyContent& operator=(const tPropertyContent& rhs);
00375 
00376                 const DWFString* _pszName;    
00377                 const DWFString* _pszCategory;
00378                 const DWFString* _pszType;
00379                 const DWFString* _pszUnits;
00380                 const DWFString* _pszValue;
00381 
00382                 DWFOwner*                _pOwner;
00383                 DWFSortedList<DWFOwner*> _oOwnerObservers;
00384 
00385                 typedef pair<DWFString, DWFString>              _tAttribute;
00386                 typedef _DWFTK_STD_VECTOR(_tAttribute)          _tAttributeList;
00387                 typedef std::map<DWFString, _tAttributeList>    _tAttributeMap;
00388                 _tAttributeMap  _oAttributes;
00389 
00390         };
00391 
00392         friend class tPropertyArchive;
00393 
00403         class tPropertyArchive
00404         {
00405         public:
00406 
00407                 typedef DWFToolkit::DWFProperty::tPropertyContent tValueType;
00408                 typedef tValueType* tPointer;
00409                 typedef const tValueType* tConstPointer;
00410                 typedef DWFPagingAdapter::tHandleType tHandleType;
00411 
00413                 static void load(DWFInputAdapter& rInputAdapter, 
00414                         tHandleType hHandle, 
00415                         tPointer pObject);
00416 
00418                 static tHandleType save(DWFOutputAdapter& rOutputAdapter, 
00419                         tConstPointer p, 
00420                         tHandleType old);
00421 
00422         private:
00423 
00424                 typedef std::back_insert_iterator<DWFInputAdapter::tBufferType> tOutputIterator;
00425 
00426                 static void _copyByte(const void* src, 
00427                         size_t size, 
00428                         tOutputIterator itr);
00429 
00430                 static void * _loadStr(DWFString& str, void *pos);
00431         };
00432 
00433 public:
00440         DWFOwnable& toOwnable()
00441         {
00442                 return _toOwnable();
00443         }
00444 
00445 private:
00446         DWFOwnable& _toOwnable();       
00447 
00448         //specify the Archive type with tPropertyArchive instead of DWFArchive
00449         typedef DWFProxy<tPropertyContent, std::allocator<tPropertyContent>, tPropertyArchive> tImpType;
00450         tImpType oPropertyContent;
00451 
00452         static const DWFString _koEmpty;
00453         static DWFStringTable* _kpDataTable;
00454 };
00455 
00456 }
00457 
00458 #endif

Generated on Tue Jan 6 22:40:05 2009 for Autodesk DWF Toolkit by  doxygen 1.4.5