DWFToolkit::DWFResourceContainer Class Reference
[DWF Package API]

#include "dwf/package/utility/ResourceContainer.h"

Inheritance diagram for DWFToolkit::DWFResourceContainer:

Inheritance graph
[legend]
Collaboration diagram for DWFToolkit::DWFResourceContainer:

Collaboration graph
[legend]
List of all members.

Detailed Description

An auto-mapping collection utility for DWFResource objects.

Since:
7.0.1
This class is a resource owner. As resources are added to the container, they are associated in internal maps for fast, multi-keyed look-up.
Examples:

3DPublish/3DPublish_UTF8.cpp.

Definition at line 56 of file ResourceContainer.h.

Public Member Functions

virtual _DWFTK_API ~DWFResourceContainer () throw ()
_DWFTK_API size_t resourceCount () const throw ()
_DWFTK_API DWFResourcefindResourceByHREF (const DWFString &zHRef) throw ()
_DWFTK_API DWFResourcefindResourceByObjectID (const DWFString &zObjectID) throw ()
_DWFTK_API ResourceIteratorfindResourcesByRole (const DWFString &zRole) throw ()
_DWFTK_API ResourceIteratorfindResourcesByMIME (const DWFString &zMIME) throw ()
_DWFTK_API ResourceKVIteratorgetResourcesByHREF () throw ()
_DWFTK_API ResourceKVIteratorgetResourcesByRole () throw ()
_DWFTK_API ResourceKVIteratorgetResourcesByMIME () throw ()
_DWFTK_API DWFResourceremoveResource (DWFResource &rResource, bool bDeleteIfOwned) throw ( DWFException )
_DWFTK_API DWFResourceremoveResourceByHREF (const DWFString &zHRef, bool bDeleteIfOwned) throw ( DWFException )
virtual _DWFTK_API ResourceIteratorremoveResourcesByRole (const DWFString &zRole, bool bDeleteIfOwned) throw ( DWFException )
_DWFTK_API ResourceIteratorremoveResourcesByMIME (const DWFString &zMIME, bool bDeleteIfOwned) throw ( DWFException )
virtual _DWFTK_API DWFResourceaddResource (DWFResource *pResource, bool bOwnResource, bool bReplace=true, bool bDeleteReplacedIfOwned=true, const DWFResource *pParentResource=NULL) throw ( DWFException )
virtual _DWFTK_API void onBeforeResourceHRefChanged (DWFResource *pResource) throw ()
virtual _DWFTK_API void onAfterResourceHRefChanged (DWFResource *pResource) throw ()
DWFXMLSerializablegetSerializable () const throw ()

Protected Types

typedef std::multimap< const
DWFResource *, DWFResource * > 
tResourcePointerMultiMap
 This type defines a multi-value mapped collection of DWFResource pointers.

Protected Member Functions

_DWFTK_API DWFResourceContainer () throw ()
void rename (const DWFString &zName) throw ()
virtual _DWFTK_API void notifyOwnerChanged (DWFOwnable &rOwnable) throw ( DWFException )
virtual _DWFTK_API void notifyOwnableDeletion (DWFOwnable &rOwnable) throw ( DWFException )

Protected Attributes

DWFUUID _oUUID
 Used to generate sequential identifiers for serialization.
DWFResource::tMap _oResourcesByHREF
 The main collection of resources, keyed uniquely by their HREFs.
DWFResource::tMap _oResourcesByObjectID
DWFResource::tMultiMap _oResourcesByRole
DWFResource::tMultiMap _oResourcesByMIME
 A reference collection of the resources, grouped by their MIME types.
tResourcePointerMultiMap _oResourceHierarchy
 A reference mapping of the resources and their children.

Classes

class  ResourceIterator
 An iterator implementation used to enumerate lists of DWFResource objects. More...
class  ResourceKVIterator
 A key-value iterator implementation used to enumerate keyed sets of DWFResource objects. More...


Constructor & Destructor Documentation

virtual _DWFTK_API DWFToolkit::DWFResourceContainer::~DWFResourceContainer  )  throw () [virtual]
 

Destructor

This method will delete only those resources that are owned by this object.

Exceptions:
None 

_DWFTK_API DWFToolkit::DWFResourceContainer::DWFResourceContainer  )  throw () [protected]
 

Constructor

Exceptions:
None 


Member Function Documentation

virtual _DWFTK_API DWFResource* DWFToolkit::DWFResourceContainer::addResource DWFResource pResource,
bool  bOwnResource,
bool  bReplace = true,
bool  bDeleteReplacedIfOwned = true,
const DWFResource pParentResource = NULL
throw ( DWFException ) [virtual]
 

