Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages | Examples

file_stats.h

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

Generated on Tue May 17 12:07:44 2005 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.1