summaryrefslogtreecommitdiffstats
path: root/src/table_handler.hpp
blob: 68f5859cdb00b12ad1335733a10ac5e6e1195007 (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
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * 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 IXION_TABLE_HANDLER_HPP
#define IXION_TABLE_HANDLER_HPP

#include "ixion/interface/table_handler.hpp"
#include "ixion/types.hpp"
#include "ixion/address.hpp"

#include <vector>
#include <map>
#include <memory>

namespace ixion {

class table_handler : public iface::table_handler
{
public:

    /** single table entry */
    struct entry
    {
        string_id_t name;
        abs_range_t range;
        std::vector<string_id_t> columns;
        row_t totals_row_count;

        entry();
    };

    typedef std::map<string_id_t, std::unique_ptr<entry>> entries_type;

    virtual ~table_handler();

    virtual abs_range_t get_range(
        const abs_address_t& pos, string_id_t column_first, string_id_t column_last, table_areas_t areas) const;
    virtual abs_range_t get_range(
        string_id_t table, string_id_t column_first, string_id_t column_last, table_areas_t areas) const;

    void insert(std::unique_ptr<entry>& p);

private:
    abs_range_t get_column_range(
        const entry& e, string_id_t column_first, string_id_t column_last,
        table_areas_t areas) const;

    entries_type m_entries;
};

}

#endif

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