FBX SDK Reference Guide: kfbxusernotification.h Source File
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 © 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 <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 
00060 class KFBX_DLL AccumulatorEntry
00061 {
00062 public:
00063     enum AEClass {
00064         eAE_ERROR=1,
00065         eAE_WARNING=2,
00066         eAE_INFO=4,
00067         eAE_ANY=7 
00068     };
00069 
00081     AccumulatorEntry(AEClass pAEClass, const KString& pName, const KString& pDescr, 
00082                      KString pDetail="", bool pMuteState=true);
00083 
00088     AccumulatorEntry(const AccumulatorEntry& pAE, bool pSkipDetails);
00089 
00091     ~AccumulatorEntry();
00092 
00094     AEClass GetClass() const;
00095 
00097     KString GetName() const;
00098 
00100     KString GetDescription() const;
00101 
00103     int GetDetailsCount() const;
00104 
00109     const KString* GetDetail(int id) const;
00110 
00112     bool IsMuted() const;
00113 
00114 private:
00115     friend class KFbxUserNotification;
00116     KArrayTemplate<KString*>& GetDetails();
00117     void Mute(bool pState);
00118 
00119     bool    mMute;
00120     AEClass mAEClass;
00121     KString mName;
00122     KString mDescr;
00123     KArrayTemplate<KString*> mDetails;
00124 };
00125 
00126 
00132 class KFBX_DLL KFbxUserNotification
00133 {
00134 public:
00135     static KFbxUserNotification* Create(KFbxSdkManager* pManager, 
00136                                         const KString& pLogFileName, 
00137                                         const KString& pSessionDescription);
00138 
00139     static void Destroy(KFbxSdkManager* pManager);
00140 
00156     KFbxUserNotification(KFbxSdkManager* pManager,
00157                          KString const& pLogFileName, 
00158                          KString const& pSessionDescription);
00159 
00160     virtual ~KFbxUserNotification();
00161 
00166     void InitAccumulator();
00167 
00171     void ClearAccumulator();
00172 
00173     enum AEid {
00174         eBINDPOSE_INVALIDOBJECT = 0x0000,
00175         eBINDPOSE_INVALIDROOT,
00176         eBINDPOSE_NOTALLANCESTORS_NODES,
00177         eBINDPOSE_NOTALLDEFORMING_NODES,
00178         eBINDPOSE_NOTALLANCESTORS_DEFNODES,
00179         eBINDPOSE_RELATIVEMATRIX,
00180         eFILE_IO_NOTIFICATION, // this is generic for reader and writer to log notifications.
00181         eFILE_IO_NOTIFICATION_MATERIAL,
00182         eAE_START_ID // Starting ID for any Accumulator entry added by derived classes.
00183     };
00184 
00196     int AddEntry(const int pID, const KString& pName, const KString& pDescr, AccumulatorEntry::AEClass pClass=AccumulatorEntry::eAE_WARNING);
00197 
00206     int AddDetail(int pEntryId);
00207 
00217     int AddDetail(int pEntryId, KString pString);
00218 
00228     int AddDetail(int pEntryId, KFbxNode* pNode);
00229 
00231     int  GetNbEntries() const;
00232 
00238     const AccumulatorEntry* GetEntry(int pEntryId) const;
00239 
00245     const AccumulatorEntry* GetEntryAt(int pEntryIndex) const;
00246 
00248     int GetNbDetails() const;
00249 
00259     int GetDetail(int pDetailId, const AccumulatorEntry*& pAE) const;
00260 
00262 
00267     enum OutputSource {
00268         eACCUMULATOR_ENTRY,
00269         eSEQUENCED_DETAILS
00270     };
00271 
00283     bool Output(OutputSource pOutSrc=eACCUMULATOR_ENTRY, int pIndex = -1, bool pExtraDevicesOnly = false);
00284 
00293     bool OutputById(AEid pId, OutputSource pOutSrc=eACCUMULATOR_ENTRY, bool pExtraDevicesOnly = false);
00294 
00304     bool Output(const KString& pName, const KString& pDescr, AccumulatorEntry::AEClass pClass, bool pExtraDevicesOnly = false);
00305 
00313     bool Output(KFbxUserNotificationFilteredIterator& pAEFIter, bool pExtraDevicesOnly = false);
00314 
00323     virtual void GetLogFilePath(KString& pPath);
00324     
00327     inline KString GetLogFileName() { return mLogFileName; }
00329 
00330 protected:
00331     class AESequence
00332     {
00333     public:
00334         AESequence(AccumulatorEntry* pAE, int pDetailId) :
00335             mAE(pAE),
00336             mDetailId(pDetailId)
00337             {
00338             };
00339 
00340         AccumulatorEntry* AE() { return mAE; }
00341         int DetailId() { return mDetailId; }
00342 
00343     private:
00344         AccumulatorEntry* mAE;
00345         int mDetailId;
00346     };
00347 
00348     friend class KFbxUserNotificationFilteredIterator;
00349 
00354     virtual bool PostTerminate();
00355 
00359     virtual void AccumulatorInit();
00360 
00364     virtual void AccumulatorClear();
00365 
00369     virtual void OpenExtraDevices();
00370 
00378     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AccumulatorEntry*>& pEntries);
00379 
00387     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AESequence*>& pAESequence);
00388 
00398     virtual bool SendToExtraDevices(bool pOutputNow, const AccumulatorEntry* pAccEntry, int pDetailId = -1);
00399 
00400     
00404     virtual void CloseExtraDevices();
00405 
00407     void ResetAccumulator();
00408 
00410     void ResetSequence();
00411 
00416     void SendToLog(OutputSource pOutSrc, int pId);
00417 
00422     void SendToLog(const AccumulatorEntry* pAccEntry, int pDetailId = -1);
00423 
00424 private:
00425     KString mLogFileName;
00426     KString mSessionDescription;
00427     KString* mLog;
00428 
00429     bool mProperlyInitialized;
00430     bool mProperlyCleaned;
00431 
00432     KSet mAccuHT;                             // The set establish a relationship between an AccumulatorEntry and it's ID
00433     KArrayTemplate<AccumulatorEntry*> mAccu;  // The array defines the order the AccumulatorEntry objects have been 
00434                                               // added to the accumulator (calls to AddEntry)
00435                                               // Both structures share the same pointers.
00436     KArrayTemplate<AESequence*> mAESequence;
00437     KFbxSdkManager*             mSdkManager;
00438 };
00439 
00440 #if 0
00441 
00446 class KFBX_DLL KFbxUserNotificationFILE : public KFbxUserNotification
00447 {
00448 public:
00449 
00450     KFbxUserNotificationFILE(KString pFileDevice, KString pLogFileName="", KString pSessionDescription="");
00451     virtual ~KFbxUserNotificationFILE();
00452 
00453     virtual void OpenExtraDevices();
00454     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AccumulatorEntry*>& pEntries);
00455     virtual bool SendToExtraDevices(bool pOutputNow, KArrayTemplate<AESequence*>& pAESequence);
00456     virtual bool SendToExtraDevices(bool pOutputNow, const AccumulatorEntry* pAccEntry, int pDetailId = -1);
00457     virtual void CloseExtraDevices();
00458 
00459 private:
00460     KString mFileDevice;
00461     FILE* mFP;
00462     int   mUseStream;
00463 };
00464 #endif
00465 
00469 class KFBX_DLL KFbxUserNotificationFilteredIterator
00470 {
00471 public:
00484     KFbxUserNotificationFilteredIterator(KFbxUserNotification& pAccumulator, 
00485             int pFilterClass,
00486             KFbxUserNotification::OutputSource pSrc = KFbxUserNotification::eSEQUENCED_DETAILS,
00487             bool pNoDetail = true);
00488 
00489     virtual ~KFbxUserNotificationFilteredIterator();
00490 
00492     int  GetNbItems() const;
00493 
00495     void Reset();
00496 
00500     AccumulatorEntry* const First();
00501 
00509     AccumulatorEntry* const Previous();
00510 
00518     AccumulatorEntry* const Next();
00519 
00520 protected:
00521     // Called in the constructor.
00522     virtual void BuildFilteredList(KFbxUserNotification& pAccumulator);
00523 
00524     int                                 mIterator;
00525     int                                 mFilterClass;
00526     bool                                mNoDetail;
00527     KFbxUserNotification::OutputSource  mAccuSrcData;
00528     KArrayTemplate<AccumulatorEntry*>   mFilteredAE;
00529 };
00530 
00531 
00532 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00533 
00534 #endif // FBXFILESDK_KFBXPLUGINS_KFBXUSERNOTIFICATION_H
00535