package/Resource.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/Resource.h#2 $
00019 //  $DateTime: 2008/06/18 18:08:14 $
00020 //  $Author: gaoje $
00021 //  $Change: 101166 $
00022 //  $Revision: #2 $
00023 //
00024 
00025 #ifndef _DWFTK_RESOURCE_H
00026 #define _DWFTK_RESOURCE_H
00027 
00032 
00033 
00034 #include "dwfcore/STL.h"
00035 #include "dwfcore/Owner.h"
00036 #include "dwfcore/Vector.h"
00037 #include "dwfcore/SkipList.h"
00038 #include "dwfcore/InputStream.h"
00039 #include "dwfcore/ZipFileDescriptor.h"
00040 using namespace DWFCore;
00041 
00042 #include "dwf/Toolkit.h"
00043 #include "dwf/package/XML.h"
00044 #include "dwf/package/reader/PackageReader.h"
00045 #include "dwf/package/writer/PackageWriter.h"
00046 #include "dwf/package/utility/PropertyContainer.h"
00047 
00048 namespace DWFToolkit
00049 {
00050 
00051 //forward decl
00052 class DWFResource;
00053 
00063 class DWFResourceRelationship
00064     : public DWFXMLBuildable
00065     _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00066 {
00067 public:
00071     typedef DWFOrderedVector<DWFResourceRelationship*> tList;
00072 
00073 public:
00086     _DWFTK_API
00087     DWFResourceRelationship(DWFPackageReader* /*pPackageReader*/)
00088         throw()
00089         : _pResource(NULL)
00090         , _zResourceID()
00091         , _zType()
00092     { ; }
00093 
00103     _DWFTK_API
00104     DWFResourceRelationship(const DWFResource* pResource, const DWFString& zType)
00105         throw()
00106         : _pResource(pResource)
00107         , _zResourceID()
00108         , _zType(zType)
00109     { ; }
00110 
00114     _DWFTK_API
00115     virtual ~DWFResourceRelationship()
00116         throw()
00117     { ; }
00118 
00127     _DWFTK_API
00128     const DWFString& resourceID() const
00129         throw(DWFException);
00130 
00137     _DWFTK_API
00138     const DWFString& type() const
00139         throw()
00140     {
00141         return _zType;
00142     }
00143 
00147     _DWFTK_API
00148     virtual void parseAttributeList( const char** ppAttributeList )
00149         throw( DWFException );
00150 
00151 
00152 private:
00153     const DWFResource*  _pResource;
00154     DWFString           _zResourceID;
00155     DWFString           _zType;
00156 
00157 private:
00158     // Intentionally not implemented.
00159     DWFResourceRelationship( const DWFResourceRelationship& );
00160     DWFResourceRelationship& operator=( const DWFResourceRelationship& );
00161 };
00162 
00163 
00173 class DWFResource : public DWFXMLBuildable
00174 
00175 #ifndef DWFTK_READ_ONLY
00176                   , public DWFXMLSerializable
00177 #endif
00178                   , public DWFPropertyContainer
00179                   , public DWFOwnable
00180                   _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00181 {
00182 
00183 public:
00184 
00188     typedef _DWFTK_STD_VECTOR(DWFResource*)                                     tList;
00192     typedef DWFSkipList<uint32_t, DWFResource*>                                 tOrderedList;
00196     typedef DWFWCharKeySkipList<DWFResource*>                                   tMap;
00200     typedef std::multimap<const wchar_t*, DWFResource*, tDWFWCharCompareLess>   tMultiMap;
00204     typedef DWFIterator<DWFString>                                              tStringIterator;
00208     typedef DWFIterator<DWFResource*>                                           tIterator;
00212     typedef DWFConstIterator<DWFResource*>                                      tConstIterator;
00216     typedef DWFCachingIterator<DWFResource*>                                    tCachingIterator;
00217 
00218 public:
00226     class NotificationSink _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE
00227     {
00228 
00229     public:
00230 
00236         _DWFTK_API
00237         NotificationSink()
00238             throw()
00239         {;}
00240 
00246         _DWFTK_API
00247         virtual ~NotificationSink()
00248             throw()
00249         {;}
00250 
00251     public:
00252 
00260         _DWFTK_API
00261         virtual void onBeforeResourceHRefChanged( DWFResource* pResource )
00262             throw()
00263             = 0;
00264 
00272         _DWFTK_API
00273         virtual void onAfterResourceHRefChanged( DWFResource* pResource )
00274             throw()
00275             = 0;
00276     };
00277 
00278 private:
00279     typedef _DWFTK_STD_VECTOR(NotificationSink*)    _tNotifySinks;
00280 
00281 
00282 public:
00295     _DWFTK_API
00296     DWFResource( DWFPackageReader* pPackageReader )
00297         throw();
00298 
00320     _DWFTK_API
00321     DWFResource( const DWFString& zTitle,
00322                  const DWFString& zRole,
00323                  const DWFString& zMIME,
00324                  const DWFString& zHREF = /*NOXLATE*/L"" )
00325         throw();
00326 
00332     _DWFTK_API
00333     virtual ~DWFResource()
00334         throw();
00335 
00342     _DWFTK_API
00343     const DWFString& title() const
00344         throw()
00345     {
00346         return _zTitle;
00347     }
00348 
00355     _DWFTK_API
00356     void setTitle( const DWFString& zTitle )
00357         throw()
00358     {
00359         _zTitle = zTitle;
00360     }
00361 
00368     _DWFTK_API
00369     const DWFString& role() const
00370         throw()
00371     {
00372         return _zRole;
00373     }
00374 
00382     _DWFTK_API
00383     void setRole( const DWFString& zRole )
00384         throw()
00385     {
00386         _zRole = zRole;
00387     }
00388 
00395     _DWFTK_API
00396     const DWFString& mime() const
00397         throw()
00398     {
00399         return _zMIME;
00400     }
00401 
00409     _DWFTK_API
00410     void setMIME( const DWFString& zMIME )
00411         throw();
00412 
00419     _DWFTK_API
00420     const DWFString& href() const
00421         throw()
00422     {
00423         return _zHRef;
00424     }
00425 
00437     _DWFTK_API
00438     virtual bool addContentID( const DWFString& zContentID )
00439         throw( DWFException );
00440 
00448     _DWFTK_API
00449     bool removeContentID( const DWFString& zContentID )
00450         throw()
00451     {
00452         return _oContentID.erase( zContentID );
00453     }
00454 
00463     _DWFTK_API
00464     size_t contentIDCount() const
00465         throw()
00466     {
00467         return _oContentID.size();
00468     }
00469 
00479     _DWFTK_API
00480     tStringIterator* contentIDs()
00481         throw()
00482     {
00483         return _oContentID.iterator();
00484     }
00485 
00492     _DWFTK_API
00493     const DWFString& objectID() const
00494         throw()
00495     {
00496         return _zObjectID;
00497     }
00498 
00505     _DWFTK_API
00506     virtual void setObjectID( const DWFString& zObjectID )
00507         throw()
00508     {
00509         _zObjectID = zObjectID;
00510     }
00511 
00520     _DWFTK_API
00521     const DWFString& internalID() const
00522         throw()
00523     {
00524         return _zInternalID;
00525     }
00526 
00536     _DWFTK_API
00537     virtual void setInternalID( const DWFString& zInternalID )
00538         throw()
00539     {
00540         _zInternalID = zInternalID;
00541     }
00542 
00549     _DWFTK_API
00550     const DWFString& parentID() const
00551         throw()
00552     {
00553         return _zParentObjectID;
00554     }
00555 
00568     _DWFTK_API
00569     void setParentResource( const DWFResource* pResource )
00570         throw();
00571 
00584     _DWFTK_API
00585     void setParentObjectID( const DWFString& zObjectID )
00586         throw()
00587     {
00588         _zParentObjectID = zObjectID;
00589     }
00590 
00599     _DWFTK_API
00600     void setHRef( const DWFString& zHRef )
00601         throw()
00602     {
00603         notifyBeforeHRefChanged();
00604         _zHRef = zHRef;
00605         notifyAfterHRefChanged();
00606     }
00607 
00616     _DWFTK_API
00617     void setTargetHRef( const DWFString& zTargetHRef )
00618         throw()
00619     {
00620         _zTargetHRef = zTargetHRef;
00621     }
00622 
00635     _DWFTK_API
00636     const size_t size() const
00637         throw()
00638     {
00639         return _nSize;
00640     }
00641 
00652     _DWFTK_API
00653     virtual void setPublishedIdentity( const DWFString& zSectionName,
00654                                        const DWFString& zObjectID )
00655         throw();
00656 
00673     _DWFTK_API
00674     const DWFString& publishedIdentity() const
00675         throw()
00676     {
00677         return _zTargetHRef;
00678     }
00679 
00691     _DWFTK_API
00692     virtual void setRequestedName( const DWFString& zName )
00693         throw()
00694     {
00695         _zRequestedIdentity = zName;
00696     }
00697 
00705     _DWFTK_API
00706     virtual const DWFString& requestedName()
00707         throw()
00708     {
00709         return _zRequestedIdentity;
00710     }
00711 
00735     _DWFTK_API
00736     virtual DWFInputStream* getInputStream( bool bCache = false )
00737         throw( DWFException );
00738 
00742     _DWFTK_API
00743     virtual void parseAttributeList( const char** ppAttributeList )
00744         throw( DWFException );
00745 
00746 
00747 #ifndef DWFTK_READ_ONLY
00748 
00778     _DWFTK_API
00779     void setInputStream( DWFInputStream* pStream, size_t nBytes = 0 )
00780         throw( DWFException );
00781 
00785     _DWFTK_API
00786     virtual void serializeXML( DWFXMLSerializer& rSerializer, unsigned int nFlags )
00787         throw( DWFException );
00788 
00789 #endif
00790 
00799     _DWFTK_API
00800     DWFZipFileDescriptor::teFileMode customZipMode()
00801         throw()
00802     {
00803         return _eCustomZipMode;
00804     }
00805 
00813     _DWFTK_API
00814     bool useCustomZipMode()
00815         throw()
00816     {
00817         return _bUseCustomZipMode;
00818     }
00819 
00829     _DWFTK_API
00830     void enableCustomZipMode( bool bUseCustomZipMode, DWFZipFileDescriptor::teFileMode eZipMode = DWFZipFileDescriptor::eZip )
00831         throw();
00832 
00841     _DWFTK_API
00842     void addRelationship( DWFResourceRelationship* pResourceRel)
00843         throw(DWFException);
00844 
00854     _DWFTK_API
00855     void addRelationship( const DWFResource* pResource, const DWFString& zType)
00856         throw(DWFException);
00857 
00865     _DWFTK_API
00866     DWFResourceRelationship::tList::ConstIterator* getRelationships()
00867         throw(DWFException)
00868     {
00869         return _oRelationships.constIterator();
00870     }
00871 
00881     _DWFTK_API
00882     void removeRelationship( DWFResourceRelationship* pResourceRel, bool bDelete = false )
00883         throw( DWFException );
00884 
00891     _DWFTK_API
00892     void setNotificationSink( DWFResource::NotificationSink* pSink )
00893         throw();
00894 
00902     _DWFTK_API
00903     void removeNotificationSink( DWFResource::NotificationSink* pSink )
00904         throw();
00905 
00912     _DWFTK_API
00913     void notifyBeforeHRefChanged()
00914         throw();
00915 
00922     _DWFTK_API
00923     void notifyAfterHRefChanged()
00924         throw();
00925 
00926 private:
00927 
00928     _DWFTK_API
00929     tStringIterator* _tokenizeBySpace( char* szInput )
00930         throw();
00931 
00932 protected:
00933 
00937     size_t _nSize;
00938     DWFString _zTargetHRef;
00939 
00940     DWFOrderedVector<DWFString> _oContentID;
00941 
00942     DWFResourceRelationship::tList _oRelationships;
00943 
00944     DWFPackageReader*   _pPackageReader;
00945     //
00946     bool        _bDWFXProtected;
00947 
00948 
00949 private:
00950 
00951     DWFString _zTitle;
00952     DWFString _zRole;
00953     DWFString _zMIME;
00954     DWFString _zHRef;
00955     DWFString _zObjectID;
00956     DWFString _zParentObjectID;
00957 
00958     DWFString _zRequestedIdentity;
00959 
00960     //
00961     //  This is used for DWFXFixedPages - to allow identification of embedded resources by looking at the 
00962     //  Name attribute of the top-level Canvas and ImageBrush elements.
00963     //
00964     DWFString _zInternalID;
00965 
00966     //
00967     //  The custom zip mode to use for the resource - meaningful only if _bUseCustomZipMode is true.
00968     //
00969     DWFZipFileDescriptor::teFileMode    _eCustomZipMode;
00970     //
00971     //  If true, use the zip mode defined in the resource to serialize it.
00972     //
00973     bool                                _bUseCustomZipMode;
00974     //
00975     //
00976 
00977     DWFInputStream*     _pStream;
00978 
00979 
00980     //
00981     //  The notification sinks are used to notify an observer/listener of
00982     //  resource modification events.
00983     //
00984     _tNotifySinks                       _oNotifySinks;
00985 
00986 private:
00987 
00988     DWFResource( const DWFResource& );
00989     DWFResource& operator=( const DWFResource& );
00990 };
00991 
00992 }
00993 
00994 #endif

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