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 - 2009 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 <fbxfilesdk/components/kbaselib/kaydaradef_h.h>
00043 #include <stdio.h>
00044 #include <fbxfilesdk/components/kbaselib/klib/karrayul.h>
00045 #include <fbxfilesdk/components/kbaselib/klib/kstring.h>
00046 #include <fbxfilesdk/components/kbaselib/klib/kset.h>
00047 
00048 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00049 
00050 class KFbxMessageEmitter;
00051 class KFbxNode;
00052 class KFbxUserNotificationFilteredIterator;
00053 class KFbxSdkManager;
00054 class KFbxLogFile;
00055 
00061 class KFBX_DLL AccumulatorEntry
00062 {
00063 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 
00095     AccumulatorEntry(const AccumulatorEntry& pAE, bool pSkipDetails);
00096 
00098     ~AccumulatorEntry();
00099 
00101     AEClass GetClass() const;
00102 
00104     KString GetName() const;
00105 
00107     KString    GetDescription() const;
00108 
00110     int GetDetailsCount() const;
00111 
00116     const KString* GetDetail(int id) const;
00117 
00119     bool IsMuted() const;
00120 
00121 private:
00122     friend class KFbxUserNotification;
00123     KArrayTemplate<KString*>& GetDetails();
00124     void Mute(bool pState);
00125 
00126     bool    mMute;
00127     AEClass mAEClass;
00128     KString mName;
00129     KString mDescr;
00130     KArrayTemplate<KString*> mDetails;
00131 };
00132 
00133 
00139 class KFBX_DLL KFbxUserNotification
00140 {
00141 public:
00142     static KFbxUserNotification* Create(KFbxSdkManager* pManager, 
00143                                         const KString& pLogFileName, 
00144                                         const KString& pSessionDescription);
00145 
00146     static void Destroy(KFbxSdkManager* pManager);
00147 
00163     KFbxUserNotification(KFbxSdkManager* pManager,
00164                          KString const& pLogFileName, 
00165                          KString const& pSessionDescription);
00166 
00168     virtual ~KFbxUserNotification();
00169 
00174     void InitAccumulator();
00175 
00179     void ClearAccumulator();
00180 
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         eAE_START_ID // Starting ID for any Accumulator entry added by derived classes.
00202     };
00203 
00215     int AddEntry(const int pID, const KString& pName, const KString& pDescr, AccumulatorEntry::AEClass pClass=AccumulatorEntry::eAE_WARNING);
00216 
00225     int AddDetail(int pEntryId);
00226 
00236     int AddDetail(int pEntryId, KString pString);
00237 
00247     int AddDetail(int pEntryId, KFbxNode* pNode);
00248 
00250     int  GetNbEntries() const;
00251 
00257     const AccumulatorEntry* GetEntry(int pEntryId) const;
00258 
00264     const AccumulatorEntry* GetEntryAt(int pEntryIndex) const;
00265 
00267     int GetNbDetails() const;
00268 
00278     int GetDetail(int pDetailId, const AccumulatorEntry*& pAE) const;
00279 
00281 
00290     enum OutputSource {
00291         eACCUMULATOR_ENTRY,
00292         eSEQUENCED_DETAILS
00293     };
00294 
00306     bool Output(OutputSource pOutSrc=eACCUMULATOR_ENTRY, int pIndex = -1, bool pExtraDevicesOnly = false);
00307 
00316     bool OutputById(AEid pId, OutputSource pOutSrc=eACCUMULATOR_ENTRY, bool pExtraDevicesOnly = false);
00317 
00327     bool Output(const KString& pName, const KString& pDescr, AccumulatorEntry::AEClass pClass, bool pExtraDevicesOnly = false);
00328 
00336     bool Output(KFbxUserNotificationFilteredIterator& pAEFIter, bool pExtraDevicesOnly = false);
00337 
00346     virtual void GetLogFilePath(KString& pPath);
00347     
00350     inline KString GetLogFileName() { return mLogFileName; }
00352 
00353 protected:
00354     class AESequence
00355     {
00356     public:
00357         AESequence(AccumulatorEntry* pAE, int pDetailId) :
00358             mAE(pAE),
00359             mDetailId(pDetailId)
00360             {
00361             };
00362 
00363         AccumulatorEntry* AE() { return mAE; }
00364         int DetailId() { return mDetailId; }
00365 
00366     private:
00367         AccumulatorEntry* mAE;
00368         int mDetailId;
00369     };
00370 
00371     friend class KFbxUserNotificationFilteredIterator;
00372 
00377     virtual bool PostTerminate();
00378 
00382     virtual void AccumulatorInit();
00383 
00387     virtual void AccumulatorClear();
00388 
00392     virtual void OpenExtraDevices();
00393 
00401     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AccumulatorEntry*>& pEntries);
00402 
00410     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AESequence*>& pAESequence);
00411 
00421     virtual bool SendToExtraDevices(bool pOutputNow, const AccumulatorEntry* pAccEntry, int pDetailId = -1);
00422 
00423     
00427     virtual void CloseExtraDevices();
00428 
00430     void ResetAccumulator();
00431 
00433     void ResetSequence();
00434 
00439     void SendToLog(OutputSource pOutSrc, int pId);
00440 
00445     void SendToLog(const AccumulatorEntry* pAccEntry, int pDetailId = -1);
00446 
00447 private:
00448     KString mLogFileName;
00449     KString* mLog;
00450     KFbxLogFile* mLogFile;
00451     KFbxMessageEmitter* mLogMessageEmitter;
00452 
00453     bool mProperlyInitialized;
00454     KString mSessionDescription;
00455     bool mProperlyCleaned;
00456 
00457     KSet mAccuHT;                             // The set establish a relationship between an AccumulatorEntry and it's ID
00458     KArrayTemplate<AccumulatorEntry*> mAccu;  // The array defines the order the AccumulatorEntry objects have been 
00459                                               // added to the accumulator (calls to AddEntry)
00460                                               // Both structures share the same pointers.
00461     KArrayTemplate<AESequence*> mAESequence;
00462     KFbxSdkManager*             mSdkManager;
00463 };
00464 
00465 #if 0
00466 
00471 class KFBX_DLL KFbxUserNotificationFILE : public KFbxUserNotification
00472 {
00473 public:
00474 
00475     KFbxUserNotificationFILE(KString pFileDevice, KString pLogFileName="", KString pSessionDescription="");
00476     virtual ~KFbxUserNotificationFILE();
00477 
00478     virtual void OpenExtraDevices();
00479     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AccumulatorEntry*>& pEntries);
00480     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AESequence*>& pAESequence);
00481     virtual bool SendToExtraDevices(bool pOutputNow, const AccumulatorEntry* pAccEntry, int pDetailId = -1);
00482     virtual void CloseExtraDevices();
00483 
00484 private:
00485     KString mFileDevice;
00486     FILE* mFP;
00487     int   mUseStream;
00488 };
00489 #endif
00490 
00494 class KFBX_DLL KFbxUserNotificationFilteredIterator
00495 {
00496 public:
00509     KFbxUserNotificationFilteredIterator(KFbxUserNotification& pAccumulator, 
00510             int pFilterClass,
00511             KFbxUserNotification::OutputSource pSrc = KFbxUserNotification::eSEQUENCED_DETAILS,
00512             bool pNoDetail = true);
00513 
00514     virtual ~KFbxUserNotificationFilteredIterator();
00515 
00517     int  GetNbItems() const;
00518 
00520     void Reset();
00521 
00525     AccumulatorEntry* const First();
00526 
00534     AccumulatorEntry* const Previous();
00535 
00543     AccumulatorEntry* const Next();
00544 
00545 protected:
00546     // Called in the constructor.
00547     virtual void BuildFilteredList(KFbxUserNotification& pAccumulator);
00548 
00549     int                                    mIterator;
00550     int                                    mFilterClass;
00551     bool                                mNoDetail;
00552     KFbxUserNotification::OutputSource    mAccuSrcData;
00553     KArrayTemplate<AccumulatorEntry*>    mFilteredAE;
00554 };
00555 
00556 
00557 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00558 
00559 #endif // FBXFILESDK_KFBXPLUGINS_KFBXUSERNOTIFICATION_H
00560