File: loader.cpp

package info (click to toggle)
kcachegrind 4%3A25.04.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,964 kB
  • sloc: cpp: 32,149; xml: 403; perl: 325; python: 235; sh: 8; makefile: 6
file content (111 lines) | stat: -rw-r--r-- 1,860 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
    This file is part of KCachegrind.

    SPDX-FileCopyrightText: 2002-2016 Josef Weidendorfer <Josef.Weidendorfer@gmx.de>

    SPDX-License-Identifier: GPL-2.0-only
*/

/*
 * Base class for loaders of profiling data.
 */

#include "loader.h"

#include "logger.h"

/// Loader

QList<Loader*> Loader::_loaderList;

Loader::Loader(const QString& name, const QString& desc)
{
    _name = name;
    _description = desc;

    _logger = nullptr;
}

Loader::~Loader()
{}

bool Loader::canLoad(QIODevice*)
{
    return false;
}

int Loader::load(TraceData*, QIODevice*, const QString&)
{
    return 0;
}

Loader* Loader::matchingLoader(QIODevice* file)
{
    foreach (Loader* l, _loaderList)
        if (l->canLoad(file))
            return l;

    return nullptr;
}

Loader* Loader::loader(const QString& name)
{
    foreach (Loader* l, _loaderList)
        if (l->name() == name)
            return l;

    return nullptr;
}

// factories of available loaders
Loader* createCachegrindLoader();

void Loader::initLoaders()
{
    _loaderList.append(createCachegrindLoader());
    //_loaderList.append(GProfLoader::createLoader());
}

void Loader::deleteLoaders()
{
    while (!_loaderList.isEmpty())
        delete _loaderList.takeFirst();
}

// notifications

void Loader::setLogger(Logger* l)
{
    _logger = l;
}

void Loader::loadStart(const QString& filename)
{
    if (_logger)
        _logger->loadStart(filename);
}

void Loader::loadProgress(int progress)
{
    if (_logger)
        _logger->loadProgress(progress);
}

void Loader::loadError(int line, const QString& msg)
{
    if (_logger)
        _logger->loadError(line, msg);
}

void Loader::loadWarning(int line, const QString& msg)
{
    if (_logger)
        _logger->loadWarning(line, msg);
}

void Loader::loadFinished(const QString& msg)
{
    if (_logger)
        _logger->loadFinished(msg);
}