pipeStatistics.cpp

00001 
00002 /* Copyright (c) 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 "pipeStatistics.h"
00019 
00020 #include "config.h"
00021 #include "pipe.h"
00022 #include "global.h"
00023 
00024 #ifdef WIN32_VC
00025 #  define snprintf _snprintf
00026 #endif
00027 
00028 namespace eq
00029 {
00030 
00031 PipeStatistics::PipeStatistics( const Statistic::Type type, Pipe* pipe )
00032         : StatisticSampler< Pipe >( type, pipe, pipe->getCurrentFrame( ))
00033 {
00034 #if 0
00035     const int32_t hint = pipe->getIAttribute( Pipe::IATTR_HINT_STATISTICS );
00036     if( hint == OFF )
00037         return;
00038 #endif
00039 
00040     const std::string& name = pipe->getName();
00041     if( name.empty( ))
00042         snprintf( event.data.statistic.resourceName, 32, "pipe %d",
00043                   pipe->getID( ));
00044     else
00045         snprintf( event.data.statistic.resourceName, 32, "%s", name.c_str( ));
00046 
00047     event.data.statistic.startTime  = pipe->getConfig()->getTime();
00048     event.data.statistic.endTime    = 0;
00049 }
00050 
00051 
00052 PipeStatistics::~PipeStatistics()
00053 {
00054 #if 0
00055     const int32_t hint = _owner->getIAttribute( Pipe::IATTR_HINT_STATISTICS);
00056     if( hint == OFF )
00057         return;
00058 #endif
00059 
00060     if( event.data.statistic.frameNumber == 0 ) // does not belong to a frame
00061         return;
00062 
00063     Config* config = _owner->getConfig();
00064     if( event.data.statistic.endTime == 0 )
00065         event.data.statistic.endTime = config->getTime();
00066     config->sendEvent( event );
00067 }
00068 
00069 }
Generated on Mon Aug 10 18:58:40 2009 for Equalizer 0.9 by  doxygen 1.5.8