Skip to content

Commit

Permalink
🐛 fixes and some convenience functions ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
aconstlink committed Nov 22, 2024
1 parent 8968723 commit 6cd72bc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
33 changes: 33 additions & 0 deletions property/generic_property.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename this_t::is_mtr_t>( 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
Expand Down
5 changes: 3 additions & 2 deletions property/property_sheet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<motor::wire::input_slot< T > > ;
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 ;
}
Expand Down

0 comments on commit 6cd72bc

Please sign in to comment.