PropertyContainer.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 //  $Header: //DWF/Development/Components/Internal/DWF Toolkit/v7.6/develop/global/src/dwf/package/utility/PropertyContainer.h#1 $
00019 //  $DateTime: 2008/02/20 08:38:28 $
00020 //  $Author: appacsviewers $
00021 //  $Change: 84992 $
00022 //  $Revision: #1 $
00023 //
00024 
00025 
00026 #ifndef _DWFTK_PROPERTY_CONTAINER_H
00027 #define _DWFTK_PROPERTY_CONTAINER_H
00028 
00029 
00034 
00035 #include "dwfcore/STL.h"
00036 #include "dwfcore/DWFXMLSerializer.h"
00037 
00038 #include "dwf/Toolkit.h"
00039 #include "dwf/package/Property.h"
00040 
00041 
00042 namespace DWFToolkit
00043 {
00044 
00045 
00059 class DWFPropertyContainer : protected DWFOwner
00060                             _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00061 {
00062 
00063 public:
00064 
00068     typedef _DWFTK_STD_VECTOR(DWFPropertyContainer*)            tList;
00072     typedef DWFStringKeySkipList<DWFPropertyContainer*>         tMap;
00073 
00074 public:
00075 
00082     _DWFTK_API
00083     DWFPropertyContainer( const DWFString& zID = /*NOXLATE*/L"" )
00084         throw();
00085 
00094     _DWFTK_API
00095     virtual ~DWFPropertyContainer()
00096         throw();
00097 
00104     virtual const DWFString& id() const
00105     {
00106         return _zID;
00107     }
00108 
00120     _DWFTK_API
00121     virtual const DWFProperty* const findProperty( const DWFString& zName,
00122                                                    const DWFString& zCategory = /*NOXLATE*/L"" )
00123         throw();
00124 
00139     _DWFTK_API
00140     virtual DWFProperty::tMap::Iterator* getProperties( const DWFString& zCategory = /*NOXLATE*/L"" )
00141         throw();
00142 
00158     _DWFTK_API
00159     virtual DWFProperty::tIterator* getPropertiesInOrder( const DWFString& zCategory = /*NOXLATE*/L"" )
00160         throw();
00161 
00162 
00171     _DWFTK_API
00172     size_t getPropertyCount()
00173         throw()
00174     {
00175         return _oProperties.size();
00176     }
00177 
00186     _DWFTK_API
00187     size_t getOwnedPropertySetCount() const
00188         throw()
00189     {
00190         return _oContainers.size();
00191     }
00192 
00201     _DWFTK_API
00202     size_t getReferencedPropertySetCount() const
00203         throw()
00204     {
00205         return _oReferences.size();
00206     }
00207 
00217     _DWFTK_API
00218     virtual void addProperty( DWFProperty* pProperty,
00219                               bool         bOwnProperty )
00220         throw( DWFException );
00221 
00234     _DWFTK_API
00235     virtual DWFProperty* addProperty( const DWFString& zName,
00236                                       const DWFString& zValue,
00237                                       const DWFString& zCategory = /*NOXLATE*/L"",
00238                                       const DWFString& zType = /*NOXLATE*/L"",
00239                                       const DWFString& zUnits = /*NOXLATE*/L"" )
00240         throw( DWFException );
00241 
00247     //                                  property will be deleted.
00250     _DWFTK_API
00251     virtual void removeProperty( DWFProperty* pProperty,
00252                                  bool         bDeleteIfOwned=true )
00253         throw( DWFException );
00254 
00267     _DWFTK_API
00268     virtual void addPropertyContainer( DWFPropertyContainer* pContainer )
00269         throw( DWFException );
00270 
00281     _DWFTK_API
00282     virtual void referencePropertyContainer( const DWFPropertyContainer& rContainer )
00283         throw( DWFException );
00284 
00296     _DWFTK_API
00297     virtual void getOwnedPropertyContainers( DWFPropertyContainer::tList& rContainerList )
00298         throw( DWFException );
00299 
00310     _DWFTK_API
00311     virtual void getReferencedPropertyContainers( DWFPropertyContainer::tList& rContainerList )
00312         throw( DWFException );
00313 
00323     _DWFTK_API
00324     virtual void getAllPropertyContainers( DWFPropertyContainer::tList& rContainerList )
00325         throw( DWFException );
00326 
00341     _DWFTK_API
00342     virtual void removeOwnedPropertyContainers( DWFPropertyContainer::tList& rContainerList,
00343                                                 bool                         bMakeReferences = false )
00344         throw( DWFException );
00345 
00356     _DWFTK_API
00357     virtual void removeReferencedPropertyContainers( DWFPropertyContainer::tList& rContainerList )
00358         throw( DWFException );
00359 
00370     _DWFTK_API
00371     bool removeOwnedPropertyContainer( DWFPropertyContainer* pContainer, bool bDelete = true )
00372         throw();
00373 
00382     _DWFTK_API
00383     bool removeReferencedPropertyContainer( DWFPropertyContainer& rContainer )
00384         throw();
00385 
00394     _DWFTK_API
00395     virtual void removeAllPropertyContainers( DWFPropertyContainer::tList& rContainerList )
00396         throw( DWFException );
00397 
00413     _DWFTK_API
00414     virtual void copyProperties( DWFPropertyContainer& rContainer,
00415                                  bool                  bRemoveOwnership = false,
00416                                  bool                  bMakeReferences = false)
00417         throw( DWFException );
00418 
00426     _DWFTK_API
00427     DWFPropertyContainer* ownedContainer( const DWFString& zID )
00428         throw();
00429 
00437     _DWFTK_API
00438     DWFPropertyContainer* referencedContainer( const DWFString& zID )
00439         throw();
00440 
00448     _DWFTK_API
00449     bool ownsContainer( DWFPropertyContainer* pContainer ) const
00450         throw()
00451     {
00452         return (std::find( _oContainers.begin(), _oContainers.end(), pContainer ) != _oContainers.end());
00453     }
00454 
00462     _DWFTK_API
00463     bool referencesContainer( DWFPropertyContainer* pContainer ) const
00464         throw()
00465     {
00466         return (std::find( _oReferences.begin(), _oReferences.end(), pContainer ) != _oReferences.end());
00467     }
00468 
00469 #ifndef DWFTK_READ_ONLY
00470 
00478     _DWFTK_API
00479     DWFXMLSerializable& getSerializable() const
00480         throw()
00481     {
00482         return (DWFXMLSerializable&)_oSerializer;
00483     }
00484 
00485 #endif
00486 
00487 protected:
00488 
00497     _DWFTK_API
00498     virtual void identify( const DWFString& zID )
00499         throw()
00500     {
00501         _zID = zID;
00502     }
00503 
00504 #ifndef DWFTK_READ_ONLY
00505 
00519     _DWFTK_API
00520     virtual void _serializeXML( DWFXMLSerializer& rSerializer, unsigned int nFlags )
00521         throw( DWFException );
00522 
00523 #endif
00524 
00528     _DWFTK_API
00529     virtual void notifyOwnerChanged( DWFOwnable& rOwnable )
00530         throw( DWFException );
00531 
00535     _DWFTK_API
00536     virtual void notifyOwnableDeletion( DWFOwnable& rOwnable )
00537         throw( DWFException );
00538 
00539 #ifndef DWFTK_READ_ONLY
00540 
00541 private:
00542 
00543     //
00544     // in order to avoid bizarre diamond patterns and
00545     // excessively overload base implementations,
00546     // all container classes must define and implementation this
00547     // internal [PRIVATE] class utility for serializing themselves into XML.
00548     //
00549     class _Serializer : public DWFXMLSerializable
00550                         _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00551     {
00552 
00553     public:
00554 
00555         _Serializer()
00556             throw()
00557             : DWFXMLSerializable()
00558             , _pContainer( NULL )
00559         {;}
00560 
00561         virtual ~_Serializer()
00562             throw()
00563         {;}
00564 
00565         void is( DWFPropertyContainer* pContainer )
00566         {
00567             _pContainer = pContainer;
00568         }
00569 
00570         //
00571         //
00572         //
00573         virtual void serializeXML( DWFXMLSerializer& rSerializer, unsigned int nFlags )
00574             throw( DWFException );
00575 
00576     private:
00577 
00578         DWFPropertyContainer* _pContainer;
00579     };
00580 
00581 #endif
00582 
00583 
00584 protected:
00585 
00589     DWFProperty::tMap           _oProperties;
00594     DWFProperty::tList          _oOrderedProperties;
00595 
00599     DWFPropertyContainer::tList _oContainers;
00603     DWFPropertyContainer::tList _oReferences;
00604 
00605 #ifndef DWFTK_READ_ONLY
00606 
00607     _Serializer                 _oSerializer;
00608 
00609 #endif
00610 
00611 private:
00612 
00613     DWFString                   _zID;
00614 
00615 private:
00616 
00617     DWFPropertyContainer( const DWFPropertyContainer& );
00618     DWFPropertyContainer& operator=( const DWFPropertyContainer& );
00619 };
00620 
00621 }
00622 
00623 #endif

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