ORE Studio 0.0.4
Loading...
Searching...
No Matches
counterparty_service.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2026 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_CORE_SERVICE_COUNTERPARTY_SERVICE_HPP
21#define ORES_REFDATA_CORE_SERVICE_COUNTERPARTY_SERVICE_HPP
22
23#include <string>
24#include <vector>
25#include <cstdint>
26#include <optional>
27#include <boost/uuid/uuid.hpp>
28#include "ores.logging/make_logger.hpp"
29#include "ores.database/domain/context.hpp"
30#include "ores.refdata.api/domain/counterparty.hpp"
31#include "ores.refdata.core/repository/counterparty_repository.hpp"
32
33namespace ores::refdata::service {
34
42private:
43 inline static std::string_view logger_name =
44 "ores.refdata.service.counterparty_service";
45
46 [[nodiscard]] static auto& lg() {
47 using namespace ores::logging;
48 static auto instance = make_logger(logger_name);
49 return instance;
50 }
51
52public:
54
60 explicit counterparty_service(context ctx);
61
65 std::vector<domain::counterparty> list_counterparties(
66 std::uint32_t offset = 0, std::uint32_t limit = 100);
67
71 std::uint32_t count_counterparties();
72
76 std::optional<domain::counterparty>
77 find_counterparty(const boost::uuids::uuid& id);
78
82 std::optional<domain::counterparty>
83 find_counterparty_by_code(const std::string& code);
84
90 void save_counterparty(const domain::counterparty& counterparty);
91
97 void save_counterparties(const std::vector<domain::counterparty>& counterparties);
98
104 void remove_counterparty(const boost::uuids::uuid& id);
105
112 std::vector<domain::counterparty>
113 get_counterparty_history(const boost::uuids::uuid& id);
114
115private:
116 context ctx_;
118};
119
120}
121
122#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Context for the operations on a postgres database.
Definition context.hpp:47
An external trading partner participating in financial transactions.
Definition counterparty.hpp:37
Reads and writes counterparties to data storage.
Definition counterparty_repository.hpp:37
Service for managing counterparties.
Definition counterparty_service.hpp:41
std::vector< domain::counterparty > get_counterparty_history(const boost::uuids::uuid &id)
Gets the version history for a counterparty.
Definition counterparty_service.cpp:98
std::uint32_t count_counterparties()
Returns total number of active counterparties.
Definition counterparty_service.cpp:42
void save_counterparty(const domain::counterparty &counterparty)
Saves a counterparty (creates or updates).
Definition counterparty_service.cpp:67
std::optional< domain::counterparty > find_counterparty_by_code(const std::string &code)
Finds a counterparty by its code.
Definition counterparty_service.cpp:58
void remove_counterparty(const boost::uuids::uuid &id)
Removes a counterparty.
Definition counterparty_service.cpp:91
std::vector< domain::counterparty > list_counterparties(std::uint32_t offset=0, std::uint32_t limit=100)
Lists counterparties with pagination.
Definition counterparty_service.cpp:35
void save_counterparties(const std::vector< domain::counterparty > &counterparties)
Saves multiple counterparties (creates or updates).
Definition counterparty_service.cpp:78
std::optional< domain::counterparty > find_counterparty(const boost::uuids::uuid &id)
Finds a counterparty by its ID.
Definition counterparty_service.cpp:48