query/include/matador/utils/identifiable.hpp

51 lines
1.1 KiB
C++

#ifndef QUERY_IDENTIFIABLE_HPP
#define QUERY_IDENTIFIABLE_HPP
#include "matador/utils/identifier.hpp"
namespace matador::utils {
/**
* Base class for all pointer object
* which can contain an identifiable
*/
class identifiable
{
public:
virtual ~identifiable() = default;
/**
* Resets the object_holder with the given
* identifier. If the type of identifier differs
* from internal type an exception is thrown
*
* @param id The identifier to set
*/
virtual void reset(const identifier &id) = 0;
/**
* Returns true if serializable has a primary key
*
* @return true if serializable has a primary key
*/
[[nodiscard]] virtual bool has_primary_key() const = 0;
/**
* Gets the primary key of the foreign serializable
*
* @return The primary key of the foreign serializable
*/
[[nodiscard]] virtual const identifier& primary_key() const = 0;
virtual identifier& primary_key() = 0;
/**
* Creates a new identifier object.
*
* @return Returns a new identifier object.
*/
[[nodiscard]] virtual identifier create_identifier() const = 0;
};
}
#endif //QUERY_IDENTIFIABLE_HPP