|
- #pragma once
-
- #include <cpphibernate/config.h>
-
- namespace cpphibernate
- {
-
- /**
- * @brief Context class for cpphibernate.
- */
- template<typename T_driver, typename T_schema>
- struct context
- : public T_driver
- {
- public:
- using base_type = T_driver;
- using driver_type = T_driver;
- using schema_type = T_schema;
-
- private:
- const schema_type& _schema;
-
- public:
- /**
- * @brief Value constructor. Create a new context object.
- *
- * @param p_schema Database schema to use.
- * @param p_args Arguments to pass to underlying driver.
- */
- template<typename... T_args>
- constexpr context(const schema_type& p_schema, T_args&&... p_args);
-
- /**
- * @brief Nove constructor.
- */
- constexpr context(context&&) = default;
-
- /**
- * @brief Copy constrcutor.
- */
- constexpr context(const context&) = default;
-
- /**
- * @brief Initialize the database. This will create all non exsitsing tables.
- */
- template<typename... T_args>
- constexpr decltype(auto) init(T_args&&... args);
-
- /**
- * @brief Create the passed object in the database.
- */
- template<typename... T_args>
- constexpr decltype(auto) create(T_args&&... args);
-
- /**
- * @brief Read an object from the database.
- */
- template<typename... T_args>
- constexpr decltype(auto) read(T_args&&... args);
-
- /**
- * @brief Update the passed object in the database.
- */
- template<typename... T_args>
- constexpr decltype(auto) update(T_args&&... args);
-
- /**
- * @brief Destroy the passed object in the database.
- */
- template<typename... T_args>
- constexpr decltype(auto) destroy(T_args&&... args);
- };
-
- /**
- * @brief Create a new cpphibernate context.
- *
- * @tparam T_driver Hibernate driver to use.
- * @tparam T_schema Database schema to use.
- * @tparam T_args Arguments to pass to underlying driver implementation.
- *
- * @param schema Database schema to use.
- * @param args Arguments to pass to underlying driver implementation.
- *
- * @return Created hibernate context.
- */
- template<typename T_driver, typename T_schema, typename... T_args>
- constexpr decltype(auto) make_context(T_schema&& schema, T_args&&... args);
-
- /**
- * @brief Create a new cpphibernate context as a unique pointer.
- *
- * @tparam T_driver Hibernate driver to use.
- * @tparam T_schema Database schema to use.
- * @tparam T_args Arguments to pass to underlying driver implementation.
- *
- * @param schema Database schema to use.
- * @param args Arguments to pass to underlying driver implementation.
- *
- * @return Unique pointer of the created hibernate context.
- */
- template<typename T_driver, typename T_schema, typename... T_args>
- constexpr decltype(auto) make_context_ptr(T_schema&& schema, T_args&&... args);
-
- }
|