Inserts a resource to the container.

Parameters:
pResource The resource to add to the container (must not be NULL).
bOwnResource If true, the container will claim ownership of the resource and delete it using the DWFCORE_FREE_OBJECT macro upon destruction of this container if it is still owned.
bReplace If true, pResource will replace an existing resource at the same HREF.
bDeleteReplacedIfOwned If bReplace is true and pResource has the same HREF as one in the container, and the container has ownership of the resource, then the previous object will be deleted using the DWFCORE_FREE_OBJECT macro.
pParentResource - Identifies another resource is associated as a parent in the meta-structure.
Returns:
If pResource replaced an existing object but the previous was not deleted, this method will return a pointer to that object. The caller is responsible for either claiming ownership of the resource or recognizing that it is already owned by another object; otherwise, this method returns NULL.
Exceptions:
DWFException 

Reimplemented in DWFToolkit::DWFSection.

_DWFTK_API DWFResource* DWFToolkit::DWFResourceContainer::findResourceByHREF const DWFString zHRef  )  throw ()
 

Locates a resource in the container using its unique HREF.

Parameters:
zHRef The unique resource HREF.
Returns:
A pointer to the resource (may be NULL). This object is owned by the container by default and must not be deleted by the caller without first explicitly claiming ownership.
Exceptions:
None 

_DWFTK_API DWFResource* DWFToolkit::DWFResourceContainer::findResourceByObjectID const DWFString zObjectID  )  throw ()
 

Locates the resource in the container with the given object ID.

Parameters:
zObjectID The resource object ID to search by.
Returns:
The resource with the given object ID.
Exceptions:
None 

_DWFTK_API ResourceIterator* DWFToolkit::DWFResourceContainer::findResourcesByMIME const DWFString zMIME  )  throw ()
 

Locates all resources in the container that share a MIME type.

Parameters:
zMIME The MIME type to search by.
Returns:
A pointer an iterator for enumerating the resources (may be NULL). This pointer must be deleted by the caller with the DWFCORE_FREE_OBJECT macro. Resources returned from the iterator are owned by the container by default and must not be deleted by the caller without first explicitly claiming ownership.
Exceptions:
None 

_DWFTK_API ResourceIterator* DWFToolkit::DWFResourceContainer::findResourcesByRole const DWFString zRole  )  throw ()
 

Locates all resources in the container that share a role.

Parameters:
zRole The resource role to search by.
Returns:
A pointer an iterator for enumerating the resources (may be NULL). This pointer must be deleted by the caller with the DWFCORE_FREE_OBJECT macro. Resources returned from the iterator are owned by the container by default and must not be deleted by the caller without first explicitly claiming ownership.
Exceptions:
None 
Examples:
SimpleW3DStreamProcessor/SimpleW3DStreamProcessor.cpp, and TimedXMLReader/TimedXMLReader.cpp.

_DWFTK_API ResourceKVIterator* DWFToolkit::DWFResourceContainer::getResourcesByHREF  )  throw ()
 

Returns all resources in the container.

Use this method to obtain an iterator that will return resources ordered by their unique HREFs. The HREF is returned by the ResourceKVIterator::key() method.

Returns:
A pointer an iterator for enumerating the resources (may be NULL). This pointer must be deleted by the caller with the DWFCORE_FREE_OBJECT macro. Resources returned from the iterator are owned by the container by default and must not be deleted by the caller without first explicitly claiming ownership.
Exceptions:
None 

_DWFTK_API ResourceKVIterator* DWFToolkit::DWFResourceContainer::getResourcesByMIME  )  throw ()
 

Returns all resources in the container.

Use this method to obtain an iterator that will return resources ordered by their MIME types. The MIME type is returned by the ResourceKVIterator::key() method.

Returns:
A pointer an iterator for enumerating the resources (may be NULL). This pointer must be deleted by the caller with the DWFCORE_FREE_OBJECT macro. Resources returned from the iterator are owned by the container by default and must not be deleted by the caller without first explicitly claiming ownership.
Exceptions:
None 

_DWFTK_API ResourceKVIterator* DWFToolkit::DWFResourceContainer::getResourcesByRole  )  throw ()
 

Returns all resources in the container.

Use this method to obtain an iterator that will return resources ordered by their roles. The role is returned by the ResourceKVIterator::key() method.

Returns:
A pointer an iterator for enumerating the resources (may be NULL). This pointer must be deleted by the caller with the DWFCORE_FREE_OBJECT macro. Resources returned from the iterator are owned by the container by default and must not be deleted by the caller without first explicitly claiming ownership.
Exceptions:
None 

DWFXMLSerializable& DWFToolkit::DWFResourceContainer::getSerializable  )  const throw () [inline]
 

