IAssetAccessor Class Reference

IAssetAccessor Class Referenceabstract

#include <IAssetAccessor.h>

Class Description

A callback interface for declaring and modifying an asset reference.

A callback class used in conjunction with IEnumAuxAssetsCallback to declare an asset used by this application component. Accessor methods provide high-level information about the assets, and one mutator method - SetPath, is used at the time of declaration to retarget an asset. Classes implementing this interface need not worry about maintaining a persistent link to this interface. It should only be instantiated within the scope of a call to the client's EnumAuxFiles function. When the asset is declared, at that point the enumerating code may choose to retarget the asset.

class PointCacheAssetAccessor : public IAssetAccessor {
public:
PointCacheAssetAccessor(PointCacheBase* aPointCache);
// path accessor functions
virtual const MCHAR* GetPath() const ;
virtual void SetPath(const MSTR& aNewPath) ;
// asset client information
virtual int GetAssetType() const ;
protected:
PointCacheBase* mPointCache;
};
PointCacheAssetAccessor::PointCacheAssetAccessor(PointCacheBase* aPointCache) :
mPointCache(aPointCache)
{
}
const MCHAR *fname;
mPointCache->pblock->GetValue(pb_cache_file,0,fname,iv);
return fname;
}
void PointCacheAssetAccessor::SetPath(const MSTR& aNewPath) {
mPointCache->pblock->SetValue(pb_cache_file, 0, aNewPath.data());
}
int PointCacheAssetAccessor::GetAssetType() const {
}
void PointCacheBase::EnumAuxFiles(AssetEnumCallback& nameEnum, DWORD flags)
{
if ((flags&FILE_ENUM_CHECK_AWORK1)&&TestAFlag(A_WORK1)) return; // LAM - 4/11/03
PointCacheAssetAccessor accessor(this);
const MCHAR* test = accessor.GetPath();
if(test && test[0] != _M('\0')) {
IEnumAuxAssetsCallback* callback = static_cast<IEnumAuxAssetsCallback*>(&nameEnum);
callback->DeclareAsset(accessor);
// NOTE: callback object can call SetPath on
// on the accessor within the scope of this call
}
}
else {
// do normal enum business
}
}

Notice that the accessor does not need to survive beyond the scope which contains the call to

callback->DeclareAsset(IAssetAccessor& anAccessor);

Clients must implement GetPath() and SetPath(), and GetAssetType(). The asset type must be one of the types declared as AssetType.

A client wishing to declare a new category of assets can do so by returning kOtherAsset as a type and implementing the GetAssetDesc() and GetAssetTypeIcon() functions.

Finally, other methods exist that allow a client to return varying amounts of information about an asset. See methods below for details.

+ Inheritance diagram for IAssetAccessor:

Public Member Functions

virtual MaxSDK::AssetManagement::AssetUser GetAsset () const =0
 enum AssetType has been moved to iAsset.h. More...
 
virtual bool SetAsset (const MaxSDK::AssetManagement::AssetUser &aNewAssetUser)=0
 Implementing classes should implement this method so that a call to this method causes the component to point to a newly declared asset. More...
 
virtual CoreExport bool IsInputAsset () const
 Should return whether this is an input asset. More...
 
virtual MaxSDK::AssetManagement::AssetType GetAssetType () const =0
 Returns the asset type for this asset declaration. More...
 
virtual CoreExport const MCHARGetAssetDesc () const
 Returns an asset description string, or NULL if this is a standard asset. More...
 
virtual CoreExport const MCHARGetAssetTypeIcon () const
 Returns the full path of an icon file associated with a custom asset description. More...
 
virtual CoreExport const MCHARGetAssetClientDesc () const
 A brief description string of the asset client. More...
 
virtual CoreExport bool IsAssetPathWritable () const
 Whether it is possible to retarget this client's asset. More...
 
virtual CoreExport const MCHARGetRetargetErrorMsg () const
 Allows a client to return an error message related to a failed SetPath attempt. More...
 
- Public Member Functions inherited from InterfaceServer
virtual UtilExport ~InterfaceServer ()
 Destructor. More...
 
