~aleteoryx/muditaos

ref: d86d3aed09ca50c40218abd5cb18bbc17a305f49 muditaos/module-db/Interface/AlarmsRecord.hpp -rw-r--r-- 1.6 KiB
d86d3aed — Pawel Paprocki [EGD-4182] Create UT for File Indexer DB (#1050) 5 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
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

/*
 * AlarmsRecord.hpp
 *
 *  Created on: 15 lip 2019
 *      Author: kuba
 */
#pragma once

#include "Record.hpp"
#include <stdint.h>
#include "../Databases/AlarmsDB.hpp"
#include "utf8/UTF8.hpp"
#include "../Common/Common.hpp"

struct AlarmsRecord
{
    uint32_t ID;
    uint32_t time;
    uint32_t snooze;
    uint32_t status;
    UTF8 path;
};

enum class AlarmsRecordField
{
    Time,
    Snooze,
    Status,
    Path
};

class AlarmsRecordInterface : public RecordInterface<AlarmsRecord, AlarmsRecordField>
{
  public:
    AlarmsRecordInterface(AlarmsDB *alarmsDb);
    ~AlarmsRecordInterface();

    bool Add(const AlarmsRecord &rec) override final;
    bool RemoveByID(uint32_t id) override final;
    bool RemoveByField(AlarmsRecordField field, const char *str) override final;
    bool Update(const AlarmsRecord &rec) override final;
    AlarmsRecord GetByID(uint32_t id) override final;

    uint32_t GetCount() override final;

    std::unique_ptr<std::vector<AlarmsRecord>> GetLimitOffset(uint32_t offset, uint32_t limit) override final;

    std::unique_ptr<std::vector<AlarmsRecord>> GetLimitOffsetByField(uint32_t offset,
                                                                     uint32_t limit,
                                                                     AlarmsRecordField field,
                                                                     const char *str) override final;

    AlarmsRecord GetNext(time_t time);

  private:
    AlarmsDB *alarmsDB;
};