summaryrefslogtreecommitdiff
path: root/sc/inc/datamapper.hxx
blob: 28476df8d8dd19d47d181d84160d957cc0b57ab5 (plain)
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
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#ifndef INCLUDED_SC_INC_EXTERNALDATAMAPPER_HXX
#define INCLUDED_SC_INC_EXTERNALDATAMAPPER_HXX

#include <memory>

#include <rtl/ustring.hxx>

class ScDocument;
class ScDBData;

namespace sc {

class ScDBDataManager;
class DataProvider;
class ScDBDataManager;

class ExternalDataSource
{
private:

    /**
     * The URL for the external data provider. The URL
     * will be passed to the data provider together with
     * the ID.
     *
     * A data provider may decide to ignore the URL string.
     */
    OUString maURL;

    /**
     * The data provider is a unique identifier that will
     * allow to identify and instantiate the required data
     * provider.
     *
     * Examples for the internal data providers are:
     *
     * org.libreoffice.dataprovider.calc.csv
     * org.libreoffice.dataprovider.calc.json
     *
     * Only internal data providers should use the:
     * "org.libreoffice.dataprovider prefix".
     */
    OUString maProvider;

    /**
     * The ID allows the same data provider to support different
     * data streams.
     *
     * A data provider may decide to ignore the ID string.
     */
    OUString maID;

    double mnUpdateFrequency;

    std::shared_ptr<DataProvider> mpDataProvider;
    std::shared_ptr<ScDBDataManager> mpDBDataManager;

public:

    ExternalDataSource(const OUString& rURL,
            const OUString& rProvider);

    void setUpdateFrequency(double nUpdateFrequency);

    void setID(const OUString& rID);

    const OUString& getURL() const;
    const OUString& getProvider() const;
    const OUString& getID() const;
    double getUpdateFrequency() const;
    OUString getDBName() const;
    void setDBData(ScDBData* pDBData);

    void refresh(ScDocument* pDoc);
};

class SC_DLLPUBLIC ExternalDataMapper
{
    //ScDocument* mpDoc;
    std::vector<ExternalDataSource> maDataSources;

public:
    ExternalDataMapper(ScDocument* pDoc);

    ~ExternalDataMapper();

    void insertDataSource(const ExternalDataSource& rSource);

    const std::vector<ExternalDataSource>& getDataSources() const;
    std::vector<ExternalDataSource>& getDataSources();
};

}

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */