ORE Studio 0.0.4
Loading...
Searching...
No Matches
application.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_CLI_APP_APPLICATION_HPP
21#define ORES_CLI_APP_APPLICATION_HPP
22
23#include <vector>
24#include <ostream>
25#include <optional>
26#include <filesystem>
27#include "ores.logging/make_logger.hpp"
28#include "ores.database/domain/context.hpp"
29#include "ores.database/domain/database_options.hpp"
30#include "ores.cli/config/options.hpp"
31#include "ores.cli/config/import_options.hpp"
32#include "ores.cli/config/export_options.hpp"
33#include "ores.cli/config/delete_options.hpp"
34#include "ores.cli/config/add_options.hpp"
35#include "ores.cli/config/add_currency_options.hpp"
36#include "ores.cli/config/add_account_options.hpp"
37#include "ores.cli/config/add_system_setting_options.hpp"
38#include "ores.cli/config/add_login_info_options.hpp"
39#include "ores.cli/config/add_role_options.hpp"
40#include "ores.cli/config/add_permission_options.hpp"
41#include "ores.cli/config/add_country_options.hpp"
42#include "ores.cli/config/add_change_reason_options.hpp"
43#include "ores.cli/config/add_change_reason_category_options.hpp"
44#include "ores.cli/config/add_compute_app_options.hpp"
45#include "ores.cli/config/add_compute_app_version_options.hpp"
46#include "ores.cli/config/add_compute_batch_options.hpp"
47#include "ores.cli/config/add_compute_workunit_options.hpp"
48#include "ores.cli/config/add_day_count_fraction_type_options.hpp"
49#include "ores.cli/config/add_business_day_convention_type_options.hpp"
50#include "ores.cli/config/add_floating_index_type_options.hpp"
51#include "ores.cli/config/add_payment_frequency_type_options.hpp"
52#include "ores.cli/config/add_leg_type_options.hpp"
53
54namespace ores::cli::app {
55
59class application final {
60private:
61 inline static std::string_view logger_name =
62 "ores.cli.application";
63
64 [[nodiscard]] static auto& lg() {
65 using namespace ores::logging;
66 static auto instance = make_logger(logger_name);
67 return instance;
68 }
69
70public:
71 explicit application(std::ostream& output_stream,
72 const std::optional<database::database_options>& db_opts);
73 application(const application&) = delete;
74 application& operator=(const application&) = delete;
75
76private:
78 make_context(const std::optional<database::database_options>& db_opts);
79
88 void set_tenant_context(const std::string& tenant);
89 void import_currencies(const std::vector<std::filesystem::path> files) const;
90 void import_data(const std::optional<config::import_options>& ocfg) const;
91
92 void export_currencies(const config::export_options& cfg) const;
93 void export_accounts(const config::export_options& cfg) const;
94 void export_system_settings(const config::export_options& cfg) const;
95 void export_login_info(const config::export_options& cfg) const;
96 void export_roles(const config::export_options& cfg) const;
97 void export_permissions(const config::export_options& cfg) const;
98 void export_countries(const config::export_options& cfg) const;
99 void export_change_reasons(const config::export_options& cfg) const;
100 void export_change_reason_categories(const config::export_options& cfg) const;
101 void export_compute_hosts(const config::export_options& cfg) const;
102 void export_compute_apps(const config::export_options& cfg) const;
103 void export_compute_app_versions(const config::export_options& cfg) const;
104 void export_compute_batches(const config::export_options& cfg) const;
105 void export_compute_workunits(const config::export_options& cfg) const;
106 void export_compute_results(const config::export_options& cfg) const;
107 void export_data(const std::optional<config::export_options>& ocfg) const;
108
109 void delete_currency(const config::delete_options& cfg) const;
110 void delete_account(const config::delete_options& cfg) const;
111 void delete_system_setting(const config::delete_options& cfg) const;
112 void delete_login_info(const config::delete_options& cfg) const;
113 void delete_role(const config::delete_options& cfg) const;
114 void delete_permission(const config::delete_options& cfg) const;
115 void delete_country(const config::delete_options& cfg) const;
116 void delete_change_reason(const config::delete_options& cfg) const;
117 void delete_change_reason_category(const config::delete_options& cfg) const;
118 void delete_data(const std::optional<config::delete_options>& ocfg) const;
119
120 void add_currency(const config::add_currency_options& cfg) const;
121 void add_account(const config::add_account_options& cfg) const;
122 void add_system_setting(const config::add_system_setting_options& cfg) const;
123 void add_login_info(const config::add_login_info_options& cfg) const;
124 void add_role(const config::add_role_options& cfg) const;
125 void add_permission(const config::add_permission_options& cfg) const;
126 void add_country(const config::add_country_options& cfg) const;
127 void add_change_reason(const config::add_change_reason_options& cfg) const;
128 void add_change_reason_category(const config::add_change_reason_category_options& cfg) const;
129 void add_compute_host(const config::add_compute_host_options& cfg) const;
130 void add_compute_app(const config::add_compute_app_options& cfg) const;
131 void add_compute_app_version(const config::add_compute_app_version_options& cfg) const;
132 void add_compute_batch(const config::add_compute_batch_options& cfg) const;
133 void add_compute_workunit(const config::add_compute_workunit_options& cfg) const;
134 void add_data(const std::optional<config::add_options>& ocfg) const;
135
136 void export_day_count_fraction_types(const config::export_options& cfg) const;
137 void export_business_day_convention_types(const config::export_options& cfg) const;
138 void export_floating_index_types(const config::export_options& cfg) const;
139 void export_payment_frequency_types(const config::export_options& cfg) const;
140 void export_leg_types(const config::export_options& cfg) const;
141
142 void delete_day_count_fraction_type(const config::delete_options& cfg) const;
143 void delete_business_day_convention_type(const config::delete_options& cfg) const;
144 void delete_floating_index_type(const config::delete_options& cfg) const;
145 void delete_payment_frequency_type(const config::delete_options& cfg) const;
146 void delete_leg_type(const config::delete_options& cfg) const;
147
148 void add_day_count_fraction_type(const config::add_day_count_fraction_type_options& cfg) const;
149 void add_business_day_convention_type(const config::add_business_day_convention_type_options& cfg) const;
150 void add_floating_index_type(const config::add_floating_index_type_options& cfg) const;
151 void add_payment_frequency_type(const config::add_payment_frequency_type_options& cfg) const;
152 void add_leg_type(const config::add_leg_type_options& cfg) const;
153
154public:
160 void run(const config::options& cfg) const;
161
162private:
163 database::context context_;
164 std::ostream& output_stream_;
165};
166
167}
168
169#endif
Application hosting infrastructure for the CLI tool.
Definition application.hpp:54
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Entry point for the ores command line application.
Definition application.hpp:59
void run(const config::options &cfg) const
Executes the application.
Definition application.cpp:934
Configuration for adding an account entity via command-line arguments.
Definition add_account_options.hpp:32
Configuration for adding a business day convention type via command-line arguments.
Definition add_business_day_convention_type_options.hpp:32
Configuration for adding a change reason category entity via command-line arguments.
Definition add_change_reason_category_options.hpp:32
Configuration for adding a change reason entity via command-line arguments.
Definition add_change_reason_options.hpp:32
Configuration for adding a compute app entity via command-line arguments.
Definition add_compute_app_options.hpp:32
Configuration for adding a compute app_version entity via command-line arguments.
Definition add_compute_app_version_options.hpp:33
Configuration for adding a compute batch entity via command-line arguments.
Definition add_compute_batch_options.hpp:32
Configuration for adding a compute host via command-line arguments.
Definition add_compute_host_options.hpp:32
Configuration for adding a compute workunit via command-line arguments.
Definition add_compute_workunit_options.hpp:32
Configuration for adding a country entity via command-line arguments.
Definition add_country_options.hpp:32
Configuration for adding a currency entity via command-line arguments.
Definition add_currency_options.hpp:32
Configuration for adding a day count fraction type via command-line arguments.
Definition add_day_count_fraction_type_options.hpp:32
Configuration for adding a floating index type via command-line arguments.
Definition add_floating_index_type_options.hpp:32
Configuration for adding a leg type via command-line arguments.
Definition add_leg_type_options.hpp:32
Configuration for adding a login_info entity via command-line arguments.
Definition add_login_info_options.hpp:32
Configuration for adding a payment frequency type via command-line arguments.
Definition add_payment_frequency_type_options.hpp:32
Configuration for adding a permission entity via command-line arguments.
Definition add_permission_options.hpp:32
Configuration for adding a role entity via command-line arguments.
Definition add_role_options.hpp:33
Configuration for adding a system setting entity via command-line arguments.
Definition add_system_setting_options.hpp:32
Configuration related to deleting entities.
Definition delete_options.hpp:32
Configuration related to exporting data into a supported export format.
Definition export_options.hpp:34
All of the configuration options required by the command line application.
Definition options.hpp:39
Context for the operations on a postgres database.
Definition context.hpp:47