Entity.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 2005-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/Entity.h#2 $
00019 //  $DateTime: 2008/06/18 18:08:14 $
00020 //  $Author: gaoje $
00021 //  $Change: 101166 $
00022 //
00023 
00024 #ifndef _DWFTK_ENTITY_H
00025 #define _DWFTK_ENTITY_H
00026 
00031 
00032 #include "dwfcore/STL.h"
00033 
00034 #include "dwf/Toolkit.h"
00035 #include "dwf/package/Class.h"
00036 #include "dwf/package/Feature.h"
00037 
00038 namespace DWFToolkit
00039 { 
00040 
00053 class DWFEntity : public DWFContentElement
00054                 _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00055 {
00056 
00057     //
00058     // Management of this class will occur only through the content class
00059     //
00060     friend class DWFContent;
00061     //
00062     // During reading, the DWFXMLElementBuilder needs to create these classes
00063     //
00064     friend class DWFXMLElementBuilder;
00065 
00066 public:
00067 
00071     typedef DWFOrderedVector<DWFEntity*>            tList;
00075     typedef DWFSortedVector<DWFEntity*>             tSortedList;
00079     typedef DWFStringKeySkipList<DWFEntity*>        tMap;
00084     typedef DWFCachingIterator<DWFEntity*>          tCachingIterator;
00088     typedef DWFIterator<DWFEntity*>                 tIterator;
00092     typedef DWFConstIterator<DWFEntity*>            tConstIterator;
00093 
00098     typedef enum teUnresolvedAttributes
00099     {
00100         //
00101         ePropertySetReferences  = DWFPropertySet::ePropertySetReferences,
00102 
00103         //
00104         eChildEntityReferences  = DWFPropertySet::ePropertySetReferences + 1,
00105 
00106         //
00107         eClassReferences        = DWFPropertySet::ePropertySetReferences + 2,
00108 
00109         //
00110         eFeatureReferences      = DWFPropertySet::ePropertySetReferences + 3
00111 
00112     } teUnresolvedAttributes;
00113 
00114 
00115 public:
00116 
00122     _DWFTK_API
00123     virtual ~DWFEntity()
00124         throw();
00125 
00133     _DWFTK_API
00134     DWFEntity::tSortedList::ConstIterator* getChildren()
00135         throw()
00136     {
00137         return _oChildren.constIterator();
00138     }
00139 
00146     _DWFTK_API
00147     size_t getChildCount() const
00148         throw()
00149     {
00150         return _oChildren.size();
00151     }
00152 
00160     _DWFTK_API
00161     DWFEntity::tSortedList::ConstIterator* getParents()
00162         throw()
00163     {
00164         return _oParents.constIterator();
00165     }
00166 
00173     // Most often an entity will have only 1 parent - this allows simpler
00174     // easier access to the single parent using getParent(0)
00175     _DWFTK_API
00176     DWFEntity* getParent( size_t index ) const
00177         throw()
00178     {
00179         return _oParents[ index ];
00180     }
00181 
00188     _DWFTK_API
00189     size_t getParentCount() const
00190         throw()
00191     {
00192         return _oParents.size();
00193     }
00194 
00202     _DWFTK_API
00203     bool isParent( DWFEntity* pEntity ) const
00204         throw()
00205     {
00206         size_t iLocation;
00207         return _oParents.findFirst( pEntity, iLocation );
00208     }
00209 
00217     _DWFTK_API
00218     DWFClass::tList::Iterator* getClasses()
00219         throw()
00220     {
00221         return (_oClasses.size() > 0 ? _oClasses.iterator() : NULL);
00222     }
00223 
00230     _DWFTK_API
00231     size_t getClassCount() const
00232         throw()
00233     {
00234         return _oClasses.size();
00235     }
00236 
00244     _DWFTK_API
00245     bool hasClass( DWFClass* pClass ) const
00246         throw()
00247     {
00248         size_t iLocation;
00249         return _oClasses.findFirst( pClass, iLocation );
00250     }   
00251 
00259     _DWFTK_API
00260     DWFFeature::tList::Iterator* getFeatures()
00261         throw()
00262     {
00263         return (_oFeatures.size() > 0 ? _oFeatures.iterator() : NULL);
00264     }
00265 
00272     _DWFTK_API
00273     size_t getFeatureCount() const
00274         throw()
00275     {
00276         return _oFeatures.size();
00277     }
00278 
00286     _DWFTK_API
00287     bool hasFeature( DWFFeature* pFeature ) const
00288         throw()
00289     {
00290         size_t iLocation;
00291         return _oFeatures.findFirst( pFeature, iLocation );
00292     }   
00293 
00297     _DWFTK_API
00298     virtual void parseAttributeList( const char** ppAttributeList,
00299                                      tUnresolvedList& rUnresolved )
00300         throw( DWFException );
00301 
00302 protected:
00303 
00314     _DWFTK_API
00315     DWFEntity( const DWFString& zID = /*NOXLATE*/L"",
00316                DWFContent* pContent = NULL )
00317         throw();
00318 
00319 #ifndef DWFTK_READ_ONLY
00320 
00324     _DWFTK_API
00325     virtual void _serializeAttributes( DWFXMLSerializer& rSerializer, unsigned int nFlags )
00326         throw( DWFException );
00327 
00331     _DWFTK_API
00332     virtual void _serializeXML( DWFXMLSerializer& rSerializer, unsigned int nFlags )
00333         throw( DWFException );
00334 
00335 #endif
00336 
00340     _DWFTK_API
00341     virtual void insertPropertyAncestors( DWFContentElement::tVector& rAncestorElements ) const
00342         throw();
00343 
00344 private:
00345 
00352     _DWFTK_API
00353     void _addClass( DWFClass* pClass )
00354         throw()
00355     {
00356         _oClasses.push_back( pClass );
00357     }
00358 
00366     _DWFTK_API
00367     bool _removeClass( DWFClass* pClass )
00368         throw()
00369     {
00370         return _oClasses.erase( pClass );
00371     }
00372 
00378     _DWFTK_API
00379     void _removeClasses()
00380         throw()
00381     {
00382         _oClasses.clear();
00383     }
00384 
00391     _DWFTK_API
00392     void _addFeature( DWFFeature* pFeature )
00393         throw()
00394     {
00395         _oFeatures.push_back( pFeature );
00396     }
00397 
00405     _DWFTK_API
00406     bool _removeFeature( DWFFeature* pFeature )
00407         throw()
00408     {
00409         return _oFeatures.erase( pFeature );
00410     }
00411 
00417     _DWFTK_API
00418     void _removeFeatures()
00419         throw()
00420     {
00421         _oFeatures.clear();
00422     }
00423 
00430     _DWFTK_API
00431     void _addChild( DWFEntity* pChild )
00432         throw();
00433 
00442     _DWFTK_API
00443     bool _removeChild( DWFEntity* pChild )
00444         throw();
00445 
00451     _DWFTK_API
00452     void _removeChildren()
00453         throw();
00454 
00455 private:
00456 
00457     // An entity can have multiple parents, if multiple design elements need 
00458     // to use this common one. The parent and child lists are initialized 
00459     // duplicates not allowed.
00460     DWFEntity::tSortedList      _oParents;
00461     // An entity can be composed of multiple child entities.
00462     DWFEntity::tSortedList      _oChildren;
00463 
00464     // References (pointers) to classes that classify this entity.
00465     DWFClass::tList             _oClasses;
00466 
00467     // References (pointers) to features that this entity uses.
00468     DWFFeature::tList           _oFeatures;
00469 
00470 private:
00471 
00472     //
00473     // Not Implemented
00474     //
00475     DWFEntity( const DWFEntity& );
00476     DWFEntity& operator=( const DWFEntity& );
00477 
00478 };
00479 
00480 }
00481 
00482 #endif
00483 

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