57 lines
1.9 KiB
C++
57 lines
1.9 KiB
C++
#include "property_scope.hpp"
|
|
|
|
#include <cppbase/templates.hpp>
|
|
|
|
#include <ikarus/objects/blueprint.hpp>
|
|
#include <ikarus/objects/entity.hpp>
|
|
|
|
IkarusPropertyScope::IkarusPropertyScope(Data data):
|
|
data{data} {}
|
|
|
|
IkarusId IkarusPropertyScope::get_id() const {
|
|
return std::visit(
|
|
cppbase::overloaded{
|
|
[](IkarusBlueprint const * blueprint) { return blueprint->id; },
|
|
[](IkarusEntity const * entity) { return entity->id; }
|
|
},
|
|
data
|
|
);
|
|
}
|
|
|
|
IkarusPropertyScope * ikarus_property_source_create_blueprint(IkarusBlueprint * blueprint) {
|
|
return new IkarusPropertyScope{blueprint};
|
|
}
|
|
|
|
IkarusPropertyScope * ikarus_property_source_create_entity(IkarusEntity * entity) {
|
|
return new IkarusPropertyScope{entity};
|
|
}
|
|
|
|
void ikarus_property_source_visit(
|
|
struct IkarusPropertyScope * property_source,
|
|
void (*blueprint_visitor)(struct IkarusBlueprint *, void *),
|
|
void (*entity_visitor)(struct IkarusEntity *, void *),
|
|
void * user_data
|
|
) {
|
|
std::visit(
|
|
cppbase::overloaded{
|
|
[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 IkarusPropertyScope const * property_source,
|
|
void (*blueprint_visitor)(struct IkarusBlueprint const *, void *),
|
|
void (*entity_visitor)(struct IkarusEntity const *, void *),
|
|
void * user_data
|
|
) {
|
|
std::visit(
|
|
cppbase::overloaded{
|
|
[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
|
|
);
|
|
}
|