// Copyright (c) 2023 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #include "assert/assert.hpp" #include "util/Flag.hpp" #include "SceneComponent.hpp" using namespace Dawn; void SceneComponent::init(const std::shared_ptr item) { assertFlagOff( sceneComponentState, SCENE_COMPONENT_STATE_INIT, "SceneComponent is already initialized!" ); Flag::turnOn( sceneComponentState, SCENE_COMPONENT_STATE_INIT ); this->item = item; this->onInit(); } void SceneComponent::dispose() { assertFlagOn( sceneComponentState, SCENE_COMPONENT_STATE_INIT, "SceneComponent is not initialized!" ); assertFlagOff( sceneComponentState, SCENE_COMPONENT_STATE_DISPOSED, "SceneComponent is already disposed!" ); Flag::turnOn( sceneComponentState, SCENE_COMPONENT_STATE_DISPOSED ); this->onDispose(); this->item.reset(); } std::shared_ptr SceneComponent::getItem() { return this->item.lock(); } SceneComponent::~SceneComponent() { if(Flag::isOn( sceneComponentState, SCENE_COMPONENT_STATE_INIT )) { assertFlagOn( sceneComponentState, SCENE_COMPONENT_STATE_DISPOSED, "SceneComponent is initialized but was not properly disposed!" ); } }