AssetUser.h

Go to the documentation of this file.
00001 //**************************************************************************/
00002 // Copyright 2008 Autodesk, Inc.  All rights reserved.
00003 // 
00004 // Use of this software is subject to the terms of the Autodesk license agreement
00005 // provided at the time of installation or download, or which otherwise accompanies 
00006 // this software in either electronic or hard copy form.   
00007 
00008 //**************************************************************************/
00009 // DESCRIPTION: Contains definitions of classes used in asset management
00010 // AUTHOR: Chloe Mignot
00011 // DATE: 2008-07-14 (YYYY-MM-DD) 
00012 //***************************************************************************/
00013 
00014 #ifndef _MAXSDK_ASSET_USER_H_
00015 #define _MAXSDK_ASSET_USER_H_
00016 
00017 
00018 #include "..\maxheap.h"
00019 #include "..\strclass.h"
00020 #include "..\path.h"
00021 #include "..\ifnpub.h"
00022 #include "..\autoptr.h"
00023 #include "AssetType.h"
00024 #include "AssetId.h"
00025 #include "assetmanagementExport.h"
00026 
00027 // forward declarations
00028 class FileResolutionMgrImp;
00029 
00030 #define IID_IASSET_USER Interface_ID(0x32f7bccf, 0xf1881566)
00031 
00032 namespace MaxSDK
00033 {
00034     namespace AssetManagement
00035     {
00036         class AssetUser: public IObject, public FPMixinInterface
00037         {
00038         private:
00039             class AssetUserImp;
00040             AutoPtr<AssetUserImp> mImpl;
00041             unsigned int m_referencesHeld; // IObject ref count
00042             static UINT64 num_created;
00043             static UINT64 num_alive;
00044         public:
00045 
00047             CoreExport AssetUser();
00048 
00052             CoreExport AssetUser(const AssetId& assetId);
00053 
00056             CoreExport AssetUser(const AssetUser& assetU);
00057 
00060             CoreExport AssetUser& operator=(const AssetUser& assetU);
00061 
00064             CoreExport const AssetId& GetId()const;
00065 
00068             CoreExport MSTR GetIdAsString()const;
00069 
00072             CoreExport AssetType GetType() const;
00073 
00076             CoreExport const MSTR& GetFileName()const;
00077 
00081             CoreExport MSTR GetFullFilePath()const;
00082 
00090             CoreExport bool GetFullFilePath(MaxSDK::Util::Path& filePath)const;
00091 
00099             CoreExport bool GetFullFilePath(MSTR& filePath)const;
00100 
00110             CoreExport void SetUsedInFileSave();
00111 
00114             CoreExport void Reset();
00115 
00117 
00121             CoreExport IOResult Save(ISave* isave) const;
00122 
00123             CoreExport ~AssetUser();
00124 
00127             static CoreExport UINT64 GetNumCreated();
00128 
00131             static CoreExport UINT64 GetNumAlive();
00132 
00133 
00134             // this will enable the FRMImp class to invoke the protected functions below
00135             friend class ::FileResolutionMgrImp;
00136 
00137             // IObject virtual methods
00138             BaseInterface* GetInterface(Interface_ID id);
00139             BaseInterface * GetInterfaceAt(int i)const;
00140             MCHAR * GetIObjectName() { return _M("AssetUser");}
00141             int NumInterfaces()const;
00142             void AcquireIObject();
00143             void ReleaseIObject();
00144             void DeleteIObject();
00145 
00146             // FPMixinInterface virtual methods
00147             LifetimeType     LifetimeControl() { return wantsRelease; }
00148             FPInterfaceDesc* GetDescByID(Interface_ID id);
00149             Interface_ID     GetID() { return IID_IASSET_USER; }
00150             FPInterfaceDesc* GetDesc() { return GetDescByID(IID_IASSET_USER); }
00151 
00152             // FP-published symbolic enumerations
00153             enum {  asset_type };
00154 
00155             // Function IDs for function publishing
00156             enum
00157             {
00158                 kGetAssetId,
00159                 kGetFileName,
00160                 kGetType,
00161                 kCanGetFullFilePath,
00162                 kGetFullFilePath,
00163             };
00164             #pragma warning(push)
00165             #pragma warning(disable:4238)
00166             BEGIN_FUNCTION_MAP
00167                 FN_0(kGetAssetId, TYPE_TSTR_BV, GetIdAsString);
00168                 FN_0(kGetFileName, TYPE_TSTR_BV, GetFileName);
00169                 FN_0(kGetType, TYPE_ENUM, GetType);
00170                 FN_1(kCanGetFullFilePath, TYPE_bool, GetFullFilePath, TYPE_TSTR_BR);
00171                 FN_0(kGetFullFilePath, TYPE_TSTR_BV, GetFullFilePath);
00172             END_FUNCTION_MAP
00173             #pragma warning(pop)
00174 
00175         protected:
00182             CoreExport const MSTR& GetResolvedAssetPath() const;
00183 
00195             CoreExport bool SetResolvedAssetPath(const MSTR& resolvedPath);
00196 
00197             /* \brief Returns the time in milliseconds that the asset was last resolved by the file resolution manager
00198 
00199             This is the time since Windows started. 
00200 
00201             If the asset has not yet been resolved, it returns 0
00202 
00203             Note: the asset referred to here is the asset that this AssetUser instance points to
00204 
00205             \return the time in milliseconds that the asset was last resolved
00206             */
00207             CoreExport DWORD GetTimePathWasResolved() const;
00208 
00209             /* \brief Sets the time that the asset's location was most recently resolved
00210 
00211             newTime can be obtained by a call to the Win32 function, timeGetTime(VOID). It
00212             is the time in milliseconds since Windows was started.
00213 
00214             param[in] newTime the time in milliseconds that the asset was most recently resolved
00215 
00216             Note: the asset referred to here is the asset that this AssetUser instance points to
00217             */
00218             CoreExport void SetTimePathWasResolved(DWORD newTime);
00219 
00220         };
00221 
00222     }
00223 }
00224 
00225 #if !defined(NDEBUG) && defined(BUILD_WITH_IMPL)
00226 // Debug and Hybrid builds can pull in implementation details
00227 #include "..\..\..\core\AssetUserImp.h"
00228 #endif
00229 
00230 #endif