virtual UtilExport BaseInterfaceGetInterface (Interface_ID id)
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 

Member Function Documentation

virtual MaxSDK::AssetManagement::AssetUser GetAsset ( ) const
pure virtual

enum AssetType has been moved to iAsset.h.

See iAsset.h for the various assets types supported by this accessor. Gets the AssetUser pointing on the asset. Gets the full path of the asset, as declared by the asset.

Returns
the asset's AssetUser
virtual bool SetAsset ( const MaxSDK::AssetManagement::AssetUser aNewAssetUser)
pure virtual

Implementing classes should implement this method so that a call to this method causes the component to point to a newly declared asset.

Note: If an error occurs while repathing, the client might choose to indicate this by returning an error message via GetRetargetErrorMsg().

Precondition
This call will only ever be made within the scope of an EnumAuxFiles call on the application component.
Postcondition
The component should now be referring to the new asset path passed into this method.
Parameters
[in]aNewAssetUserAn AssetUser of a new asset to refer to. The path of the AssetUser need not be a fully-qualified path.
virtual CoreExport bool IsInputAsset ( ) const
virtual

Should return whether this is an input asset.

This method should return true if the asset in question is used as an input to a render. An example of an asset that is not an input would be a RenderElements output asset.

Returns
true if the asset is an input asset

Default implementation: returns true

virtual MaxSDK::AssetManagement::AssetType GetAssetType ( ) const
pure virtual

Returns the asset type for this asset declaration.

Should return an asset type defined in the AssetType enum above. If the asset does not fall under one of the predefined categories, declare the asset as kOtherAsset.

In this case, the GetAssetDesc() should return an appropriate string defining the category to which this asset belongs.

Returns
the asset type for this declared asset
virtual CoreExport const MCHAR* GetAssetDesc ( ) const
virtual

Returns an asset description string, or NULL if this is a standard asset.

A component can normally return NULL for this method if the asset declaration falls under one of the pre-defined categories. If an component declares an as kOtherAsset, then it should return an appropriate asset type description (i.e. in the vein of Bitmap, Photometric, etc.) This description will be used to visually group assets together. A third-party developer can therefore define a new asset group type by consistently returning the same description string for their declared assets, and this will be reflected appropriately in the application interface.

Returns
NULL, or a string describing the asset type if the asset type returned for GetAssetType() is kOtherAsset

Default implementation: returns NULL

virtual CoreExport const MCHAR* GetAssetTypeIcon ( ) const
virtual

Returns the full path of an icon file associated with a custom asset description.

If the asset type returned by this accessor is kOtherAsset, and the asset description returned by GetAssetDesc() is non-NULL, then this method should be overwritten to return the full path of an icon file (*.ico) that should be used as the icon for this new asset category. Otherwise, the result from this field is ignored.

Precondition
GetAssetType() == kOtherAsset, and GetAssetDesc() is non-NULL
Returns
The icon file (*.ico) that will be used as the icon to represent this new asset category.

Default implementation: returns NULL

virtual CoreExport const MCHAR* GetAssetClientDesc ( ) const
virtual

A brief description string of the asset client.

A one or two word description of an asset client. This description will be used to briefly describe the source client of this asset.

Returns
brief description string of the asset client

Default implementation: returns NULL

virtual CoreExport bool IsAssetPathWritable ( ) const
virtual

Whether it is possible to retarget this client's asset.

There are cases where an asset can be declared, but cannot be retargeted. If this is the case for an implementing client, then false should be returned here.

Returns
Whether it is possible to retarget this client's asset

Default implementation: returns true

virtual CoreExport const MCHAR* GetRetargetErrorMsg ( ) const
virtual

Allows a client to return an error message related to a failed SetPath attempt.

An asset client can report a SetPath error via this method. If an error occurs during the SetPath call, then this method should report the error. A manager which calls SetPath on an IAssetAccessor should call GetRetargetErrorMsg() to determine whether the SetPath succeeded. GetRetargetErrorMsg should return NULL if no error occurs.

Returns
NULL if there is no error to report, an error string if an error occured while repathing the asset Default implementation: returns NULL