frameDataStatistics.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 "frameDataStatistics.h"
00019 
00020 #include "config.h"
00021 #include "global.h"
00022 #include "pipe.h"
00023 #include "frameData.h"
00024 
00025 #ifdef WIN32_VC
00026 #  define snprintf _snprintf
00027 #endif
00028 
00029 namespace eq
00030 {
00031 
00032 FrameDataStatistics::FrameDataStatistics( const Statistic::Type type, 
00033                                           FrameData* frameData, 
00034                                           const uint32_t frameNumber )
00035         : StatisticSampler< FrameData >( type, frameData, frameNumber )
00036 {
00037     snprintf( event.data.statistic.resourceName, 32, "frame %d",
00038               frameData->getID( ));
00039 
00040     const net::Session* session = frameData->getSession();
00041     EQASSERT( session );
00042     if( !session )
00043     {
00044         event.data.statistic.frameNumber = 0;
00045         return;
00046     }
00047 
00048     const Config* config = EQSAFECAST( const Config*, session );
00049     event.data.statistic.startTime = config->getTime();
00050 }
00051 
00052 
00053 FrameDataStatistics::~FrameDataStatistics()
00054 {
00055     if( event.data.statistic.frameNumber == 0 ) // does not belong to a frame
00056         return;
00057 
00058     net::Session* session = _owner->getSession();
00059     EQASSERT( session );
00060     if( !session )
00061         return;
00062 
00063     Config* config = EQSAFECAST( Config*, session );
00064     event.data.statistic.endTime = config->getTime();
00065     config->sendEvent( event );
00066 }
00067 
00068 }
Generated on Mon Aug 10 18:58:33 2009 for Equalizer 0.9 by  doxygen 1.5.8