Line data Source code
1 :
2 : /* Copyright (c) 2009-2016, Stefan Eilemann <eile@equalizergraphics.com>
3 : * Daniel Nachbaur <danielnachbaur@gmail.com>
4 : *
5 : * This library is free software; you can redistribute it and/or modify it under
6 : * the terms of the GNU Lesser General Public License version 2.1 as published
7 : * by the Free Software Foundation.
8 : *
9 : * This library is distributed in the hope that it will be useful, but WITHOUT
10 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 : * details.
13 : *
14 : * You should have received a copy of the GNU Lesser General Public License
15 : * along with this library; if not, write to the Free Software Foundation, Inc.,
16 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 : */
18 :
19 : #include "pipeStatistics.h"
20 :
21 : #include "config.h"
22 : #include "global.h"
23 : #include "pipe.h"
24 :
25 : #include <cstdio>
26 :
27 : #ifdef _MSC_VER
28 : #define snprintf _snprintf
29 : #endif
30 :
31 : namespace eq
32 : {
33 0 : PipeStatistics::PipeStatistics(const Statistic::Type type, Pipe* pipe)
34 0 : : StatisticSampler<Pipe>(type, pipe)
35 : {
36 0 : const std::string& name = pipe->getName();
37 0 : if (name.empty())
38 0 : snprintf(statistic.resourceName, 32, "Pipe %s",
39 0 : pipe->getID().getShortString().c_str());
40 : else
41 0 : snprintf(statistic.resourceName, 32, "%s", name.c_str());
42 :
43 0 : statistic.resourceName[31] = 0;
44 0 : statistic.startTime = pipe->getConfig()->getTime();
45 0 : }
46 :
47 0 : PipeStatistics::~PipeStatistics()
48 : {
49 0 : if (statistic.frameNumber == 0) // does not belong to a frame
50 0 : return;
51 :
52 0 : Config* config = _owner->getConfig();
53 0 : if (statistic.endTime == 0)
54 0 : statistic.endTime = config->getTime();
55 0 : if (statistic.endTime <= statistic.startTime)
56 0 : statistic.endTime = statistic.startTime + 1;
57 :
58 0 : _owner->processEvent(statistic);
59 0 : }
60 30 : }
|