mirror of
https://github.com/silverqx/TinyORM.git
synced 2026-02-11 04:49:15 -06:00
renamed relation tags, prepended Is
Renamed to IsOneRelation, IsManyRelation, IsPivotRelation.
This commit is contained in:
@@ -1112,7 +1112,7 @@ namespace Concerns
|
||||
relation->touch();
|
||||
|
||||
// Many type relation
|
||||
if constexpr (std::is_base_of_v<Relations::ManyRelation,
|
||||
if constexpr (std::is_base_of_v<Relations::IsManyRelation,
|
||||
typename Relation::element_type>)
|
||||
{
|
||||
for (auto *const relatedModel : getRelationValue<Related>(relationName))
|
||||
@@ -1122,7 +1122,7 @@ namespace Concerns
|
||||
}
|
||||
|
||||
// One type relation
|
||||
else if constexpr (std::is_base_of_v<Relations::OneRelation,
|
||||
else if constexpr (std::is_base_of_v<Relations::IsOneRelation,
|
||||
typename Relation::element_type>)
|
||||
{
|
||||
if (auto *const relatedModel = getRelationValue<Related, One>(relationName);
|
||||
|
||||
@@ -563,7 +563,7 @@ namespace Orm::Tiny::Concerns
|
||||
{
|
||||
using Relation = typename std::invoke_result_t<Method, Derived>::element_type;
|
||||
|
||||
if constexpr (!std::is_base_of_v<Relations::PivotRelation, Relation>)
|
||||
if constexpr (!std::is_base_of_v<Relations::IsPivotRelation, Relation>)
|
||||
return;
|
||||
|
||||
m_result = typename Relation::RelatedType().getTable();
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Orm::Tiny::Relations
|
||||
|
||||
/*! Belongs to relation. */
|
||||
template<class Model, class Related>
|
||||
class BelongsTo : public OneRelation,
|
||||
class BelongsTo : public IsOneRelation,
|
||||
public Relation<Model, Related>,
|
||||
public Concerns::SupportsDefaultModels<Model, Related>
|
||||
{
|
||||
|
||||
@@ -21,9 +21,9 @@ namespace Orm::Tiny::Relations
|
||||
/*! Belongs to many relation. */
|
||||
template<class Model, class Related, class PivotType = Pivot>
|
||||
class BelongsToMany :
|
||||
public ManyRelation,
|
||||
public IsManyRelation,
|
||||
public Relation<Model, Related>,
|
||||
public PivotRelation,
|
||||
public IsPivotRelation,
|
||||
public Concerns::InteractsWithPivotTable<Model, Related, PivotType>
|
||||
{
|
||||
/*! Alias for the attribute utils. */
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Orm::Tiny::Relations
|
||||
|
||||
/*! Has many relation. */
|
||||
template<class Model, class Related>
|
||||
class HasMany : public ManyRelation,
|
||||
class HasMany : public IsManyRelation,
|
||||
public HasOneOrMany<Model, Related>
|
||||
{
|
||||
Q_DISABLE_COPY(HasMany)
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Orm::Tiny::Relations
|
||||
|
||||
/*! Has one relation. */
|
||||
template<class Model, class Related>
|
||||
class HasOne : public OneRelation,
|
||||
class HasOne : public IsOneRelation,
|
||||
public HasOneOrMany<Model, Related>,
|
||||
public Concerns::SupportsDefaultModels<Model, Related>
|
||||
{
|
||||
|
||||
@@ -39,66 +39,66 @@ namespace Orm::Tiny::Relations
|
||||
IsRelation::~IsRelation() = default;
|
||||
|
||||
/*! Tag for one type relation. */
|
||||
class OneRelation
|
||||
class IsOneRelation
|
||||
{
|
||||
Q_DISABLE_COPY(OneRelation)
|
||||
Q_DISABLE_COPY(IsOneRelation)
|
||||
|
||||
public:
|
||||
/*! Default constructor. */
|
||||
inline OneRelation() = default;
|
||||
inline IsOneRelation() = default;
|
||||
/*! Pure virtual destructor. */
|
||||
inline virtual ~OneRelation() = 0;
|
||||
inline virtual ~IsOneRelation() = 0;
|
||||
};
|
||||
|
||||
OneRelation::~OneRelation() = default;
|
||||
IsOneRelation::~IsOneRelation() = default;
|
||||
|
||||
/*! Tag for many type relation. */
|
||||
class ManyRelation
|
||||
class IsManyRelation
|
||||
{
|
||||
protected:
|
||||
/*! ManyRelation's copy constructor (used by BelongsToMany::clone()). */
|
||||
inline ManyRelation(const ManyRelation &) = default;
|
||||
/*! IsManyRelation's copy constructor (used by BelongsToMany::clone()). */
|
||||
inline IsManyRelation(const IsManyRelation &) = default;
|
||||
|
||||
public:
|
||||
/*! Default constructor. */
|
||||
inline ManyRelation() = default;
|
||||
inline IsManyRelation() = default;
|
||||
/*! Pure virtual destructor. */
|
||||
inline virtual ~ManyRelation() = 0;
|
||||
inline virtual ~IsManyRelation() = 0;
|
||||
|
||||
/*! ManyRelation's move constructor. */
|
||||
ManyRelation(ManyRelation &&) = delete;
|
||||
/*! IsManyRelation's move constructor. */
|
||||
IsManyRelation(IsManyRelation &&) = delete;
|
||||
|
||||
/*! ManyRelation's copy assignment operator. */
|
||||
ManyRelation &operator=(const ManyRelation &) = delete;
|
||||
/*! ManyRelation's move assignment operator. */
|
||||
ManyRelation &operator=(ManyRelation &&) = delete;
|
||||
/*! IsManyRelation's copy assignment operator. */
|
||||
IsManyRelation &operator=(const IsManyRelation &) = delete;
|
||||
/*! IsManyRelation's move assignment operator. */
|
||||
IsManyRelation &operator=(IsManyRelation &&) = delete;
|
||||
};
|
||||
|
||||
ManyRelation::~ManyRelation() = default;
|
||||
IsManyRelation::~IsManyRelation() = default;
|
||||
|
||||
/*! Tag for the relation which contains pivot table, like many-to-many. */
|
||||
class PivotRelation
|
||||
class IsPivotRelation
|
||||
{
|
||||
protected:
|
||||
/*! PivotRelation's copy constructor (used by BelongsToMany::clone()). */
|
||||
inline PivotRelation(const PivotRelation &) = default;
|
||||
/*! IsPivotRelation's copy constructor (used by BelongsToMany::clone()). */
|
||||
inline IsPivotRelation(const IsPivotRelation &) = default;
|
||||
|
||||
public:
|
||||
/*! Default constructor. */
|
||||
inline PivotRelation() = default;
|
||||
inline IsPivotRelation() = default;
|
||||
/*! Pure virtual destructor. */
|
||||
inline virtual ~PivotRelation() = 0;
|
||||
inline virtual ~IsPivotRelation() = 0;
|
||||
|
||||
/*! PivotRelation's move constructor. */
|
||||
PivotRelation(PivotRelation &&) = delete;
|
||||
/*! IsPivotRelation's move constructor. */
|
||||
IsPivotRelation(IsPivotRelation &&) = delete;
|
||||
|
||||
/*! PivotRelation's copy assignment operator. */
|
||||
PivotRelation &operator=(const PivotRelation &) = delete;
|
||||
/*! PivotRelation's move assignment operator. */
|
||||
PivotRelation &operator=(PivotRelation &&) = delete;
|
||||
/*! IsPivotRelation's copy assignment operator. */
|
||||
IsPivotRelation &operator=(const IsPivotRelation &) = delete;
|
||||
/*! IsPivotRelation's move assignment operator. */
|
||||
IsPivotRelation &operator=(IsPivotRelation &&) = delete;
|
||||
};
|
||||
|
||||
PivotRelation::~PivotRelation() = default;
|
||||
IsPivotRelation::~IsPivotRelation() = default;
|
||||
|
||||
} // namespace Orm::Tiny::Relations
|
||||
|
||||
|
||||
Reference in New Issue
Block a user