Object.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/Object.h#2 $
00019 //  $DateTime: 2008/06/18 18:08:14 $
00020 //  $Author: gaoje $
00021 //  $Change: 101166 $
00022 //  $Revision: #2 $
00023 //
00024 
00025 #ifndef _DWFTK_OBJECT_H
00026 #define _DWFTK_OBJECT_H
00027 
00032 
00033 #include "dwfcore/STL.h"
00034 
00035 #include "dwf/Toolkit.h"
00036 #include "dwf/package/Feature.h"
00037 #include "dwf/package/Renderable.h"
00038 
00039 namespace DWFToolkit
00040 {
00041 
00042 //
00043 // fwd declaration
00044 //
00045 class DWFEntity;
00046 
00047 
00058 class DWFObject : public DWFRenderable
00059                 _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00060 {
00061 
00062     //
00063     // Management of this class will occur only through the content class
00064     //
00065     friend class DWFContent;
00066     //
00067     // During reading, the DWFXMLElementBuilder needs to create these classes
00068     //
00069     friend class DWFXMLElementBuilder;
00070 
00071 public:
00072 
00076     typedef DWFOrderedVector<DWFObject*>            tList;
00080     typedef DWFStringKeySkipList<DWFObject*>        tMap;
00085     typedef DWFCachingIterator<DWFObject*>          tCachingIterator;
00089     typedef DWFIterator<DWFObject*>                 tIterator;
00090 
00095     typedef enum teUnresolvedAttributes
00096     {
00097         //
00098         ePropertySetReferences  = DWFPropertySet::ePropertySetReferences,
00099 
00100         //
00101         eEntityReference        = DWFPropertySet::ePropertySetReferences + 1,
00102 
00103         //
00104         eFeatureReferences      = DWFPropertySet::ePropertySetReferences + 2
00105 
00106     } teUnresolvedAttributes;
00107 
00108 public:
00109 
00115     _DWFTK_API
00116     virtual ~DWFObject()
00117         throw();
00118 
00125     _DWFTK_API
00126     DWFEntity* getEntity()
00127         throw()
00128     {
00129         return _pEntity;
00130     }
00131 
00139     _DWFTK_API
00140     DWFObject::tList::Iterator* getChildren()
00141         throw()
00142     {
00143         return (_oChildren.size() > 0 ? _oChildren.iterator() : NULL);
00144     }
00145 
00152     _DWFTK_API
00153     size_t getChildCount() const
00154         throw()
00155     {
00156         return _oChildren.size();
00157     }
00158 
00159 
00167     _DWFTK_API
00168     DWFObject* getParent() const
00169         throw()
00170     {
00171         return _pParent;
00172     }
00173 
00181     _DWFTK_API
00182     DWFFeature::tList::Iterator* getFeatures()
00183         throw()
00184     {
00185         return (_oFeatures.size() > 0 ? _oFeatures.iterator() : NULL);
00186     }
00187 
00194     _DWFTK_API
00195     size_t getFeatureCount() const
00196         throw()
00197     {
00198         return _oFeatures.size();
00199     }
00200 
00208     _DWFTK_API
00209     bool hasFeature( DWFFeature* pFeature ) const
00210         throw()
00211     {
00212         size_t iLocation;
00213         return _oFeatures.findFirst( pFeature, iLocation );
00214     }   
00215 
00219     _DWFTK_API
00220     virtual void parseAttributeList( const char** ppAttributeList,
00221                                      tUnresolvedList& rUnresolved )
00222         throw( DWFException );
00223 
00224 protected:
00225 
00237     _DWFTK_API
00238     DWFObject( const DWFString&     zID, 
00239                DWFEntity*           pEntity,
00240                DWFContent*          pContent = NULL )
00241         throw( DWFInvalidArgumentException );
00242 
00251     _DWFTK_API
00252     DWFObject()
00253         throw();
00254 
00255 #ifndef DWFTK_READ_ONLY
00256 
00260     _DWFTK_API
00261     virtual void _serializeAttributes( DWFXMLSerializer& rSerializer, unsigned int nFlags )
00262         throw( DWFException );
00263 
00267     _DWFTK_API
00268     virtual void _serializeXML( DWFXMLSerializer& rSerializer, unsigned int nFlags )
00269         throw( DWFException );
00270 
00271 #endif
00272 
00276     _DWFTK_API
00277     virtual void insertPropertyAncestors( DWFContentElement::tVector& rAncestorElements ) const
00278         throw();
00279 
00280 private:
00281 
00288     _DWFTK_API
00289     void _addChild( DWFObject* pChild )
00290         throw();
00291 
00300     _DWFTK_API
00301     bool _removeChild( DWFObject* pChild)
00302         throw();
00303 
00309     _DWFTK_API
00310     void _removeChildren()
00311         throw();
00312 
00319     _DWFTK_API
00320     void _addFeature( DWFFeature* pFeature )
00321         throw()
00322     {
00323         _oFeatures.push_back( pFeature );
00324     }
00325 
00333     _DWFTK_API
00334     bool _removeFeature( DWFFeature* pFeature )
00335         throw()
00336     {
00337         return _oFeatures.erase( pFeature );
00338     }
00339 
00345     _DWFTK_API
00346     void _removeFeatures()
00347         throw()
00348     {
00349         _oFeatures.clear();
00350     }
00351 
00356     _DWFTK_API
00357     void _setEntity( DWFEntity* pEntity )
00358     {
00359         _pEntity = pEntity;
00360     }
00361 
00362 private:
00363     
00364     // Entity that this object realizes.
00365     DWFEntity*                  _pEntity;
00366 
00367     // If this object has no parent, this will be NULL.
00368     DWFObject*                  _pParent;
00369 
00370     // An object can be composed of multiple child entities.
00371     DWFObject::tList            _oChildren;
00372 
00373     // References (pointers) to features that this object uses.
00374     DWFFeature::tList           _oFeatures;
00375 
00376 private:
00377 
00378     //
00379     // Not Implemented
00380     //
00381     DWFObject( const DWFObject& );
00382     DWFObject& operator=( const DWFObject& );
00383 };
00384 
00385 }
00386 
00387 #endif
00388 

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