00001 
00004 #ifndef _FBXSDK_USER_NOTIFICATION_H_
00005 #define _FBXSDK_USER_NOTIFICATION_H_
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
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 FbxLogFile;
00059 class KFbxNode;
00060 class KFbxUserNotificationFilteredIterator;
00061 
00067 class AccumulatorEntry
00068 {
00069 public:
00070     enum AEClass {
00071         eAE_ERROR=1,
00072         eAE_WARNING=2,
00073         eAE_INFO=4,
00074         eAE_ANY=7 
00075     };
00076 
00088     AccumulatorEntry(AEClass pAEClass, const KString& pName, const KString& pDescr, 
00089                      KString pDetail="", bool pMuteState=true);
00090 
00092     AccumulatorEntry(const AccumulatorEntry& pAE, bool pSkipDetails);
00093 
00095     ~AccumulatorEntry();
00096 
00098     AEClass GetClass() const;
00099 
00101     KString GetName() const;
00102 
00104     KString GetDescription() const;
00105 
00107     int GetDetailsCount() const;
00108 
00110     const KString* GetDetail(int id) const;
00111 
00113     bool IsMuted() const;
00114 
00115 private:
00116     friend class KFbxUserNotification;
00117     KArrayTemplate<KString*>& GetDetails();
00118     void Mute(bool pState);
00119 
00120     bool    mMute;
00121     AEClass mAEClass;
00122     KString mName;
00123     KString mDescr;
00124     KArrayTemplate<KString*> mDetails;
00125 };
00126 
00127 
00133 class KFBX_DLL KFbxUserNotification
00134 {
00135 protected:
00136     friend class KFbxSdkManager;
00137 
00153     KFbxUserNotification(KString pLogFileName, KString pSessionDescription);
00154 
00155     virtual ~KFbxUserNotification();
00156 
00161     void InitAccumulator();
00162 
00166     void ClearAccumulator();
00167 
00168 public:
00169     enum AEid {
00170         eBINDPOSE_INVALIDOBJECT = 0x0000,
00171         eBINDPOSE_INVALIDROOT,
00172         eBINDPOSE_NOTALLANCESTORS_NODES,
00173         eBINDPOSE_NOTALLDEFORMING_NODES,
00174         eBINDPOSE_NOTALLANCESTORS_DEFNODES,
00175         eBINDPOSE_RELATIVEMATRIX,
00176         eFILE_IO_NOTIFICATION, 
00177         eAE_START_ID 
00178     };
00179 
00191     int AddEntry(const int pID, const KString& pName, const KString& pDescr, AccumulatorEntry::AEClass pClass=AccumulatorEntry::eAE_WARNING);
00192 
00202     int AddDetail(int pEntryId);
00203     int AddDetail(int pEntryId, KString pString);
00204     int AddDetail(int pEntryId, KFbxNode* pNode);
00205 
00207     int  GetNbEntries() const;
00208 
00214     const AccumulatorEntry* GetEntry(int pEntryId) const;
00215 
00221     const AccumulatorEntry* GetEntryAt(int pEntryIndex) const;
00222 
00224     int GetNbDetails() const;
00225 
00235     int GetDetail(int pDetailId, const AccumulatorEntry*& pAE) const;
00236 
00238 
00243     enum OutputSource {
00244         eACCUMULATOR_ENTRY,
00245         eSEQUENCED_DETAILS
00246     };
00247 
00259     bool Output(OutputSource pOutSrc=eACCUMULATOR_ENTRY, int pIndex = -1, bool pExtraDevicesOnly = false);
00260 
00269     bool OutputById(AEid pId, OutputSource pOutSrc=eACCUMULATOR_ENTRY, bool pExtraDevicesOnly = false);
00270 
00280     bool Output(const KString& pName, const KString& pDescr, AccumulatorEntry::AEClass pClass, bool pExtraDevicesOnly = false);
00281 
00289     bool Output(KFbxUserNotificationFilteredIterator& pAEFIter, bool pExtraDevicesOnly = false);
00290 
00299     virtual void GetLogFilePath(KString& pPath);
00300     
00303     inline KString GetLogFileName() { return mLogFileName; }
00305 
00306 protected:
00307     class AESequence
00308     {
00309     public:
00310         AESequence(AccumulatorEntry* pAE, int pDetailId) :
00311             mAE(pAE),
00312             mDetailId(pDetailId)
00313             {
00314             };
00315 
00316         AccumulatorEntry* AE() { return mAE; }
00317         int DetailId() { return mDetailId; }
00318 
00319     private:
00320         AccumulatorEntry* mAE;
00321         int mDetailId;
00322     };
00323 
00324     friend class KFbxUserNotificationFilteredIterator;
00325 
00330     virtual bool PostTerminate();
00331 
00335     virtual void AccumulatorInit();
00336 
00340     virtual void AccumulatorClear();
00341 
00345     virtual void OpenExtraDevices();
00346 
00352     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AccumulatorEntry*>& pEntries);
00353     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AESequence*>& pAESequence);
00354 
00361     virtual bool SendToExtraDevices(bool pOutputNow, const AccumulatorEntry* pAccEntry, int pDetailId = -1);
00362 
00363     
00367     virtual void CloseExtraDevices();
00368 
00370     void ResetAccumulator();
00371 
00373     void ResetSequence();
00374 
00376     void SendToLog(OutputSource pOutSrc, int pId);
00377     void SendToLog(const AccumulatorEntry* pAccEntry, int pDetailId = -1);
00378 
00379 private:
00380     KString mLogFileName;
00381     KString mSessionDescription;
00382 #ifndef K_FBXSDK
00383     FbxLogFile* mLog;
00384 #else
00385     KString* mLog;
00386 #endif
00387 
00388     bool mProperlyInitialized;
00389     bool mProperlyCleaned;
00390 
00391     KSet mAccuHT;                             
00392     KArrayTemplate<AccumulatorEntry*> mAccu;  
00393                                               
00394                                               
00395     KArrayTemplate<AESequence*> mAESequence;
00396 };
00397 
00403 class KFBX_DLL KFbxUserNotificationFILE : public KFbxUserNotification
00404 {
00405 public:
00406 
00407     KFbxUserNotificationFILE(KString pFileDevice, KString pLogFileName="", KString pSessionDescription="");
00408     virtual ~KFbxUserNotificationFILE();
00409 
00410     virtual void OpenExtraDevices();
00411     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AccumulatorEntry*>& pEntries);
00412     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AESequence*>& pAESequence);
00413     virtual bool SendToExtraDevices(bool pOutputNow, const AccumulatorEntry* pAccEntry, int pDetailId = -1);
00414     virtual void CloseExtraDevices();
00415 
00416 private:
00417     KString mFileDevice;
00418     FILE* mFP;
00419     int   mUseStream;
00420 };
00421 
00422 
00427 class KFBX_DLL KFbxUserNotificationFilteredIterator
00428 {
00429 public:
00442     KFbxUserNotificationFilteredIterator(KFbxUserNotification& pAccumulator, 
00443             int pFilterClass,
00444             KFbxUserNotification::OutputSource pSrc = KFbxUserNotification::eSEQUENCED_DETAILS,
00445             bool pNoDetail = true);
00446 
00447     virtual ~KFbxUserNotificationFilteredIterator();
00448 
00450     int  GetNbItems() const;
00451 
00453     void Reset();
00454 
00458     AccumulatorEntry* const First();
00459 
00467     AccumulatorEntry* const Previous();
00468 
00476     AccumulatorEntry* const Next();
00477 
00478 protected:
00479     
00480     virtual void BuildFilteredList(KFbxUserNotification& pAccumulator);
00481 
00482     int                                 mIterator;
00483     int                                 mFilterClass;
00484     bool                                mNoDetail;
00485     KFbxUserNotification::OutputSource  mAccuSrcData;
00486     KArrayTemplate<AccumulatorEntry*>   mFilteredAE;
00487 };
00488 
00489 
00490 #include <fbxfilesdk_nsend.h>
00491 
00492 #endif // #define _FBXSDK_USER_NOTIFICATION_H_
00493 
00494