~aleteoryx/muditaos

ref: f4bcc5ce6f0d66f6ee55949f9978ad0c0399fddb muditaos/module-db/queries/phonebook/QueryContactGet.hpp -rw-r--r-- 4.6 KiB
f4bcc5ce — Dawid Wojtas [BH-1758] Fix information about next alarm ring 2 years ago
                                                                                
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <queries/RecordQuery.hpp>
#include <queries/Filter.hpp>
#include <Interface/ContactRecord.hpp>
#include <module-apps/application-phonebook/data/ContactsMap.hpp>

#include <string>

namespace db::query
{
    /**
     * @brief ContactRecord read query, filtered by text.
     *
     */
    class ContactGet : public RecordQuery, public TextFilter, public ContactGroupFilter, public ContactDisplayMode
    {
      public:
        /**
         * @brief Default constructor with an empty filtering string
         *
         * @param filter text filter
         */
        ContactGet(const std::string &filter        = "",
                   const std::uint32_t &groupFilter = 0,
                   const std::uint32_t &displayMode = 0);

        /**
         * @brief Construct read query with limit, offset and filter values
         *
         * @param limit maximum number of records to read
         * @param offset read start offset
         * @param filter text to filter records
         */
        ContactGet(std::size_t limit,
                   std::size_t offset,
                   const std::string &filter = "",
                   std::uint32_t groupFilter = 0,
                   std::uint32_t displayMode = 0);

        /**
         * @brief debug info
         *
         * @return class name
         */
        [[nodiscard]] auto debugInfo() const -> std::string override;
    };

    /**
     * @brief A response to the db::query::ContactGet query. Returns a vector of
     * ContactRecord data
     *
     */
    class ContactGetResult : public RecordQueryResult<ContactRecord>
    {
      public:
        /**
         * @brief Construct reply with a vector of results
         *
         * @param records records to be sent
         */
        ContactGetResult(const std::vector<ContactRecord> &records);

        /**
         * @brief debug info
         *
         * @return class name
         */
        [[nodiscard]] auto debugInfo() const -> std::string override;
    };

    class ContactGetResultWithTotalCount : public ContactGetResult
    {
      public:
        ContactGetResultWithTotalCount(const std::vector<ContactRecord> &records, std::size_t allLength);
        [[nodiscard]] auto debugInfo() const -> std::string override;
        auto getAllLength() const -> std::size_t;

      private:
        std::size_t allLength;
    };

    /**
     * @brief A query to get a number of contacts filtered with a text
     *
     */
    class ContactGetSize : public RecordsSizeQuery,
                           public TextFilter,
                           public ContactGroupFilter,
                           public ContactDisplayMode
    {
      public:
        /**
         * @brief Construct query with a filter value
         *
         * @param filter text to filter contacts with
         */
        ContactGetSize(const std::string &filter        = "",
                       const std::uint32_t &groupFilter = 0,
                       const std::uint32_t &displayMode = 0);

        /**
         * @brief debug info
         *
         * @return class name
         */
        [[nodiscard]] auto debugInfo() const -> std::string override;
    };

    class ContactGetWithTotalCount : public ContactGet
    {
      public:
        ContactGetWithTotalCount(std::size_t limit,
                                 std::size_t offset,
                                 const std::string &filter = "",
                                 std::uint32_t groupFilter = 0,
                                 std::uint32_t displayMode = 0);
        [[nodiscard]] auto debugInfo() const -> std::string override;
    };

    class ContactGetLetterMap : public RecordQuery,
                                public TextFilter,
                                public ContactGroupFilter,
                                public ContactDisplayMode
    {
      public:
        ContactGetLetterMap(const std::string &filter        = "",
                            const std::uint32_t &groupFilter = 0,
                            const std::uint32_t &displayMode = 0);

        ContactGetLetterMap(std::size_t limit,
                            std::size_t offset,
                            const std::string &filter        = "",
                            const std::uint32_t &groupFilter = 0,
                            const std::uint32_t &displayMode = 0);
    };

    class ContactGetLetterMapResult : public LetterMapResult
    {
      public:
        ContactGetLetterMapResult(ContactsMapData &LetterMap);
    };

}; // namespace db::query