|
- #pragma once
-
- #include <cpphibernate/config.h>
- #include <cpphibernate/misc/type_helper.h>
- #include <cpphibernate/misc/equality_compare.h>
-
- namespace cpphibernate {
- namespace schema {
-
- namespace __impl
- {
-
- /**
- * @brief Tag class to mark table objects.
- */
- struct tag_table
- { };
-
- /**
- * @brief Represents a data field in the schema.
- *
- * @tparam T_name Name of the table.
- * @tparam T_wrapped_dataset Dataset type the table represents.
- * @tparam T_table_id Unique ID assigned by the user.
- * @tparam T_fields List of field that belongs to the table.
- */
- template<
- typename T_name,
- typename T_wrapped_dataset,
- typename T_table_id,
- typename T_fields>
- struct table_t
- : public tag_table
- , public tag_equality_comparable<tag_table>
- {
- using name_type = T_name;
- using wrapped_dataset_type = mp::decay_t<T_wrapped_dataset>;
- using dataset_type = decay_unwrap_t<wrapped_dataset_type>;
- using table_id_type = T_table_id;
- using fields_type = T_fields;
- using this_type = table_t<name_type, wrapped_dataset_type, table_id_type, fields_type>;
-
- name_type name; //!< Name of the table.
- wrapped_dataset_type wrapped_dataset; //!< Dataset type this table represents.
- table_id_type table_id; //!< Unique ID of the table, assigned by the user.
- fields_type fields; //!< List of fields that belongs to the table.
-
- /**
- * @brief Constructor.
- *
- * @param[in] p_name Name of the table.
- * @param[in] p_wrapped_dataset Dataset type this table represents.
- * @param[in] p_table_id Unique ID of the table assigned by the user.
- * @param[in] p_fields List of fields that belongs to the table.
- */
- constexpr table_t(
- name_type p_name,
- wrapped_dataset_type p_wrapped_dataset,
- table_id_type p_table_id,
- fields_type p_fields);
-
- /**
- * @brief Move constructor.
- */
- constexpr table_t(table_t&&) = default;
-
- /**
- * @brief Copy constructor.
- */
- constexpr table_t(const table_t&) = delete;
-
- /**
- * @brief Move assignment constructor.
- */
- constexpr table_t& operator = (table_t&&) = default;
-
- /**
- * @brief Copy assignment constructor.
- */
- constexpr table_t& operator = (const table_t&) = delete;
-
- /**
- * @brief Print the table to the passed stream.
- */
- inline void print(std::ostream& os) const;
- };
-
- /**
- * @brief Helper type to build table objects.
- */
- template<typename X, typename = void>
- struct table_builder;
-
- /**
- * @brief Helper type to get the wrapped dataset of the passed table.
- */
- template<typename X, typename = void>
- struct table_get_wrapped_dataset;
-
- }
-
- /**
- * @brief Evaluates to true_t if the passed type is a table type.
- */
- template<typename T>
- struct is_table;
-
- /**
- * @brief Is true if the passed type is an attributes type, false otherwise.
- */
- template<typename T>
- constexpr bool is_table_v = is_table<T>::value;
-
- /**
- * @brief Predicate to create an table object from the passed attributes.
- */
- constexpr decltype(auto) make_table = mp::generic_predicate<__impl::table_builder> { };
-
- /**
- * @brief Predicate to get the wrapped dataset of the passed table.
- */
- constexpr decltype(auto) get_wrapped_dataset = mp::generic_predicate<__impl::table_get_wrapped_dataset> { };
-
- } }
-
- #include "table.inl"
|