This reference page is linked to from the following overview topics: Plug-in Upgrade Guide.
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* PointCacheAssetAccessor::GetPath() const { MCHAR *fname; Interval iv; mPointCache->pblock->GetValue(pb_cache_file,0,fname,iv); return fname; } void PointCacheAssetAccessor::SetPath(const MSTR& aNewPath) { mPointCache->pblock->SetValue(pb_cache_file, 0, const_cast<MCHAR*>(aNewPath.data())); } int PointCacheAssetAccessor::GetAssetType() const { return IAssetAccessor::kAnimationAsset; } void PointCacheBase::EnumAuxFiles(AssetEnumCallback& nameEnum, DWORD flags) { if ((flags&FILE_ENUM_CHECK_AWORK1)&&TestAFlag(A_WORK1)) return; // LAM - 4/11/03 if(flags & FILE_ENUM_ACCESSOR_INTERFACE) { 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.
#include <IAssetAccessor.h>
Public Member Functions |
|
virtual MaxSDK::AssetManagement::AssetUser |
GetAsset () const =0 |
enum AssetType has been moved to iAsset.h.
|
|
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. |
|
virtual CoreExport bool | IsInputAsset () const |
Should return whether this is an input
asset. |
|
virtual MaxSDK::AssetManagement::AssetType |
GetAssetType () const =0 |
Returns the asset type for this asset
declaration. |
|
virtual CoreExport const MCHAR * | GetAssetDesc () const |
Returns an asset description string, or NULL
if this is a standard asset. |
|
virtual CoreExport const MCHAR * | GetAssetTypeIcon () const |
Returns the full path of an icon file
associated with a custom asset description. |
|
virtual CoreExport const MCHAR * | GetAssetClientDesc () const |
A brief description string of the asset
client. |
|
virtual CoreExport bool | IsAssetPathWritable () const |
Whether it is possible to retarget this
client's asset. |
|
virtual CoreExport const MCHAR * | GetRetargetErrorMsg () const |
Allows a client to return an error message
related to a failed SetPath attempt. |
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.
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().
[in] | aNewAssetUser | An 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.
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.
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.
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.
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.
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.
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.