1  
//
1  
//
2  
// Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com)
2  
// Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com)
3  
//
3  
//
4  
// Distributed under the Boost Software License, Version 1.0. (See accompanying
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)
5  
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6  
//
6  
//
7  
// Official repository: https://github.com/cppalliance/http
7  
// Official repository: https://github.com/cppalliance/http
8  
//
8  
//
9  

9  

10  
#ifndef BOOST_HTTP_DATASTORE_HPP
10  
#ifndef BOOST_HTTP_DATASTORE_HPP
11  
#define BOOST_HTTP_DATASTORE_HPP
11  
#define BOOST_HTTP_DATASTORE_HPP
12  

12  

13  
#include <boost/http/detail/config.hpp>
13  
#include <boost/http/detail/config.hpp>
14  
#include <boost/http/core/polystore.hpp>
14  
#include <boost/http/core/polystore.hpp>
15  

15  

16  
namespace boost {
16  
namespace boost {
17  
namespace http {
17  
namespace http {
18  

18  

19  
/** A polymorphic data container with clear functionality.
19  
/** A polymorphic data container with clear functionality.
20  

20  

21  
    This class extends @ref polystore to provide a container
21  
    This class extends @ref polystore to provide a container
22  
    for type-erased objects with an explicit clear operation.
22  
    for type-erased objects with an explicit clear operation.
23  
    It is commonly used as a service container.
23  
    It is commonly used as a service container.
24  

24  

25  
    @code
25  
    @code
26  
    // Example: Using datastore with services
26  
    // Example: Using datastore with services
27  
    boost::http::datastore ctx;
27  
    boost::http::datastore ctx;
28  

28  

29  
    // Install services...
29  
    // Install services...
30  

30  

31  
    // Clean up all services when done
31  
    // Clean up all services when done
32  
    ctx.clear();
32  
    ctx.clear();
33  
    @endcode
33  
    @endcode
34  
*/
34  
*/
35  
class datastore : public polystore
35  
class datastore : public polystore
36  
{
36  
{
37  
public:
37  
public:
38  
    /** Constructor
38  
    /** Constructor
39  

39  

40  
        Constructs an empty datastore.
40  
        Constructs an empty datastore.
41  
    */
41  
    */
42  
    datastore() = default;
42  
    datastore() = default;
43  

43  

44  
    /** Remove and destroy all stored objects.
44  
    /** Remove and destroy all stored objects.
45  

45  

46  
        All stored objects are destroyed in the reverse order
46  
        All stored objects are destroyed in the reverse order
47  
        of construction. The container is left empty.
47  
        of construction. The container is left empty.
48  
    */
48  
    */
49  
    void clear() noexcept
49  
    void clear() noexcept
50  
    {
50  
    {
51  
        polystore::clear();
51  
        polystore::clear();
52  
    }
52  
    }
53  
};
53  
};
54  

54  

55  
} // http
55  
} // http
56  
} // boost
56  
} // boost
57  

57  

58  
#endif
58  
#endif