kfbxusernotification.h

Go to the documentation of this file.
00001 
00004 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXUSERNOTIFICATION_H
00005 #define FBXFILESDK_KFBXPLUGINS_KFBXUSERNOTIFICATION_H
00006 
00007 /**************************************************************************************
00008 
00009  Copyright (C) 2001 - 2010 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 #include <fbxfilesdk/fbxfilesdk_def.h>
00042 
00043 #include <fbxfilesdk/components/kbaselib/klib/karrayul.h>
00044 #include <fbxfilesdk/components/kbaselib/klib/kstring.h>
00045 #include <fbxfilesdk/components/kbaselib/klib/kset.h>
00046 
00047 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00048 
00049 class KFbxMessageEmitter;
00050 class KFbxNode;
00051 class KFbxUserNotificationFilteredIterator;
00052 class KFbxSdkManager;
00053 class KFbxLogFile;
00054 
00060 class KFBX_DLL AccumulatorEntry
00061 {
00062 public:
00069     enum AEClass {
00070         eAE_ERROR=1,
00071         eAE_WARNING=2,
00072         eAE_INFO=4,
00073         eAE_ANY=7 
00074     };
00075 
00087     AccumulatorEntry(AEClass pAEClass, const KString& pName, const KString& pDescr, 
00088                      KString pDetail="", bool pMuteState=true);
00089 
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 
00115     const KString* GetDetail(int id) const;
00116 
00118     bool IsMuted() const;
00119 
00120 private:
00121     friend class KFbxUserNotification;
00122     KArrayTemplate<KString*>& GetDetails();
00123     void Mute(bool pState);
00124 
00125     bool    mMute;
00126     AEClass mAEClass;
00127     KString mName;
00128     KString mDescr;
00129     KArrayTemplate<KString*> mDetails;
00130 };
00131 
00132 
00138 class KFBX_DLL KFbxUserNotification
00139 {
00140 public:
00141     static KFbxUserNotification* Create(KFbxSdkManager* pManager, 
00142                                         const KString& pLogFileName, 
00143                                         const KString& pSessionDescription);
00144 
00145     static void Destroy(KFbxSdkManager* pManager);
00146 
00162     KFbxUserNotification(KFbxSdkManager* pManager,
00163                          KString const& pLogFileName, 
00164                          KString const& pSessionDescription);
00165 
00167     virtual ~KFbxUserNotification();
00168 
00173     void InitAccumulator();
00174 
00178     void ClearAccumulator();
00179 
00192     enum AEid {
00193         eBINDPOSE_INVALIDOBJECT = 0x0000,
00194         eBINDPOSE_INVALIDROOT,
00195         eBINDPOSE_NOTALLANCESTORS_NODES,
00196         eBINDPOSE_NOTALLDEFORMING_NODES,
00197         eBINDPOSE_NOTALLANCESTORS_DEFNODES,
00198         eBINDPOSE_RELATIVEMATRIX,
00199         eFILE_IO_NOTIFICATION, // this is generic for reader and writer to log notifications.
00200         eFILE_IO_NOTIFICATION_MATERIAL,
00201         eFILE_IO_NOTIFICATION_DXF_NOT_SUPPORT_NURBS,
00202         eAE_START_ID // Starting ID for any Accumulator entry added by derived classes.
00203     };
00204 
00216     int AddEntry(const int pID, const KString& pName, const KString& pDescr, AccumulatorEntry::AEClass pClass=AccumulatorEntry::eAE_WARNING);
00217 
00226     int AddDetail(int pEntryId);
00227 
00237     int AddDetail(int pEntryId, KString pString);
00238 
00248     int AddDetail(int pEntryId, KFbxNode* pNode);
00249 
00251     int  GetNbEntries() const;
00252 
00258     const AccumulatorEntry* GetEntry(int pEntryId) const;
00259 
00265     const AccumulatorEntry* GetEntryAt(int pEntryIndex) const;
00266 
00268     int GetNbDetails() const;
00269 
00279     int GetDetail(int pDetailId, const AccumulatorEntry*& pAE) const;
00280 
00282 
00291     enum OutputSource {
00292         eACCUMULATOR_ENTRY,
00293         eSEQUENCED_DETAILS
00294     };
00295 
00307     bool Output(OutputSource pOutSrc=eACCUMULATOR_ENTRY, int pIndex = -1, bool pExtraDevicesOnly = false);
00308 
00317     bool OutputById(AEid pId, OutputSource pOutSrc=eACCUMULATOR_ENTRY, bool pExtraDevicesOnly = false);
00318 
00328     bool Output(const KString& pName, const KString& pDescr, AccumulatorEntry::AEClass pClass, bool pExtraDevicesOnly = false);
00329 
00337     bool Output(KFbxUserNotificationFilteredIterator& pAEFIter, bool pExtraDevicesOnly = false);
00338 
00342     void SetLogMessageEmitter(KFbxMessageEmitter * pLogMessageEmitter);
00343 
00352     virtual void GetLogFilePath(KString& pPath);
00353     
00356     inline KString GetLogFileName() { return mLogFileName; }
00358 
00359 protected:
00360     class AESequence
00361     {
00362     public:
00363         AESequence(AccumulatorEntry* pAE, int pDetailId) :
00364             mAE(pAE),
00365             mDetailId(pDetailId)
00366             {
00367             };
00368 
00369         AccumulatorEntry* AE() { return mAE; }
00370         int DetailId() { return mDetailId; }
00371 
00372     private:
00373         AccumulatorEntry* mAE;
00374         int mDetailId;
00375     };
00376 
00377     friend class KFbxUserNotificationFilteredIterator;
00378 
00383     virtual bool PostTerminate();
00384 
00388     virtual void AccumulatorInit();
00389 
00393     virtual void AccumulatorClear();
00394 
00398     virtual void OpenExtraDevices();
00399 
00407     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AccumulatorEntry*>& pEntries);
00408 
00416     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AESequence*>& pAESequence);
00417 
00427     virtual bool SendToExtraDevices(bool pOutputNow, const AccumulatorEntry* pAccEntry, int pDetailId = -1);
00428 
00429     
00433     virtual void CloseExtraDevices();
00434 
00436     void ResetAccumulator();
00437 
00439     void ResetSequence();
00440 
00445     void SendToLog(OutputSource pOutSrc, int pId);
00446 
00451     void SendToLog(const AccumulatorEntry* pAccEntry, int pDetailId = -1);
00452 
00453 private:
00454     KString mLogFileName;
00455     KString* mLog;
00456     KFbxLogFile* mLogFile;
00457     KFbxMessageEmitter* mLogMessageEmitter;
00458 
00459     bool mProperlyInitialized;
00460     KString mSessionDescription;
00461     bool mProperlyCleaned;
00462 
00463     KSet mAccuHT;                             // The set establish a relationship between an AccumulatorEntry and it's ID
00464     KArrayTemplate<AccumulatorEntry*> mAccu;  // The array defines the order the AccumulatorEntry objects have been 
00465                                               // added to the accumulator (calls to AddEntry)
00466                                               // Both structures share the same pointers.
00467     KArrayTemplate<AESequence*> mAESequence;
00468     KFbxSdkManager*             mSdkManager;
00469 };
00470 
00471 #if 0
00472 
00477 class KFBX_DLL KFbxUserNotificationFILE : public KFbxUserNotification
00478 {
00479 public:
00480 
00481     KFbxUserNotificationFILE(KString pFileDevice, KString pLogFileName="", KString pSessionDescription="");
00482     virtual ~KFbxUserNotificationFILE();
00483 
00484     virtual void OpenExtraDevices();
00485     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AccumulatorEntry*>& pEntries);
00486     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AESequence*>& pAESequence);
00487     virtual bool SendToExtraDevices(bool pOutputNow, const AccumulatorEntry* pAccEntry, int pDetailId = -1);
00488     virtual void CloseExtraDevices();
00489 
00490 private:
00491     KString mFileDevice;
00492     FILE* mFP;
00493     int   mUseStream;
00494 };
00495 #endif
00496 
00500 class KFBX_DLL KFbxUserNotificationFilteredIterator
00501 {
00502 public:
00515     KFbxUserNotificationFilteredIterator(KFbxUserNotification& pAccumulator, 
00516             int pFilterClass,
00517             KFbxUserNotification::OutputSource pSrc = KFbxUserNotification::eSEQUENCED_DETAILS,
00518             bool pNoDetail = true);
00519 
00520     virtual ~KFbxUserNotificationFilteredIterator();
00521 
00523     int  GetNbItems() const;
00524 
00526     void Reset();
00527 
00531     AccumulatorEntry* const First();
00532 
00540     AccumulatorEntry* const Previous();
00541 
00549     AccumulatorEntry* const Next();
00550 
00551 protected:
00552     // Called in the constructor.
00553     virtual void BuildFilteredList(KFbxUserNotification& pAccumulator);
00554 
00555     int                                    mIterator;
00556     int                                    mFilterClass;
00557     bool                                mNoDetail;
00558     KFbxUserNotification::OutputSource    mAccuSrcData;
00559     KArrayTemplate<AccumulatorEntry*>    mFilteredAE;
00560 };
00561 
00562 
00563 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00564 
00565 #endif // FBXFILESDK_KFBXPLUGINS_KFBXUSERNOTIFICATION_H
00566