FBX SDK Reference Guide: kfbxusernotification.h Source File
Go to the documentation of this file.
00001 
00004 #ifndef _FBXSDK_USER_NOTIFICATION_H_
00005 #define _FBXSDK_USER_NOTIFICATION_H_
00006 
00007 /**************************************************************************************
00008 
00009  Copyright © 2001 - 2008 Autodesk, Inc. and/or its licensors.
00010  All Rights Reserved.
00011 
00012  The coded instructions, statements, computer programs, and/or related material 
00013  (collectively the "Data") in these files contain unpublished information 
00014  proprietary to Autodesk, Inc. and/or its licensors, which is protected by 
00015  Canada and United States of America federal copyright law and by international 
00016  treaties. 
00017  
00018  The Data may not be disclosed or distributed to third parties, in whole or in
00019  part, without the prior written consent of Autodesk, Inc. ("Autodesk").
00020 
00021  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00022  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
00023  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING
00024  BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE, 
00025  NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE. 
00026  WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION
00027  OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE. 
00028  
00029  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
00030  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES
00031  OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER
00032  SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE
00033  OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND),
00034  HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED
00035  FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE,
00036  ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE,
00037  WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS
00038  OR DAMAGE. 
00039 
00040 **************************************************************************************/
00041 
00042 #include <kaydaradef.h>
00043 #ifndef KFBX_DLL 
00044     #define KFBX_DLL K_DLLIMPORT
00045 #endif
00046 
00047 #include <stdio.h>
00048 #include <klib/karrayul.h>
00049 #include <klib/kstring.h>
00050 #include <klib/kset.h>
00051 
00052 #ifndef MB_FBXSDK
00053 #include <kbaselib_nsuse.h>
00054 #endif
00055 
00056 #include <fbxfilesdk_nsbegin.h>
00057 
00058 class KFbxLogFile;
00059 class KFbxMessageEmitter;
00060 class KFbxNode;
00061 class KFbxUserNotificationFilteredIterator;
00062 class KFbxSdkManager;
00063 
00069 class KFBX_DLL AccumulatorEntry
00070 {
00071 public:
00072     enum AEClass {
00073         eAE_ERROR=1,
00074         eAE_WARNING=2,
00075         eAE_INFO=4,
00076         eAE_ANY=7 
00077     };
00078 
00090     AccumulatorEntry(AEClass pAEClass, const KString& pName, const KString& pDescr, 
00091                      KString pDetail="", bool pMuteState=true);
00092 
00094     AccumulatorEntry(const AccumulatorEntry& pAE, bool pSkipDetails);
00095 
00097     ~AccumulatorEntry();
00098 
00100     AEClass GetClass() const;
00101 
00103     KString GetName() const;
00104 
00106     KString GetDescription() const;
00107 
00109     int GetDetailsCount() const;
00110 
00112     const KString* GetDetail(int id) const;
00113 
00115     bool IsMuted() const;
00116 
00117 private:
00118     friend class KFbxUserNotification;
00119     KArrayTemplate<KString*>& GetDetails();
00120     void Mute(bool pState);
00121 
00122     bool    mMute;
00123     AEClass mAEClass;
00124     KString mName;
00125     KString mDescr;
00126     KArrayTemplate<KString*> mDetails;
00127 };
00128 
00129 
00135 class KFBX_DLL KFbxUserNotification
00136 {
00137 public:
00138     static KFbxUserNotification* Create(KFbxSdkManager* pManager, 
00139                                         const KString& pLogFileName, 
00140                                         const KString& pSessionDescription);
00141 
00142     static void Destroy(KFbxSdkManager* pManager);
00143 
00159     KFbxUserNotification(KFbxSdkManager* pManager,
00160                          KString const& pLogFileName, 
00161                          KString const& pSessionDescription);
00162 
00163     virtual ~KFbxUserNotification();
00164 
00169     void InitAccumulator();
00170 
00174     void ClearAccumulator();
00175 
00176     enum AEid {
00177         eBINDPOSE_INVALIDOBJECT = 0x0000,
00178         eBINDPOSE_INVALIDROOT,
00179         eBINDPOSE_NOTALLANCESTORS_NODES,
00180         eBINDPOSE_NOTALLDEFORMING_NODES,
00181         eBINDPOSE_NOTALLANCESTORS_DEFNODES,
00182         eBINDPOSE_RELATIVEMATRIX,
00183         eFILE_IO_NOTIFICATION, // this is generic for reader and writer to log notifications.
00184         eFILE_IO_NOTIFICATION_MATERIAL,
00185         eAE_START_ID // Starting ID for any Accumulator entry added by derived classes.
00186     };
00187 
00199     int AddEntry(const int pID, const KString& pName, const KString& pDescr, AccumulatorEntry::AEClass pClass=AccumulatorEntry::eAE_WARNING);
00200 
00209     int AddDetail(int pEntryId);
00210 
00220     int AddDetail(int pEntryId, KString pString);
00221 
00231     int AddDetail(int pEntryId, KFbxNode* pNode);
00232 
00234     int  GetNbEntries() const;
00235 
00241     const AccumulatorEntry* GetEntry(int pEntryId) const;
00242 
00248     const AccumulatorEntry* GetEntryAt(int pEntryIndex) const;
00249 
00251     int GetNbDetails() const;
00252 
00262     int GetDetail(int pDetailId, const AccumulatorEntry*& pAE) const;
00263 
00265 
00270     enum OutputSource {
00271         eACCUMULATOR_ENTRY,
00272         eSEQUENCED_DETAILS
00273     };
00274 
00286     bool Output(OutputSource pOutSrc=eACCUMULATOR_ENTRY, int pIndex = -1, bool pExtraDevicesOnly = false);
00287 
00296     bool OutputById(AEid pId, OutputSource pOutSrc=eACCUMULATOR_ENTRY, bool pExtraDevicesOnly = false);
00297 
00307     bool Output(const KString& pName, const KString& pDescr, AccumulatorEntry::AEClass pClass, bool pExtraDevicesOnly = false);
00308 
00316     bool Output(KFbxUserNotificationFilteredIterator& pAEFIter, bool pExtraDevicesOnly = false);
00317 
00326     virtual void GetLogFilePath(KString& pPath);
00327     
00330     inline KString GetLogFileName() { return mLogFileName; }
00332 
00333 protected:
00334     class AESequence
00335     {
00336     public:
00337         AESequence(AccumulatorEntry* pAE, int pDetailId) :
00338             mAE(pAE),
00339             mDetailId(pDetailId)
00340             {
00341             };
00342 
00343         AccumulatorEntry* AE() { return mAE; }
00344         int DetailId() { return mDetailId; }
00345 
00346     private:
00347         AccumulatorEntry* mAE;
00348         int mDetailId;
00349     };
00350 
00351     friend class KFbxUserNotificationFilteredIterator;
00352 
00357     virtual bool PostTerminate();
00358 
00362     virtual void AccumulatorInit();
00363 
00367     virtual void AccumulatorClear();
00368 
00372     virtual void OpenExtraDevices();
00373 
00379     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AccumulatorEntry*>& pEntries);
00380     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AESequence*>& pAESequence);
00381 
00388     virtual bool SendToExtraDevices(bool pOutputNow, const AccumulatorEntry* pAccEntry, int pDetailId = -1);
00389 
00390     
00394     virtual void CloseExtraDevices();
00395 
00397     void ResetAccumulator();
00398 
00400     void ResetSequence();
00401 
00403     void SendToLog(OutputSource pOutSrc, int pId);
00404     void SendToLog(const AccumulatorEntry* pAccEntry, int pDetailId = -1);
00405 
00406 private:
00407     KString mLogFileName;
00408     KString mSessionDescription;
00409 #ifndef K_FBXSDK
00410     KFbxLogFile* mLogFile;
00411     KFbxMessageEmitter* mLog;
00412 #else
00413     KString* mLogFile;
00414     KString* mLog;
00415 #endif
00416 
00417     bool mProperlyInitialized;
00418     bool mProperlyCleaned;
00419 
00420     KSet mAccuHT;                             // The set establish a relationship between an AccumulatorEntry and it's ID
00421     KArrayTemplate<AccumulatorEntry*> mAccu;  // The array defines the order the AccumulatorEntry objects have been 
00422                                               // added to the accumulator (calls to AddEntry)
00423                                               // Both structures share the same pointers.
00424     KArrayTemplate<AESequence*> mAESequence;
00425     KFbxSdkManager*             mSdkManager;
00426 };
00427 
00428 #if 0
00429 
00434 class KFBX_DLL KFbxUserNotificationFILE : public KFbxUserNotification
00435 {
00436 public:
00437 
00438     KFbxUserNotificationFILE(KString pFileDevice, KString pLogFileName="", KString pSessionDescription="");
00439     virtual ~KFbxUserNotificationFILE();
00440 
00441     virtual void OpenExtraDevices();
00442     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AccumulatorEntry*>& pEntries);
00443     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AESequence*>& pAESequence);
00444     virtual bool SendToExtraDevices(bool pOutputNow, const AccumulatorEntry* pAccEntry, int pDetailId = -1);
00445     virtual void CloseExtraDevices();
00446 
00447 private:
00448     KString mFileDevice;
00449     FILE* mFP;
00450     int   mUseStream;
00451 };
00452 #endif
00453 
00457 class KFBX_DLL KFbxUserNotificationFilteredIterator
00458 {
00459 public:
00472     KFbxUserNotificationFilteredIterator(KFbxUserNotification& pAccumulator, 
00473             int pFilterClass,
00474             KFbxUserNotification::OutputSource pSrc = KFbxUserNotification::eSEQUENCED_DETAILS,
00475             bool pNoDetail = true);
00476 
00477     virtual ~KFbxUserNotificationFilteredIterator();
00478 
00480     int  GetNbItems() const;
00481 
00483     void Reset();
00484 
00488     AccumulatorEntry* const First();
00489 
00497     AccumulatorEntry* const Previous();
00498 
00506     AccumulatorEntry* const Next();
00507 
00508 protected:
00509     // Called in the constructor.
00510     virtual void BuildFilteredList(KFbxUserNotification& pAccumulator);
00511 
00512     int                                 mIterator;
00513     int                                 mFilterClass;
00514     bool                                mNoDetail;
00515     KFbxUserNotification::OutputSource  mAccuSrcData;
00516     KArrayTemplate<AccumulatorEntry*>   mFilteredAE;
00517 };
00518 
00519 
00520 #include <fbxfilesdk_nsend.h>
00521 
00522 #endif // #define _FBXSDK_USER_NOTIFICATION_H_
00523 
00524