PublishedObject.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/publisher/PublishedObject.h#2 $
00019 //  $DateTime: 2008/06/18 18:08:14 $
00020 //  $Author: gaoje $
00021 //  $Change: 101166 $
00022 //  $Revision: #2 $
00023 //
00024 
00025 #ifndef _DWFTK_PUBLISHED_OBJECT_H
00026 #define _DWFTK_PUBLISHED_OBJECT_H
00027 
00028 
00034 
00035 
00036 #ifndef DWFTK_READ_ONLY
00037 
00038 
00039 
00040 
00041 #include "dwfcore/STL.h"
00042 #include "dwfcore/String.h"
00043 #include "dwfcore/Exception.h"
00044 using namespace DWFCore;
00045 
00046 #include "dwf/Toolkit.h"
00047 #include "dwf/package/PropertySet.h"
00048 
00049 
00050 namespace DWFToolkit
00051 {
00052 
00053 //
00054 // fwd decl
00055 //
00056 class DWFPropertyVisitor;
00057 class DWFObject;
00058 class DWFEntity;
00059 
00068 class DWFPublishedObject : public DWFPropertySet
00069                            _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00070 {
00071 
00072 public:
00073 
00077     typedef long    tKey;
00081     typedef int     tIndex;
00082 
00086     typedef struct tReference
00087     {
00088         tKey                nKey;           // Key of the referring segment.
00089         tIndex              nIndex;         // Segment index in scenegraph.
00090         DWFPublishedObject* pObj;           // The published object being referred to.
00091         DWFString           zName;          // Optional name to override referred objects name.
00092         bool                bHideFromModel; // Prevent model from showing this.
00093 
00094         tReference() : nKey(-1), nIndex(0), pObj(NULL), zName(), bHideFromModel(false) {}
00095 
00096     } tReference;
00097 
00101     typedef _DWFTK_STD_VECTOR(tReference*)          tReferenceList;
00105     typedef _DWFTK_STD_VECTOR(DWFPublishedObject*)  tList;
00109     typedef DWFSkipList<tKey, DWFPublishedObject*>  tMap;
00110 
00111 public:
00112 
00119     class Factory _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE
00120     {
00121 
00122     public:
00123 
00129         _DWFTK_API
00130         Factory( const Factory& )
00131             throw()
00132         {;}
00133 
00139         _DWFTK_API
00140         Factory& operator=( const Factory& )
00141             throw()
00142         {
00143             return *this;
00144         }
00145 
00151         _DWFTK_API
00152         virtual ~Factory()
00153             throw()
00154         {;}
00155 
00164         _DWFTK_API
00165         virtual DWFPublishedObject* makePublishedObject( tKey              nKey,
00166                                                          const DWFString&  zName )
00167             throw( DWFException ) = 0;
00168 
00179         _DWFTK_API
00180         virtual DWFPublishedObject& findPublishedObject( tKey nKey )
00181             throw( DWFException ) = 0;
00182 
00183     protected:
00184 
00190         _DWFTK_API
00191         Factory()
00192             throw()
00193         {;}
00194     };
00195 
00196 public:
00197 
00206     class Visitor _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE
00207     {
00208 
00209     public:
00210 
00216         _DWFTK_API
00217         virtual ~Visitor()
00218             throw()
00219         {;}
00220 
00227         _DWFTK_API
00228         virtual void visitPublishedObject( DWFPublishedObject& rObject )
00229             throw( DWFException )
00230         {
00231             if (_pComposite)
00232             {
00233                 _pComposite->visitPublishedObject( rObject );
00234             }
00235         }
00236 
00237     protected:
00238 
00244         _DWFTK_API
00245         Visitor( Visitor* pComposite = NULL )
00246             throw()
00247             : _pComposite( pComposite )
00248         {;}
00249 
00250     private:
00251 
00252         Visitor( const Visitor& );
00253         Visitor& operator=( const Visitor& );
00254 
00255     private:
00256 
00257         Visitor* _pComposite;
00258     };
00259 
00260 public:
00261 
00269     _DWFTK_API
00270     DWFPublishedObject( tKey             nKey,
00271                         const DWFString& zName )
00272         throw();
00273 
00280     _DWFTK_API
00281     DWFPublishedObject( DWFPublishedObject& rSource)
00282         throw();
00283 
00290     _DWFTK_API
00291     DWFPublishedObject& operator=( DWFPublishedObject& rSource)
00292         throw();
00293 
00299     _DWFTK_API
00300     virtual ~DWFPublishedObject()
00301         throw();
00302 
00314     _DWFTK_API
00315     const DWFString& name() const
00316         throw()
00317     {
00318         return getLabel() ;
00319     }
00320 
00330     _DWFTK_API
00331     void path( DWFString& zPath )
00332         throw();
00333 
00345     _DWFTK_API
00346     tKey key() const
00347         throw()
00348     {
00349         return _nKey;
00350     }
00351 
00352     //
00353     // return the object's instance id
00354     //
00355     _DWFTK_API
00356     unsigned int instance() const
00357         throw()
00358     {
00359         return _nIID;
00360     }
00361 
00362     //
00363     // assign the object's instance id
00364     //
00365     _DWFTK_API
00366     void setInstance( unsigned int nIID )
00367         throw()
00368     {
00369         _nIID = nIID;
00370     }
00371 
00372     //
00373     // return the scene index
00374     //
00375     _DWFTK_API
00376     tIndex index() const
00377         throw()
00378     {
00379         return _nIndex;
00380     }
00381 
00388     _DWFTK_API
00389     void setIndex( tIndex nIndex )
00390         throw()
00391     {
00392         _nIndex = nIndex;
00393     }
00394 
00401     _DWFTK_API
00402     DWFPublishedObject* parent() const
00403         throw()
00404     {
00405         return _pParent;
00406     }
00407 
00415     _DWFTK_API
00416     void setParent( DWFPublishedObject* pParentObject )
00417         throw()
00418     {
00419         _pParent = pParentObject;
00420     }
00421 
00439     _DWFTK_API
00440     void referenced()
00441         throw()
00442     {
00443         _bRef = true;
00444     }
00445 
00452     _DWFTK_API
00453     bool isReferenced() const
00454         throw()
00455     {
00456         return _bRef;
00457     }
00458 
00470     _DWFTK_API
00471     virtual void addReference( DWFPublishedObject*      pObject,
00472                                DWFPublishedObject::tKey nKey,
00473                                const DWFString*         pzInstanceName = NULL,
00474                                bool                     bPropertiesOnly = false )
00475         throw( DWFException );
00476 
00485     _DWFTK_API
00486     tReferenceList& references()
00487         throw( DWFException );
00488 
00495     _DWFTK_API
00496     virtual void accept( DWFPublishedObject::Visitor& rVisitor )
00497         throw( DWFException );
00498 
00505     _DWFTK_API
00506     virtual void accept( DWFPropertyVisitor& rVisitor )
00507         throw( DWFException );
00508 
00522     _DWFTK_API
00523     virtual bool setHideFromDefaultModel( DWFPublishedObject::tKey /*nKey*/ )
00524         throw()
00525     {
00526         return true;
00527     }
00528 
00541     _DWFTK_API
00542     void setContentEntity( DWFEntity*       /*pEntity*/,
00543                            tKey             /*nKey*/, 
00544                            const DWFString* /*pzInstanceName*/ )
00545         throw( DWFException )
00546     {;}
00547 
00559     _DWFTK_API
00560     virtual void setContentObject( DWFObject*   /*pObject*/,
00561                                    tKey         /*nKey*/ )
00562         throw( DWFException )
00563     {;}
00564 
00576     _DWFTK_API
00577     virtual DWFObject* getContentObject()
00578         throw()
00579     {
00580         return NULL;
00581     }
00582 
00583 protected:
00584 
00585     bool                _bRef;
00586     
00587     tKey                _nKey;
00588 
00589     unsigned int        _nIID;
00590     unsigned int        _nIndex;
00591     DWFPublishedObject* _pParent;
00592 
00593     tReferenceList      _oReferenceList;
00594 
00595 private:
00596 
00597     DWFPublishedObject();
00598 };
00599 
00600 }
00601 
00602 
00603 #endif  
00604 #endif
00605 

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