implement IkarusPropertySource and switch to cppbase::overloaded
Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
parent
ab250c00ae
commit
7be1675180
10 changed files with 90 additions and 50 deletions
|
|
@ -0,0 +1,46 @@
|
|||
#include "property_source.hpp"
|
||||
|
||||
#include <boost/functional/overloaded_function.hpp>
|
||||
|
||||
#include <objects/blueprint.hpp>
|
||||
|
||||
IkarusPropertySource::IkarusPropertySource(Data data):
|
||||
data{data} {}
|
||||
|
||||
IkarusPropertySource * ikarus_property_source_create_blueprint(IkarusBlueprint * blueprint) {
|
||||
return new IkarusPropertySource{blueprint};
|
||||
}
|
||||
|
||||
IkarusPropertySource * ikarus_property_source_create_entity(IkarusEntity * entity) {
|
||||
return new IkarusPropertySource{entity};
|
||||
}
|
||||
|
||||
void ikarus_property_source_visit(
|
||||
struct IkarusPropertySource * property_source,
|
||||
void (*blueprint_visitor)(struct IkarusBlueprint *, void *),
|
||||
void (*entity_visitor)(struct IkarusEntity *, void *),
|
||||
void * user_data
|
||||
) {
|
||||
boost::variant2::visit(
|
||||
boost::make_overloaded_function(
|
||||
[blueprint_visitor, user_data](IkarusBlueprint * blueprint) { blueprint_visitor(blueprint, user_data); },
|
||||
[entity_visitor, user_data](IkarusEntity * entity) { entity_visitor(entity, user_data); }
|
||||
),
|
||||
property_source->data
|
||||
);
|
||||
}
|
||||
|
||||
void ikarus_property_source_visit_const(
|
||||
struct IkarusPropertySource const * property_source,
|
||||
void (*blueprint_visitor)(struct IkarusBlueprint const *, void *),
|
||||
void (*entity_visitor)(struct IkarusEntity const *, void *),
|
||||
void * user_data
|
||||
) {
|
||||
boost::variant2::visit(
|
||||
boost::make_overloaded_function(
|
||||
[blueprint_visitor, user_data](IkarusBlueprint const * blueprint) { blueprint_visitor(blueprint, user_data); },
|
||||
[entity_visitor, user_data](IkarusEntity const * entity) { entity_visitor(entity, user_data); }
|
||||
),
|
||||
property_source->data
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue