diff --git a/property/generic_property.hpp b/property/generic_property.hpp index 4c2b3d1..08e91c5 100644 --- a/property/generic_property.hpp +++ b/property/generic_property.hpp @@ -399,6 +399,39 @@ namespace motor return _is ; } + void_t replace_is( motor::wire::iinput_slot_mtr_safe_t s, bool_t const take_old_value ) noexcept + { + if ( s.mtr() == _is ) + { + motor::release( motor::move( s ) ) ; + return ; + } + + auto * s_ = dynamic_cast( s.mtr() ) ; + if ( s_ == nullptr ) + { + motor::release( motor::move( s ) ) ; + return ; + } + + if( take_old_value && _is != nullptr ) + s_->set_value( _is->get_value() ) ; + + motor::release( motor::move( _is ) ) ; + _is = s_ ; + } + + void_t replace_is( motor::wire::iinput_slot_mtr_safe_t s ) noexcept + { + this_t::replace_is( motor::move( s ), false ) ; + } + + void_t replace_is( typename this_t::is_mtr_safe_t s ) noexcept + { + motor::release( motor::move( _is ) ) ; + _is = motor::move( s ) ; + } + public: static bool_t create_property( motor::wire::iinput_slot_mtr_t is, this_t & prop_out ) noexcept diff --git a/property/property_sheet.hpp b/property/property_sheet.hpp index 8cb674a..af55107 100644 --- a/property/property_sheet.hpp +++ b/property/property_sheet.hpp @@ -154,14 +154,15 @@ namespace motor template< typename T > static bool_t add_is_property( motor::string_in_t name, motor::wire::iinput_slot_ptr_t is, motor::property::property_sheet_inout_t props ) { - using property_t = motor::property::generic_property > ; + using type_t = motor::wire::input_slot< T > ; + using property_t = motor::property::generic_property< type_t > ; property_t p ; if ( property_t::create_property( is, p ) ) { if( !props.add_property( name, std::move( p ) ) ) { - return props.borrow_property< T >( name ) != nullptr ; + return props.borrow_property< type_t >( name ) != nullptr ; } return true ; }