Returns an interface with which the container can be serialized into an XML document.

Returns:
A reference to a serialization interface.
Exceptions:
None 

Definition at line 606 of file ResourceContainer.h.

virtual _DWFTK_API void DWFToolkit::DWFResourceContainer::notifyOwnableDeletion DWFOwnable rOwnable  )  throw ( DWFException ) [protected, virtual]
 

Reimplemented from DWFCore::DWFOwner.

virtual _DWFTK_API void DWFToolkit::DWFResourceContainer::notifyOwnerChanged DWFOwnable rOwnable  )  throw ( DWFException ) [protected, virtual]
 

Reimplemented from DWFCore::DWFOwner.

virtual _DWFTK_API void DWFToolkit::DWFResourceContainer::onAfterResourceHRefChanged DWFResource pResource  )  throw () [virtual]
 

virtual _DWFTK_API void DWFToolkit::DWFResourceContainer::onBeforeResourceHRefChanged DWFResource pResource  )  throw () [virtual]
 

_DWFTK_API DWFResource* DWFToolkit::DWFResourceContainer::removeResource DWFResource rResource,
bool  bDeleteIfOwned
throw ( DWFException )
 

Clears the resource from the container.

Parameters:
rResource The resource object to remove from this container.
bDeleteIfOwned If true and this container currently owns the resource, it will be deleted; otherwise, the resource must be tracked by the caller who must either explicitly delete it using the DWFCORE_FREE_OBJECT macro or recognize that another object has claimed ownership of it.
Returns:
The resource that was removed. If the resource was deleted, this pointer will be NULL.
Exceptions:
DWFException 
Todo:
Passing in an object reference when it might be deleted is a little strange. Change to take a pointer instead.

_DWFTK_API DWFResource* DWFToolkit::DWFResourceContainer::removeResourceByHREF const DWFString zHRef,
bool  bDeleteIfOwned
throw ( DWFException )
 

Clears the resource from the container.

Parameters:
zHRef A unique identifier of a resource object to remove from this container.
bDeleteIfOwned If true and this container currently owns the resource, it will be deleted; otherwise, the resource must be tracked by the caller who must either explicitly delete it using the DWFCORE_FREE_OBJECT macro or recognize that another object has claimed ownership of it.
Returns:
The resource that was removed. If the resource was deleted, this pointer will be NULL.
Exceptions:
DWFException 

_DWFTK_API ResourceIterator* DWFToolkit::DWFResourceContainer::removeResourcesByMIME const DWFString zMIME,
bool  bDeleteIfOwned
throw ( DWFException )
 

Clears all resources that share a MIME type from the container.

Parameters:
zMIME The MIME type of the resources to remove from this container.
bDeleteIfOwned If true and this container currently owns any of the resources, they will be deleted; otherwise, the resources found in the iterator must be tracked by the caller who must either explicitly delete them using the DWFCORE_FREE_OBJECT macro or recognize that another object has claimed ownership of some or all of them.
Returns:
A pointer to an iterator for enumerating the resources that were removed from the container but not deleted.
Exceptions:
DWFException 

virtual _DWFTK_API ResourceIterator* DWFToolkit::DWFResourceContainer::removeResourcesByRole const DWFString zRole,
bool  bDeleteIfOwned
throw ( DWFException ) [virtual]
 

Clears all resources that share a role from the container.

Parameters:
zRole The role of the resources to remove from this container.
bDeleteIfOwned If true and this container currently owns any of the resources, they will be deleted; otherwise, the resources found in the iterator must be tracked by the caller who must either explicitly delete them using the DWFCORE_FREE_OBJECT macro or recognize that another object has claimed ownership of some or all of them.
Returns:
A pointer to an iterator for enumerating the resources that were removed from the container but not deleted.
Exceptions:
DWFException 

void DWFToolkit::DWFResourceContainer::rename const DWFString zName  )  throw () [inline, protected]
 

For internal use only.

Allows the specializing class (sections) to associate a (their) name with the container so when the resources are serialized their HREF attributes are updated correctly.

This is obviously an internal publishing API but may be useful for specialized section classes.

Parameters:
zName The new name.
Exceptions:
None 

Reimplemented in DWFToolkit::DWFSection.

Definition at line 636 of file ResourceContainer.h.

_DWFTK_API size_t DWFToolkit::DWFResourceContainer::resourceCount  )  const throw ()
 

Returns the number of resources in the container.

Returns:
The resource count.
Exceptions:
None 


The documentation for this class was generated from the following file:
Generated on Tue Jan 6 22:40:37 2009 for Autodesk DWF Toolkit by  doxygen 1.4.5