windowStatistics.cpp

00001 
00002 /* Copyright (c) 2008-2009, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License version 2.1 as published
00006  * by the Free Software Foundation.
00007  *  
00008  * This library is distributed in the hope that it will be useful, but WITHOUT
00009  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00011  * details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this library; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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 ) // does not belong to a frame
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 }
Generated on Mon Aug 10 18:58:41 2009 for Equalizer 0.9 by  doxygen 1.5.8