PublishableSection.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 
00019 #ifndef _DWFTK_PUBLISHABLESECTION_H
00020 #define _DWFTK_PUBLISHABLESECTION_H
00021 
00022 
00027 
00028 #ifndef DWFTK_READ_ONLY
00029 
00030 
00031 
00032 #include "dwfcore/STL.h"
00033 #include "dwfcore/UUID.h"
00034 #include "dwfcore/Iterator.h"
00035 #include "dwfcore/Exception.h"
00036 using namespace DWFCore;
00037 
00038 #include "dwf/Toolkit.h"
00039 #include "dwf/publisher/Publishable.h"
00040 #include "dwf/publisher/PublishableResource.h"
00041 #include "dwf/publisher/EmbeddedFont.h"
00042 #include "dwf/package/utility/PropertyContainer.h"
00043 #include "dwf/package/utility/ResourceContainer.h"
00044 #include "dwf/package/CoordinateSystem.h"
00045 
00046 
00047 namespace DWFToolkit
00048 {
00049 
00050 //
00051 // fwd decl
00052 //
00053 class DWFPublisher;
00054 
00055 
00056 
00064 class DWFPublishableSection : public DWFPublishable
00065                             , public DWFResourceContainer
00066                             , public DWFPropertyContainer
00067                             _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00068 {
00069 
00070 public:
00071 
00077         class ResourceIterator : public DWFIterator<DWFPublishableResource*>
00078                                  _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00079     {
00080 
00081     public:
00082 
00089         ResourceIterator( DWFPublishableResource::tList& rVector )
00090             throw()
00091             : _rVector( rVector )
00092             , _iCurrent( 0 )
00093         {;}
00094 
00101         ResourceIterator( const ResourceIterator& i )
00102             throw()
00103             : _rVector( i._rVector )
00104             , _iCurrent( i._iCurrent )
00105         {;}
00106 
00113         ResourceIterator& operator=( const ResourceIterator& i )
00114             throw()
00115         {
00116             _iCurrent = i._iCurrent;
00117 
00118             size_t n = 0;
00119             for (; n < i._rVector.size(); n++)
00120             {
00121                 _rVector.push_back( i._rVector[n] );
00122             }
00123 
00124             return *this;
00125         }
00126 
00132         virtual ~ResourceIterator()
00133             throw()
00134         {;}
00135 
00139         void reset()
00140             throw()
00141         {
00142             _iCurrent = 0;
00143         }
00144 
00148         bool valid()
00149             throw()
00150         {
00151             return (_iCurrent < _rVector.size());
00152         }
00153 
00157         bool next()
00158             throw()
00159         {
00160             if (valid())
00161             {
00162                 _iCurrent++;
00163                 return valid();
00164             }
00165             else
00166             {
00167                 return false;
00168             }
00169         }
00170 
00174         DWFPublishableResource*& get()
00175             throw( DWFException )
00176         {
00177             if (valid())
00178             {
00179                 return _rVector[_iCurrent];
00180             }
00181             else
00182             {
00183                 _DWFCORE_THROW( DWFDoesNotExistException, /*NOXLATE*/L"No more elements" );
00184             }
00185         }
00186 
00187     private:
00188 
00189         DWFPublishableResource::tList& _rVector;
00190         size_t  _iCurrent;
00191     };
00192 
00198     _DWFTK_API
00199     virtual ~DWFPublishableSection()
00200         throw()
00201     {;}
00202 
00209     _DWFTK_API
00210     virtual void publish( DWFPublisher& rPublisher )
00211         throw( DWFException ) = 0;
00212 
00220     _DWFTK_API
00221     virtual void embedFont( DWFEmbeddedFont* /*pFont*/ )
00222         throw( DWFException )
00223     {
00224         _DWFCORE_THROW( DWFNotImplementedException, /*NOXLATE*/L"Font embedding not supported by this object" );
00225     }
00226 
00236     _DWFTK_API
00237     virtual void addResource( DWFPublishableResource* /*pResource*/ )
00238         throw( DWFException )
00239     {
00240         _DWFCORE_THROW( DWFNotImplementedException, /*NOXLATE*/L"Additional resources are not supported by this object" );
00241     }
00242 
00251     _DWFTK_API
00252     virtual DWFIterator<DWFPublishableResource*>* getResources()
00253         throw( DWFException )
00254     {
00255         _DWFCORE_THROW( DWFNotImplementedException, /*NOXLATE*/L"Additional resources are not supported by this object" );
00256     }
00257 
00264     _DWFTK_API
00265     virtual const DWFString& getType() const
00266         throw()
00267     {
00268         return _zType;
00269     }
00270 
00277     _DWFTK_API
00278     virtual const DWFString& getTitle() const
00279         throw()
00280     {
00281         return _zTitle;
00282     }
00283 
00284 
00291     _DWFTK_API
00292     virtual double getVersion() const
00293         throw() = 0;
00294 
00301     _DWFTK_API
00302     virtual const DWFString& getSource() const
00303         throw()
00304     {
00305         return _zSource;
00306     }
00307 
00314     _DWFTK_API
00315     virtual const DWFString& getSourceID() const
00316         throw()
00317     {
00318         return _zSourceID;
00319     }
00320 
00327     _DWFTK_API
00328     virtual const DWFString& getSourceHRef() const
00329         throw()
00330     {
00331         return _zSourceHRef;
00332     }
00333 
00341     _DWFTK_API
00342     virtual void setLabel( const DWFString& zLabel )
00343         throw()
00344     {
00345         _zLabel = zLabel;
00346     }
00347 
00355     _DWFTK_API
00356     virtual const DWFString& getLabel() const
00357         throw()
00358     {
00359         return _zLabel;
00360     }
00361 
00369     _DWFTK_API
00370     virtual const DWFString& initialURI()
00371         throw()
00372     {
00373         return _zInitialURI;
00374     }
00375 
00383     _DWFTK_API
00384     virtual void setInitialURI( const DWFString& zInitialURI )
00385         throw()
00386     {
00387         _zInitialURI = zInitialURI;
00388     }
00389 
00398     _DWFTK_API
00399     virtual DWFString href()
00400         throw()
00401     {
00402         if (_zName.chars() == 0)
00403         {
00404             DWFUUID uuid;
00405             _zName = uuid.next( false );
00406         }
00407 
00408         DWFString zHREF( _zType );
00409         zHREF.append( /*NOXLATE*/L"_" );
00410         zHREF.append( _zName );
00411         
00412         return zHREF;
00413     }
00414 
00424     _DWFTK_API
00425     virtual const DWFString& name()
00426         throw()
00427     {
00428         return _zName;
00429     }
00430 
00440     _DWFTK_API
00441     void addCoordinateSystem(DWFCoordinateSystem* pCS)
00442         throw()
00443     {
00444         _oCSs.insert( pCS );
00445     }
00446 
00457     _DWFTK_API
00458     virtual DWFCoordinateSystem::tList::Iterator* getCoordinateSystems( )
00459         throw()
00460     {
00461         return _oCSs.iterator();
00462     }
00463 
00472     _DWFTK_API
00473     virtual void removeCoordinateSystem( DWFCoordinateSystem* pCS,
00474                              bool                             bDelete )
00475         throw( DWFException )
00476     {
00477         _oCSs.erase(pCS);
00478         
00479         if (bDelete)
00480         {
00481             DWFCORE_FREE_OBJECT(pCS);
00482         }
00483     }
00484 
00485 protected:
00486 
00492     _DWFTK_API
00493     DWFPublishableSection( const DWFString& zSectionType,
00494                            const DWFString& zSectionTitle = "",
00495                            const DWFString& zSectionSource = "",
00496                            const DWFString& zSectionSourceID = "",
00497                            const DWFString& zSectionSourceHRef = "",
00498                            const DWFString& zSectionLabel = "")
00499                            : _zType(zSectionType)
00500                            , _zTitle(zSectionTitle)
00501                            , _zSource(zSectionSource)
00502                            , _zSourceID(zSectionSourceID)
00503                            , _zSourceHRef(zSectionSourceHRef)
00504                            , _zLabel(zSectionLabel)
00505                            , _zInitialURI()
00506                            , _oCSs()
00507                            , _zName()                           
00508     {
00509         DWFUUID uuid;
00510         _zName = uuid.next( false );
00511     }
00512 
00513 private:
00514 
00515     DWFString                       _zType;
00516     DWFString                       _zTitle;
00517     DWFString                       _zSource;
00518     DWFString                       _zSourceID;
00519     DWFString                       _zSourceHRef;
00520     DWFString                       _zLabel;
00521     DWFString                       _zInitialURI;
00522     DWFCoordinateSystem::tList      _oCSs;
00523 
00524     //
00525     // This defines the second part of the HREF - need this separately 
00526     // for setting the name of the final published section.
00527     //
00528     DWFString               _zName;
00529 
00530 };
00531 
00532 }
00533 
00534 #endif  
00535 
00536 #endif
00537 

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