You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

58 lines
1.9 KiB

  1. #pragma once
  2. namespace cpphibernate {
  3. namespace mariadb {
  4. /**
  5. * @brief Field that represents a foreign table.
  6. */
  7. template<typename T_field>
  8. struct field_foreign_table_t
  9. : public field_simple_t<T_field>
  10. {
  11. private:
  12. using base_type = field_simple_t<T_field>;
  13. public:
  14. /**
  15. * @brief Value constructor. Creates a mariadb field from the cpphibernate field.
  16. *
  17. * @param[in] p_owner Owner of the field.
  18. * @param[in] p_schema Cpphibernate schema the mariadb field belongs to.
  19. * @param[in] p_table Cpphibernate table the mariadb field belongs to.
  20. * @param[in] p_field Cpphibernate field to create mariadb field for.
  21. */
  22. template<
  23. typename T_schema,
  24. typename T_table>
  25. inline field_foreign_table_t(
  26. const table_t& p_owner,
  27. const T_schema& p_schema,
  28. const T_table& p_table,
  29. const T_field& p_field);
  30. public:
  31. /**
  32. * @brief Execute a create/update operation on the foreign table this field represents (if it is a foreign field)
  33. *
  34. * @param[in] context Create/Update context with the needed data for the operation.
  35. *
  36. * @return Key of the created/updated foreign dataset.
  37. */
  38. inline value_t foreign_create_update(const create_update_context& context) const override;
  39. /**
  40. * @brief Create a read context for the foreign key field.
  41. *
  42. * @param[in] context Read context to inherit new context from.
  43. * @param[in] create_fake Create a fake context (not data will be written).
  44. *
  45. * @return The created read context.
  46. */
  47. inline read_context_ptr_u foreign_read(const read_context& context, bool create_fake) const override;
  48. };
  49. } }