Line data Source code
1 : //
2 : // Copyright (c) 2025 Vinnie Falco (vinnie dot falco at gmail dot com)
3 : //
4 : // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 : //
7 : // Official repository: https://github.com/cppalliance/capy
8 : //
9 :
10 : #ifndef BOOST_CAPY_DATASTORE_HPP
11 : #define BOOST_CAPY_DATASTORE_HPP
12 :
13 : #include <boost/capy/detail/config.hpp>
14 : #include <boost/capy/polystore.hpp>
15 :
16 : namespace boost {
17 : namespace capy {
18 :
19 : /** A polymorphic data container with clear functionality.
20 :
21 : This class extends @ref polystore to provide a container
22 : for type-erased objects with an explicit clear operation.
23 : It is commonly used as a service container for compression
24 : and decompression services.
25 :
26 : @code
27 : // Example: Using datastore with compression services
28 : boost::capy::datastore ctx;
29 :
30 : // Install services
31 : auto& deflate_svc = boost::capy::zlib::install_deflate_service(ctx);
32 : auto& inflate_svc = boost::capy::zlib::install_inflate_service(ctx);
33 : auto& brotli_enc = boost::capy::brotli::install_encode_service(ctx);
34 :
35 : // Use services...
36 :
37 : // Clean up all services when done
38 : ctx.clear();
39 : @endcode
40 : */
41 : class datastore : public polystore
42 : {
43 : public:
44 : /** Constructor
45 :
46 : Constructs an empty datastore.
47 : */
48 1 : datastore() = default;
49 :
50 : /** Remove and destroy all stored objects.
51 :
52 : All stored objects are destroyed in the reverse order
53 : of construction. The container is left empty.
54 : */
55 1 : void clear() noexcept
56 : {
57 1 : polystore::clear();
58 1 : }
59 : };
60 :
61 : } // capy
62 : } // boost
63 :
64 : #endif
|