Database System 0.1.0
Advanced C++20 Database System with Multi-Backend Support
Loading...
Searching...
No Matches
entity.h File Reference
#include "../database_types.h"
#include "../core/database_backend.h"
#include <string>
#include <vector>
#include <memory>
#include <type_traits>
#include <chrono>
#include <unordered_map>
#include <functional>
#include <mutex>
#include <optional>
Include dependency graph for entity.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  database::orm::is_entity< T, typename >
 
struct  database::orm::is_entity< T, std::void_t< typename T::primary_key_type, decltype(std::declval< T >().table_name()), decltype(std::declval< T >().get_metadata()) > >
 
class  database::orm::field_metadata
 Metadata for entity fields including constraints and relationships. More...
 
class  database::orm::entity_metadata
 Metadata for entire entities including table mapping and relationships. More...
 
class  database::orm::entity_base
 Base class for all ORM entities. More...
 
class  database::orm::field_accessor< T, typename >
 Template class for type-safe field access. More...
 
class  database::orm::query_builder< EntityType, typename >
 Template query builder for type-safe ORM queries. More...
 
class  database::orm::entity_manager
 Manages entity metadata and provides factory methods. More...
 

Namespaces

namespace  database
 
namespace  database::orm
 

Macros

#define ENTITY_FIELD(type, name, ...)
 
#define ENTITY_TABLE(table_name)
 
#define ENTITY_METADATA()
 

Enumerations

enum class  database::orm::field_constraint {
  database::orm::none = 0 , database::orm::primary_key = 1 , database::orm::not_null = 2 , database::orm::unique = 4 ,
  database::orm::auto_increment = 8 , database::orm::index = 16 , database::orm::foreign_key = 32 , database::orm::default_now = 64
}
 

Functions

field_constraint database::orm::operator| (field_constraint a, field_constraint b)
 
bool database::orm::has_constraint (field_constraint constraints, field_constraint check)
 
field_constraint database::orm::primary_key ()
 
field_constraint database::orm::not_null ()
 
field_constraint database::orm::unique ()
 
field_constraint database::orm::auto_increment ()
 
field_constraint database::orm::default_now ()
 
field_constraint database::orm::index (const std::string &name="")
 
field_constraint database::orm::foreign_key (const std::string &table, const std::string &field)
 

Variables

template<typename T >
constexpr bool database::orm::is_entity_v = is_entity<T>::value
 
template<typename T >
constexpr bool database::orm::is_field_type_v
 

Macro Definition Documentation

◆ ENTITY_FIELD

#define ENTITY_FIELD ( type,
name,
... )
Value:
private: \
type name##_; \
static inline field_metadata name##_metadata_{#name, #type, __VA_ARGS__}; \
public: \
field_accessor<type> name{name##_, name##_metadata_}; \
static const field_metadata& name##_field() { return name##_metadata_; }
Examples
orm_framework_demo.cpp.

Definition at line 274 of file entity.h.

274 #define ENTITY_FIELD(type, name, ...) \
275 private: \
276 type name##_; \
277 static inline field_metadata name##_metadata_{#name, #type, __VA_ARGS__}; \
278 public: \
279 field_accessor<type> name{name##_, name##_metadata_}; \
280 static const field_metadata& name##_field() { return name##_metadata_; }

◆ ENTITY_METADATA

#define ENTITY_METADATA ( )
Value:
public: \
const entity_metadata& get_metadata() const override { \
static std::once_flag init_flag; \
std::call_once(init_flag, [this]() { initialize_metadata(); }); \
return metadata_; \
} \
private: \
static void initialize_metadata();
Examples
orm_framework_demo.cpp.

Definition at line 289 of file entity.h.

289 #define ENTITY_METADATA() \
290 public: \
291 const entity_metadata& get_metadata() const override { \
292 static std::once_flag init_flag; \
293 std::call_once(init_flag, [this]() { initialize_metadata(); }); \
294 return metadata_; \
295 } \
296 private: \
297 static void initialize_metadata();

◆ ENTITY_TABLE

#define ENTITY_TABLE ( table_name)
Value:
public: \
std::string table_name() const override { return table_name; } \
using primary_key_type = decltype(id_); \
private: \
static inline entity_metadata metadata_{table_name};
Examples
orm_framework_demo.cpp.

Definition at line 282 of file entity.h.

282 #define ENTITY_TABLE(table_name) \
283 public: \
284 std::string table_name() const override { return table_name; } \
285 using primary_key_type = decltype(id_); \
286 private: \
287 static inline entity_metadata metadata_{table_name};