ORE Studio 0.0.4
Loading...
Searching...
No Matches
book_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_BOOK_SERVICE_HPP
21#define ORES_REFDATA_CORE_SERVICE_BOOK_SERVICE_HPP
22
23#include <string>
24#include <vector>
25#include <optional>
26#include <boost/uuid/uuid.hpp>
27#include "ores.logging/make_logger.hpp"
28#include "ores.database/domain/context.hpp"
29#include "ores.refdata.api/domain/book.hpp"
30#include "ores.refdata.core/repository/book_repository.hpp"
31
32namespace ores::refdata::service {
33
41private:
42 inline static std::string_view logger_name =
43 "ores.refdata.service.book_service";
44
45 [[nodiscard]] static auto& lg() {
46 using namespace ores::logging;
47 static auto instance = make_logger(logger_name);
48 return instance;
49 }
50
51public:
53
59 explicit book_service(context ctx);
60
64 std::vector<domain::book> list_books();
65
69 std::optional<domain::book>
70 find_book(const boost::uuids::uuid& id);
71
75 std::optional<domain::book>
76 find_book_by_code(const std::string& code);
77
83 void save_book(const domain::book& book);
84
90 void save_books(const std::vector<domain::book>& books);
91
97 void remove_book(const boost::uuids::uuid& id);
98
105 std::vector<domain::book>
106 get_book_history(const boost::uuids::uuid& id);
107
108private:
109 context ctx_;
111};
112
113}
114
115#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Context for the operations on a postgres database.
Definition context.hpp:47
Operational ledger leaf that holds trades.
Definition book.hpp:37
Reads and writes books to data storage.
Definition book_repository.hpp:36
Service for managing books.
Definition book_service.hpp:40
std::optional< domain::book > find_book_by_code(const std::string &code)
Finds a book by its code.
Definition book_service.cpp:51
std::vector< domain::book > get_book_history(const boost::uuids::uuid &id)
Gets the version history for a book.
Definition book_service.cpp:90
std::vector< domain::book > list_books()
Lists all books.
Definition book_service.cpp:35
void save_books(const std::vector< domain::book > &books)
Saves multiple books (creates or updates).
Definition book_service.cpp:71
std::optional< domain::book > find_book(const boost::uuids::uuid &id)
Finds a book by its ID.
Definition book_service.cpp:41
void save_book(const domain::book &book)
Saves a book (creates or updates).
Definition book_service.cpp:60
void remove_book(const boost::uuids::uuid &id)
Removes a book.
Definition book_service.cpp:83