kfbxusernotification.h

Go to the documentation of this file.
00001 /****************************************************************************************
00002 
00003    Copyright (C) 2010 Autodesk, Inc.
00004    All rights reserved.
00005 
00006    Use of this software is subject to the terms of the Autodesk license agreement
00007    provided at the time of installation or download, or which otherwise accompanies
00008    this software in either electronic or hard copy form.
00009 
00010 ****************************************************************************************/
00011 
00015 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXUSERNOTIFICATION_H
00016 #define FBXFILESDK_KFBXPLUGINS_KFBXUSERNOTIFICATION_H
00017 
00018 
00019 #include <fbxfilesdk/fbxfilesdk_def.h>
00020 
00021 #include <fbxfilesdk/components/kbaselib/klib/karrayul.h>
00022 #include <fbxfilesdk/components/kbaselib/klib/kstring.h>
00023 #include <fbxfilesdk/components/kbaselib/klib/kset.h>
00024 
00025 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00026 
00027 class KFbxMessageEmitter;
00028 class KFbxNode;
00029 class KFbxUserNotificationFilteredIterator;
00030 class KFbxSdkManager;
00031 class KFbxLogFile;
00032 
00039 class KFBX_DLL AccumulatorEntry
00040 {
00041 public:
00044     enum AEClass {
00045         eAE_ERROR=1,    
00046         eAE_WARNING=2,  
00047         eAE_INFO=4,     
00048         eAE_ANY=7       
00049     };
00050 
00062     AccumulatorEntry(AEClass pAEClass, const KString& pName, const KString& pDescr, 
00063                      KString pDetail="", bool pMuteState=true);
00064 
00069     AccumulatorEntry(const AccumulatorEntry& pAE, bool pSkipDetails);
00070 
00072     ~AccumulatorEntry();
00073 
00075     AEClass GetClass() const;
00076 
00078     KString GetName() const;
00079 
00081     KString    GetDescription() const;
00082 
00084     int GetDetailsCount() const;
00085 
00092     const KString* GetDetail(int id) const;
00093 
00095     bool IsMuted() const;
00096 
00097 private:
00098     friend class KFbxUserNotification;
00099     KArrayTemplate<KString*>& GetDetails();
00100     void Mute(bool pState);
00101 
00102     bool    mMute;
00103     AEClass mAEClass;
00104     KString mName;
00105     KString mDescr;
00106     KArrayTemplate<KString*> mDetails;
00107 };
00108 
00109 
00114 class KFBX_DLL KFbxUserNotification
00115 {
00116 public:
00128     static KFbxUserNotification* Create(KFbxSdkManager* pManager, 
00129                                         const KString& pLogFileName, 
00130                                         const KString& pSessionDescription);
00131 
00135     static void Destroy(KFbxSdkManager* pManager);
00136 
00152     KFbxUserNotification(KFbxSdkManager* pManager,
00153                          KString const& pLogFileName, 
00154                          KString const& pSessionDescription);
00155 
00157     virtual ~KFbxUserNotification();
00158 
00165     void InitAccumulator();
00166 
00170     void ClearAccumulator();
00171 
00174     enum AEid {
00175         eBINDPOSE_INVALIDOBJECT = 0x0000,
00176         eBINDPOSE_INVALIDROOT,
00177         eBINDPOSE_NOTALLANCESTORS_NODES,
00178         eBINDPOSE_NOTALLDEFORMING_NODES,
00179         eBINDPOSE_NOTALLANCESTORS_DEFNODES,
00180         eBINDPOSE_RELATIVEMATRIX,
00181         eFILE_IO_NOTIFICATION,       
00182         eFILE_IO_NOTIFICATION_MATERIAL,
00183         eFILE_IO_NOTIFICATION_DXF_NOT_SUPPORT_NURBS,
00184         eAE_START_ID                 
00185     };
00186 
00198     int AddEntry(const int pID, const KString& pName, const KString& pDescr, AccumulatorEntry::AEClass pClass=AccumulatorEntry::eAE_WARNING);
00199 
00208     int AddDetail(int pEntryId);
00209 
00219     int AddDetail(int pEntryId, KString pString);
00220 
00230     int AddDetail(int pEntryId, KFbxNode* pNode);
00231 
00233     int  GetNbEntries() const;
00234 
00240     const AccumulatorEntry* GetEntry(int pEntryId) const;
00241 
00247     const AccumulatorEntry* GetEntryAt(int pEntryIndex) const;
00248 
00250     int GetNbDetails() const;
00251 
00261     int GetDetail(int pDetailId, const AccumulatorEntry*& pAE) const;
00262 
00264 
00271     enum OutputSource {
00272         eACCUMULATOR_ENTRY,     
00273         eSEQUENCED_DETAILS      
00274     };
00275 
00287     bool Output(OutputSource pOutSrc=eACCUMULATOR_ENTRY, int pIndex = -1, bool pExtraDevicesOnly = false);
00288 
00297     bool OutputById(AEid pId, OutputSource pOutSrc=eACCUMULATOR_ENTRY, bool pExtraDevicesOnly = false);
00298 
00308     bool Output(const KString& pName, const KString& pDescr, AccumulatorEntry::AEClass pClass, bool pExtraDevicesOnly = false);
00309 
00317     bool Output(KFbxUserNotificationFilteredIterator& pAEFIter, bool pExtraDevicesOnly = false);
00318 
00322     void SetLogMessageEmitter(KFbxMessageEmitter * pLogMessageEmitter);
00323 
00332     virtual void GetLogFilePath(KString& pPath);
00333     
00335     inline KString GetLogFileName() { return mLogFileName; }
00337 
00338 protected:
00342     class AESequence
00343     {
00344     public:
00345         AESequence(AccumulatorEntry* pAE, int pDetailId) :
00346             mAE(pAE),
00347             mDetailId(pDetailId)
00348             {
00349             };
00350 
00352         AccumulatorEntry* AE() { return mAE; }
00354         int DetailId() { return mDetailId; }
00355 
00356     private:
00357         AccumulatorEntry* mAE;
00358         int mDetailId;
00359     };
00360 
00361     friend class KFbxUserNotificationFilteredIterator;
00362 
00367     virtual bool PostTerminate();
00368 
00372     virtual void AccumulatorInit();
00373 
00377     virtual void AccumulatorClear();
00378 
00382     virtual void OpenExtraDevices();
00383 
00391     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AccumulatorEntry*>& pEntries);
00392 
00400     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AESequence*>& pAESequence);
00401 
00411     virtual bool SendToExtraDevices(bool pOutputNow, const AccumulatorEntry* pAccEntry, int pDetailId = -1);
00412 
00413     
00417     virtual void CloseExtraDevices();
00418 
00420     void ResetAccumulator();
00421 
00423     void ResetSequence();
00424 
00429     void SendToLog(OutputSource pOutSrc, int pId);
00430 
00435     void SendToLog(const AccumulatorEntry* pAccEntry, int pDetailId = -1);
00436 
00437 private:
00438     KString mLogFileName;
00439     KString* mLog;
00440     KFbxLogFile* mLogFile;
00441     KFbxMessageEmitter* mLogMessageEmitter;
00442 
00443     bool mProperlyInitialized;
00444     KString mSessionDescription;
00445     bool mProperlyCleaned;
00446 
00447     KSet mAccuHT;                             // The set establish a relationship between an AccumulatorEntry and it's ID
00448     KArrayTemplate<AccumulatorEntry*> mAccu;  // The array defines the order the AccumulatorEntry objects have been 
00449                                               // added to the accumulator (calls to AddEntry)
00450                                               // Both structures share the same pointers.
00451     KArrayTemplate<AESequence*> mAESequence;
00452     KFbxSdkManager*             mSdkManager;
00453 };
00454 
00455 #if 0
00456 
00461 class KFBX_DLL KFbxUserNotificationFILE : public KFbxUserNotification
00462 {
00463 public:
00464 
00465     KFbxUserNotificationFILE(KString pFileDevice, KString pLogFileName="", KString pSessionDescription="");
00466     virtual ~KFbxUserNotificationFILE();
00467 
00468     virtual void OpenExtraDevices();
00469     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AccumulatorEntry*>& pEntries);
00470     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AESequence*>& pAESequence);
00471     virtual bool SendToExtraDevices(bool pOutputNow, const AccumulatorEntry* pAccEntry, int pDetailId = -1);
00472     virtual void CloseExtraDevices();
00473 
00474 private:
00475     KString mFileDevice;
00476     FILE* mFP;
00477     int   mUseStream;
00478 };
00479 #endif
00480 
00484 class KFBX_DLL KFbxUserNotificationFilteredIterator
00485 {
00486 public:
00499     KFbxUserNotificationFilteredIterator(KFbxUserNotification& pAccumulator, 
00500             int pFilterClass,
00501             KFbxUserNotification::OutputSource pSrc = KFbxUserNotification::eSEQUENCED_DETAILS,
00502             bool pNoDetail = true);
00503 
00504     virtual ~KFbxUserNotificationFilteredIterator();
00505 
00507     int  GetNbItems() const;
00508 
00510     void Reset();
00511 
00515     AccumulatorEntry* const First();
00516 
00524     AccumulatorEntry* const Previous();
00525 
00533     AccumulatorEntry* const Next();
00534 
00535 protected:
00536     // Called in the constructor.
00537     virtual void BuildFilteredList(KFbxUserNotification& pAccumulator);
00538 
00539     int                                    mIterator;
00540     int                                    mFilterClass;
00541     bool                                mNoDetail;
00542     KFbxUserNotification::OutputSource    mAccuSrcData;
00543     KArrayTemplate<AccumulatorEntry*>    mFilteredAE;
00544 };
00545 
00546 
00547 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00548 
00549 #endif // FBXFILESDK_KFBXPLUGINS_KFBXUSERNOTIFICATION_H
00550