channelStatistics.cpp

00001 
00002 /* Copyright (c) 2006-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 "channelStatistics.h"
00019 
00020 #include "channel.h"
00021 #include "config.h"
00022 #include "global.h"
00023 #include "pipe.h"
00024 #include "window.h"
00025 
00026 #ifdef WIN32_VC
00027 #  define snprintf _snprintf
00028 #endif
00029 
00030 namespace eq
00031 {
00032 
00033 ChannelStatistics::ChannelStatistics( const Statistic::Type type, 
00034                                       Channel* channel )
00035         : StatisticSampler< Channel >( type, channel, 
00036                                        channel->getPipe()->getCurrentFrame( ))
00037 {
00038     const int32_t hint = channel->getIAttribute(Channel::IATTR_HINT_STATISTICS);
00039     if( hint == OFF )
00040         return;
00041 
00042     event.data.statistic.task = channel->getTaskID();
00043 
00044     const std::string& name = channel->getName();
00045     if( name.empty( ))
00046         snprintf( event.data.statistic.resourceName, 32, "channel %d",
00047                   channel->getID( ));
00048     else
00049         snprintf( event.data.statistic.resourceName, 32, "%s", name.c_str( ));
00050 
00051     if( hint == NICEST )
00052         channel->getWindow()->finish();
00053 
00054     event.data.statistic.startTime  = channel->getConfig()->getTime();
00055 }
00056 
00057 
00058 ChannelStatistics::~ChannelStatistics()
00059 {
00060     const int32_t hint = _owner->getIAttribute( Channel::IATTR_HINT_STATISTICS);
00061     if( hint == OFF )
00062         return;
00063 
00064     if( hint == NICEST )
00065         _owner->getWindow()->finish();
00066 
00067     if( event.data.statistic.endTime == 0 )
00068         event.data.statistic.endTime = _owner->getConfig()->getTime();
00069 
00070     _owner->addStatistic( event.data );
00071 }
00072 
00073 }
Generated on Sat Feb 6 12:59:45 2010 for Equalizer 0.9.1 by  doxygen 1.6.1