annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
1 #pragma once
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
2
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
3 //! Implementing this interface lets you maintain your own configuration files rather than depending on the cfg_var system. \n
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
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
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
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.
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
6 class NOVTABLE config_io_callback : public service_base {
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
7 public:
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
8 //! Called on startup. You can read your configuration file from here. \n
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
9 //! Hint: use core_api::get_profile_path() to retrieve the path of the folder where foobar2000 configuration files are stored.
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
10 virtual void on_read() = 0;
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
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.
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
12 //! Hint: use core_api::get_profile_path() to retrieve the path of the folder where foobar2000 configuration files are stored.
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
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.
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
14 //! Since foobar2000 v2.0, reset is never issued - profile folder is cleared instead.
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
15 virtual void on_write(bool reset) = 0;
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
16
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
17 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(config_io_callback);
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
18 };
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
19
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
20 //! \since 1.0
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
21 class NOVTABLE config_io_callback_v2 : public config_io_callback {
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
22 FB2K_MAKE_SERVICE_INTERFACE(config_io_callback_v2, config_io_callback)
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
23 public:
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
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.
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
25 virtual void on_quicksave() = 0;
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
26 };
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
27
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
28 //! \since 1.4
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
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
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
30 //! The core performs necessary checks to ensure that the volume where our profile resides is supports transacted operations. \n
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
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
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
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.
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
33 class NOVTABLE config_io_callback_v3 : public config_io_callback_v2 {
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
34 FB2K_MAKE_SERVICE_INTERFACE(config_io_callback_v3, config_io_callback_v2);
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
35 public:
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
36 void on_quicksave();
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
37 void on_write(bool bReset);
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
38 //! Since foobar2000 v2.0, reset is never issued - profile folder is cleared instead.
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
39 virtual void on_reset_v3( filesystem::ptr fs ) = 0;
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
40 virtual void on_write_v3( filesystem::ptr fs ) = 0;
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
41 virtual void on_quicksave_v3( filesystem::ptr fs ) = 0;
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
42 };
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
43
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
44 // For internal use in fb2k core
20d02a178406 *: check in everything else
Paper <paper@tflc.us>
parents:
diff changeset
45 #define FB2K_PROFILE_CONFIG_READS_WRITES 0