file_stats.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 1996-2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00008 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00009 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00010 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00011 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00012 //
00013 //  Use, duplication, or disclosure by the U.S. Government is subject to
00014 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00015 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00016 //  Data and Computer Software), as applicable.
00017 //
00018 
00019 #if !defined FILE_STATS_HEADER
00020 #define FILE_STATS_HEADER
00021 
00025 
00026 #include "whiptk/whipcore.h"
00027 
00032 
00033 class WHIPTK_API WT_File_Stats
00034 {
00035 private:
00036 
00037     long            m_last_opcode_start_position;
00038     int             m_last_opcode_index;
00039     WT_File const * m_main_file;
00040     long            m_opcode_count[WD_MAX_OPCODE_ID + 1];
00041     long            m_opcode_total_bytes[WD_MAX_OPCODE_ID + 1];
00042 
00043 public:
00044     WT_File_Stats (WT_File_Stats const &)
00045       : m_last_opcode_start_position()
00046       , m_last_opcode_index()
00047       , m_main_file()
00048     {
00049         WD_Complain ("cannot copy WT_File_Stats");
00050     } // prohibited
00051 
00052     WT_File_Stats & operator= (WT_File_Stats const &)
00053     {
00054         WD_Complain ("cannot assign WT_File_Stats");
00055         return *this;
00056     } // prohibited
00057 
00058     inline void add_stat(long opcode_index)
00059     {
00060         // Finish off tabulating the previous opcode we were dealing with:
00061         // Find out how many butes the last opcode + operand accounted for and add it in...
00062         m_opcode_total_bytes[m_last_opcode_index] += m_main_file->this_opcode_start_position() - m_last_opcode_start_position;
00063 
00064         // Store away info for future use in computing this opcode's length:
00065         m_last_opcode_start_position = m_main_file->this_opcode_start_position();
00066         m_last_opcode_index = opcode_index;
00067 
00068         // Now record the basics for this opcode:
00069         WD_Assert(opcode_index <= WD_MAX_OPCODE_ID);
00070         m_opcode_count[opcode_index]++;
00071     }
00072 
00074     WT_File_Stats(WT_File const * file);
00075 
00077     virtual ~WT_File_Stats()
00078     { }
00079 
00081 
00084     const long opcode_count(int opcode_index) const  { return  m_opcode_count[opcode_index]; }
00085 
00087 
00090     const long opcode_total_bytes(int opcode_index) const  { return  m_opcode_total_bytes[opcode_index]; }
00091 
00093 
00097     char const * descriptions(int index=-1) const;
00098 
00099 };
00100 
00102 
00103 #endif // FILE_STATS_HEADER

Generated on Tue Jan 6 22:41:12 2009 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.5