windowStatistics.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "windowStatistics.h"
00019
00020 #include "config.h"
00021 #include "global.h"
00022 #include "pipe.h"
00023 #include "window.h"
00024
00025 #ifdef WIN32_VC
00026 # define snprintf _snprintf
00027 #endif
00028
00029 namespace eq
00030 {
00031
00032 WindowStatistics::WindowStatistics( const Statistic::Type type,
00033 Window* window )
00034 : StatisticSampler< Window >( type, window,
00035 window->getPipe()->getCurrentFrame( ))
00036 {
00037 const int32_t hint = _owner->getIAttribute( Window::IATTR_HINT_STATISTICS );
00038 if( hint == OFF )
00039 return;
00040
00041 const std::string& name = window->getName();
00042 if( name.empty( ))
00043 snprintf( event.data.statistic.resourceName, 32, "window %d",
00044 window->getID( ));
00045 else
00046 snprintf( event.data.statistic.resourceName, 32, "%s", name.c_str());
00047
00048 if( hint == NICEST )
00049 window->finish();
00050
00051 event.data.statistic.startTime = window->getConfig()->getTime();
00052 }
00053
00054
00055 WindowStatistics::~WindowStatistics()
00056 {
00057 const int32_t hint = _owner->getIAttribute( Window::IATTR_HINT_STATISTICS );
00058 if( hint == OFF )
00059 return;
00060
00061 if( event.data.statistic.frameNumber == 0 )
00062 return;
00063
00064 if( hint == NICEST )
00065 _owner->finish();
00066
00067 event.data.statistic.endTime = _owner->getConfig()->getTime();
00068 _owner->processEvent( event.data );
00069 }
00070
00071 }