File: DownloadPolicy.h

package info (click to toggle)
marble 4%3A17.08.3-3.2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 141,596 kB
  • sloc: cpp: 189,322; xml: 39,420; ansic: 7,204; python: 2,244; sh: 1,137; makefile: 236; perl: 222; ruby: 97; java: 66
file content (80 lines) | stat: -rw-r--r-- 2,278 bytes parent folder | download | duplicates (4)
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
// Copyright 2009  Jens-Michael Hoffmann <jmho@c-xx.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either 
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public 
// License along with this library.  If not, see <http://www.gnu.org/licenses/>.

#ifndef MARBLE_DOWNLOADPOLICY_H
#define MARBLE_DOWNLOADPOLICY_H

#include <QString>
#include <QStringList>

#include "MarbleGlobal.h"

namespace Marble
{

class DownloadPolicyKey
{
    friend bool operator==( DownloadPolicyKey const & lhs, DownloadPolicyKey const & rhs );

 public:
    DownloadPolicyKey();
    DownloadPolicyKey( const QStringList & hostNames, const DownloadUsage usage );
    DownloadPolicyKey( const QString & hostName, const DownloadUsage usage );

    QStringList hostNames() const;
    void setHostNames( const QStringList & hostNames );

    DownloadUsage usage() const;
    void setUsage( DownloadUsage const usage );

    bool matches( const QString & hostName, const DownloadUsage usage ) const;

 private:
    QStringList m_hostNames;
    DownloadUsage m_usage;
};

inline bool operator==( const DownloadPolicyKey & lhs, const DownloadPolicyKey & rhs )
{
    return lhs.m_hostNames == rhs.m_hostNames && lhs.m_usage == rhs.m_usage;
}


class DownloadPolicy
{
    friend bool operator==( const DownloadPolicy & lhs, const DownloadPolicy & rhs );

 public:
    DownloadPolicy();
    explicit DownloadPolicy( const DownloadPolicyKey & key );

    int maximumConnections() const;
    void setMaximumConnections( const int );

    DownloadPolicyKey key() const;

 private:
    DownloadPolicyKey m_key;
    int m_maximumConnections;
};

inline bool operator==( const DownloadPolicy & lhs, const DownloadPolicy & rhs )
{
    return lhs.m_key == rhs.m_key && lhs.m_maximumConnections == rhs.m_maximumConnections;
}

}

#endif