added logging module and a sandbox project
This commit is contained in:
+8
-2
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
add_executable(demo main.cpp)
|
||||
target_link_libraries(demo PRIVATE
|
||||
matador-core
|
||||
@@ -7,3 +5,11 @@ target_link_libraries(demo PRIVATE
|
||||
${CMAKE_DL_LIBS}
|
||||
${SQLite3_LIBRARIES}
|
||||
)
|
||||
|
||||
add_executable(sandbox sandbox.cpp)
|
||||
target_link_libraries(sandbox PRIVATE
|
||||
matador-core
|
||||
matador-orm
|
||||
${CMAKE_DL_LIBS}
|
||||
${SQLite3_LIBRARIES}
|
||||
)
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
#ifndef AUTHOR_HPP
|
||||
#define AUTHOR_HPP
|
||||
|
||||
#include "matador/object/collection.hpp"
|
||||
#include "matador/object/object_ptr.hpp"
|
||||
|
||||
#include "matador/utils/access.hpp"
|
||||
|
||||
namespace demo {
|
||||
struct book;
|
||||
|
||||
struct author {
|
||||
unsigned int id{};
|
||||
std::string first_name;
|
||||
std::string last_name;
|
||||
std::string date_of_birth;
|
||||
unsigned short year_of_birth{};
|
||||
bool distinguished{false};
|
||||
matador::object::collection<matador::object::object_ptr<book>> books;
|
||||
|
||||
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
namespace field = matador::access;
|
||||
field::primary_key( op, "id", id );
|
||||
field::attribute( op, "first_name", first_name, 63 );
|
||||
field::attribute( op, "last_name", last_name, 63 );
|
||||
field::attribute( op, "date_of_birth", date_of_birth, 31 );
|
||||
field::attribute( op, "year_of_birth", year_of_birth );
|
||||
field::attribute( op, "distinguished", distinguished );
|
||||
field::has_many( op, "books", books, "author_id" );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif //AUTHOR_HPP
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef BOOK_HPP
|
||||
#define BOOK_HPP
|
||||
|
||||
#include "matador/object/object_ptr.hpp"
|
||||
#include "matador/utils/access.hpp"
|
||||
|
||||
namespace demo {
|
||||
struct author;
|
||||
|
||||
struct book {
|
||||
unsigned int id{};
|
||||
matador::object::object_ptr<author> book_author;
|
||||
std::string title;
|
||||
unsigned short published_in{};
|
||||
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
namespace field = matador::access;
|
||||
field::primary_key( op, "id", id );
|
||||
field::attribute( op, "title", title, 511 );
|
||||
field::has_one( op, "author_id", book_author, matador::utils::default_foreign_attributes );
|
||||
field::attribute( op, "published_in", published_in );
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif //BOOK_HPP
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "matador/object/schema.hpp"
|
||||
|
||||
#include "author.hpp"
|
||||
#include "book.hpp"
|
||||
|
||||
using namespace demo;
|
||||
using namespace matador;
|
||||
int main() {
|
||||
object::schema tree;
|
||||
|
||||
|
||||
tree.attach<author>("authors");
|
||||
tree.attach<book>("books");
|
||||
|
||||
}
|
||||
+3
-3
@@ -52,15 +52,15 @@ int main() {
|
||||
object::schema schema("Administration");
|
||||
|
||||
auto result = schema.attach<admin::CollectionCenter>("collection_center")
|
||||
.and_then([&schema] { return schema.attach<admin::InternalUserDirectory>("internal_user_directories"); })
|
||||
.and_then([&schema] { return schema.attach<admin::UserDirectory>("user_directories"); })
|
||||
.and_then([&schema] { return schema.attach<admin::LdapGroupSchemaSettings>("ldap_group_schema_settings"); })
|
||||
.and_then([&schema] { return schema.attach<admin::LdapImportSettings>("ldap_import_settings"); })
|
||||
.and_then([&schema] { return schema.attach<admin::LdapUserDirectory>("ldap_user_directories"); } )
|
||||
.and_then([&schema] { return schema.attach<admin::LdapUserSchemaSettings>("ldap_user_schema_settings"); })
|
||||
.and_then([&schema] { return schema.attach<admin::UserDirectory, admin::InternalUserDirectory>("internal_user_directories"); })
|
||||
.and_then([&schema] { return schema.attach<admin::UserDirectory, admin::LdapUserDirectory>("ldap_user_directories"); } )
|
||||
.and_then([&schema] { return schema.attach<admin::LoginHistory>("login_histories"); })
|
||||
.and_then([&schema] { return schema.attach<admin::Scenario>("scenarios"); })
|
||||
.and_then([&schema] { return schema.attach<admin::User>("users"); })
|
||||
.and_then([&schema] { return schema.attach<admin::UserDirectory>("user_directories"); })
|
||||
.and_then([&schema] { return schema.attach<admin::UserSession>("user_sessions"); })
|
||||
.and_then([&schema] { return schema.attach<jobs::Job>("jobs"); })
|
||||
.and_then([&schema] { return schema.attach<jobs::Payload>("payloads"); })
|
||||
|
||||
Reference in New Issue
Block a user