comparison foosdk/sdk/foobar2000/SDK/config_io_callback.h @ 1:20d02a178406 default tip

*: check in everything else yay
author Paper <paper@tflc.us>
date Mon, 05 Jan 2026 02:15:46 -0500
parents
children
comparison
equal deleted inserted replaced
0:e9bb126753e7 1:20d02a178406
1 #pragma once
2
3 //! Implementing this interface lets you maintain your own configuration files rather than depending on the cfg_var system. \n
4 //! Note that you must not make assumptions about what happens first: config_io_callback::on_read(), initialization of cfg_var values or config_io_callback::on_read() in other components. Order of these things is undefined and will change with each run. \n
5 //! Use service_factory_single_t<myclass> to register your implementations. Do not call other people's implementations, core is responsible for doing that when appropriate.
6 class NOVTABLE config_io_callback : public service_base {
7 public:
8 //! Called on startup. You can read your configuration file from here. \n
9 //! Hint: use core_api::get_profile_path() to retrieve the path of the folder where foobar2000 configuration files are stored.
10 virtual void on_read() = 0;
11 //! Called typically on shutdown but you should expect a call at any point after on_read(). You can write your configuration file from here.
12 //! Hint: use core_api::get_profile_path() to retrieve the path of the folder where foobar2000 configuration files are stored.
13 //! @param reset If set to true, our configuration is being reset, so you should wipe your files rather than rewrite them with current configuration.
14 //! Since foobar2000 v2.0, reset is never issued - profile folder is cleared instead.
15 virtual void on_write(bool reset) = 0;
16
17 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(config_io_callback);
18 };
19
20 //! \since 1.0
21 class NOVTABLE config_io_callback_v2 : public config_io_callback {
22 FB2K_MAKE_SERVICE_INTERFACE(config_io_callback_v2, config_io_callback)
23 public:
24 //! Implement optionally. Called to quickly flush recent configuration changes. If your instance of config_io_callback needs to perform timeconsuming tasks when saving, you should skip implementing this method entirely.
25 virtual void on_quicksave() = 0;
26 };
27
28 //! \since 1.4
29 //! New methods take a filesystem object that should be used for the update, so the whole config update can be performed as one transacted filesystem operation. \n
30 //! The core performs necessary checks to ensure that the volume where our profile resides is supports transacted operations. \n
31 //! However there are odd cases of people junctioning the profile folder and such. We cannot guarantee that your code won't run into such cases. \n
32 //! If you get a exception_io_transactions_unsupported, let the caller deal with it - your call will be retried with a regular filesystem instead of a transacted one.
33 class NOVTABLE config_io_callback_v3 : public config_io_callback_v2 {
34 FB2K_MAKE_SERVICE_INTERFACE(config_io_callback_v3, config_io_callback_v2);
35 public:
36 void on_quicksave();
37 void on_write(bool bReset);
38 //! Since foobar2000 v2.0, reset is never issued - profile folder is cleared instead.
39 virtual void on_reset_v3( filesystem::ptr fs ) = 0;
40 virtual void on_write_v3( filesystem::ptr fs ) = 0;
41 virtual void on_quicksave_v3( filesystem::ptr fs ) = 0;
42 };
43
44 // For internal use in fb2k core
45 #define FB2K_PROFILE_CONFIG_READS_WRITES 0