ORE Studio 0.0.4
Loading...
Searching...
No Matches
country_service.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_REFDATA_SERVICE_COUNTRY_SERVICE_HPP
21#define ORES_REFDATA_SERVICE_COUNTRY_SERVICE_HPP
22
23#include <string>
24#include <vector>
25#include <optional>
26#include "ores.database/domain/context.hpp"
27#include "ores.refdata/domain/country.hpp"
28#include "ores.refdata/repository/country_repository.hpp"
29#include "ores.logging/make_logger.hpp"
30
31namespace ores::refdata::service {
32
40private:
41 inline static std::string_view logger_name =
42 "ores.refdata.service.country_service";
43
44 [[nodiscard]] static auto& lg() {
45 using namespace ores::logging;
46 static auto instance = make_logger(logger_name);
47 return instance;
48 }
49
50public:
52
58 explicit country_service(context ctx);
59
67 std::vector<domain::country> list_countries(std::uint32_t offset,
68 std::uint32_t limit);
69
75 std::uint32_t count_countries();
76
83 void save_country(const domain::country& country);
84
91 void delete_country(const std::string& alpha2_code);
92
99 std::optional<domain::country> get_country(const std::string& alpha2_code);
100
107 std::vector<domain::country> get_country_history(const std::string& alpha2_code);
108
109private:
110 context ctx_;
112};
113
114}
115
116#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Context for the operations on a postgres database.
Definition context.hpp:30
Represents a country using ISO 3166-1 standard codes.
Definition country.hpp:33
Reads and writes countries off of data storage.
Definition country_repository.hpp:35
Service for managing countries.
Definition country_service.hpp:39
std::vector< domain::country > get_country_history(const std::string &alpha2_code)
Retrieves all historical versions of a country.
Definition country_service.cpp:66
std::optional< domain::country > get_country(const std::string &alpha2_code)
Retrieves a single country by its alpha-2 code.
Definition country_service.cpp:56
void delete_country(const std::string &alpha2_code)
Deletes a country by its alpha-2 code.
Definition country_service.cpp:51
std::vector< domain::country > list_countries(std::uint32_t offset, std::uint32_t limit)
Lists countries with pagination support.
Definition country_service.cpp:31
void save_country(const domain::country &country)
Saves a country (creates or updates).
Definition country_service.cpp:43
std::uint32_t count_countries()
Gets the total count of active countries.
Definition country_service.cpp:38