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