From 375da1cd468b53b8a8f5fcb1958b3fcae01f717b Mon Sep 17 00:00:00 2001 From: Alex Link Date: Thu, 28 Nov 2024 10:41:32 +0100 Subject: [PATCH] [#104] - :construction: yet another change. wire variables now just have one level of submembers due to memory footprint. --- wire/slot/input_slot.h | 11 + wire/variable.hpp | 83 ++------ wire/variables/trafo_variables.hpp | 142 ++++++------- wire/variables/vector_variables.hpp | 304 +++++++++++++++++----------- 4 files changed, 288 insertions(+), 252 deletions(-) diff --git a/wire/slot/input_slot.h b/wire/slot/input_slot.h index 725b83c..ffda468 100644 --- a/wire/slot/input_slot.h +++ b/wire/slot/input_slot.h @@ -138,6 +138,11 @@ namespace motor return _value ; } + bool_t has_changed( void_t ) const noexcept + { + return _has_changed ; + } + // get the value in v if the value has changed // returns the "changed flag" and also resets it bool_t get_value_and_reset( T & v ) noexcept @@ -152,6 +157,12 @@ namespace motor return false ; } + T const & get_value_and_reset( void_t ) noexcept + { + _has_changed = false ; + return _value ; + } + // void_t set_value( T const v ) noexcept { diff --git a/wire/variable.hpp b/wire/variable.hpp index c381cf8..4b72643 100644 --- a/wire/variable.hpp +++ b/wire/variable.hpp @@ -11,9 +11,6 @@ namespace motor { namespace wire { - class simple_trait { /*public: virtual ~simple_trait( void_t ) {}*/ } ; - class detailed_trait {} ; - class any { motor_this_typedefs( any ) ; @@ -56,6 +53,12 @@ namespace motor return _name ; } + motor::string_t sname( void_t ) const noexcept + { + return motor::string_t( _name ) ; + } + + #if 0 inputs_t inputs( void_t ) noexcept { inputs_t ret ; @@ -65,11 +68,13 @@ namespace motor } ) ; return ret ; } + #endif public: // virtual // return bool if anything changed. virtual bool_t update( void_t ) noexcept = 0 ; + virtual motor::wire::inputs_t inputs( void_t ) noexcept = 0 ; public: @@ -127,56 +132,14 @@ namespace motor { return _out ; } - - public: - - void_t inspect( for_each_funk_t f ) noexcept - { - member_info_t info{ 0, motor::string_t( this_t::name() ) } ; - f( *this, info ) ; - ++info.level ; - - this->for_each_member( f, info ) ; - } - - class derived_accessor - { - this_ref_t _owner ; - public: - derived_accessor( this_ref_t r ) noexcept : _owner( r ) {} - void_t for_each_member( for_each_funk_t f, member_info_in_t ifo ) noexcept - { - _owner.for_each_member( f, ifo ) ; - } - }; - friend class derived_accessor ; - - private: - - // go through every member motor::wire::variable< some_type > - // only required for complex types with multiple sub-variables - virtual void_t for_each_member( for_each_funk_t f, member_info_in_t ) noexcept - { - // do not implement if no sub-variables are used! - } }; motor_typedef( any ) ; - static bool_t is_simple( motor::wire::any_ptr_t p ) noexcept - { - return dynamic_cast< motor::wire::simple_trait * >( p ) != nullptr ; - } - - static bool_t is_detailed( motor::wire::any_ptr_t p ) noexcept - { - return dynamic_cast( p ) != nullptr ; - } - - template< typename T, typename trait_t > - class variable : public any, public trait_t + template< typename T > + class variable : public any { using base_t = any ; - motor_this_typedefs( variable< T motor_comma trait_t > ) ; + motor_this_typedefs( variable< T > ) ; public: @@ -207,6 +170,12 @@ namespace motor return false ; } + virtual motor::wire::inputs_t inputs( void_t ) noexcept + { + return motor::wire::inputs_t( { { base_t::sname(), base_t::get_is() } }, false ) ; + } + + // get output slot value T const & get_value( void_t ) const noexcept { @@ -220,18 +189,10 @@ namespace motor } }; - motor_typedefs( variable< bool_t motor_comma motor::wire::simple_trait >, boolv ) ; - motor_typedefs( variable< int_t motor_comma motor::wire::simple_trait >, intv ) ; - motor_typedefs( variable< uint_t motor_comma motor::wire::simple_trait >, uintv ) ; - motor_typedefs( variable< float_t motor_comma motor::wire::simple_trait >, floatv ) ; - motor_typedefs( variable< double_t motor_comma motor::wire::simple_trait >, doublev ) ; - - - template< typename T > - bool_t is_type_compatible( motor::wire::any_ptr_t ptr ) noexcept - { - using target_type = motor::wire::variable< T, motor::wire::simple_trait >::out_t ; - return dynamic_cast< target_type *>( ptr->borrow_os() ) != nullptr ; - } + motor_typedefs( variable< bool_t >, boolv ) ; + motor_typedefs( variable< int_t >, intv ) ; + motor_typedefs( variable< uint_t >, uintv ) ; + motor_typedefs( variable< float_t >, floatv ) ; + motor_typedefs( variable< double_t >, doublev ) ; } } \ No newline at end of file diff --git a/wire/variables/trafo_variables.hpp b/wire/variables/trafo_variables.hpp index 3923cf2..d494daa 100644 --- a/wire/variables/trafo_variables.hpp +++ b/wire/variables/trafo_variables.hpp @@ -9,15 +9,11 @@ namespace motor namespace wire { template< typename T > - class variable< motor::math::m3d::transformation< T >, motor::wire::detailed_trait > : public motor::wire::any, public motor::wire::detailed_trait + class variable< motor::math::m3d::transformation< T > > : public motor::wire::any { using base_t = motor::wire::any ; - using trait_t = motor::wire::detailed_trait ; - - motor_this_typedefs( variable< motor::math::m3d::transformation< T > motor_comma trait_t > ) ; - - + motor_this_typedefs( variable< motor::math::m3d::transformation< T > > ) ; public: @@ -25,38 +21,57 @@ namespace motor private: - using pos_t = motor::wire::vec3v< T, trait_t > ; - using scale_t = motor::wire::vec3v< T, trait_t > ; - using axis_t = motor::wire::vec3v< T, trait_t > ; - using angle_t = motor::wire::variable< T, trait_t > ; - using in_t = motor::wire::input_slot< value_t > ; using out_t = motor::wire::output_slot< value_t > ; + using vec3_is_t = motor::wire::input_slot< motor::math::vector3< T > > ; + using type_is_t = motor::wire::input_slot< T > ; + private: - pos_t _pos = pos_t( "position" ) ; - scale_t _scale = scale_t( "scale" ) ; - axis_t _axis = axis_t( "axis" ) ; - angle_t _angle = angle_t( "angle" ) ; + vec3_is_t * _pos = motor::shared( vec3_is_t() ) ; + vec3_is_t * _scale = motor::shared( vec3_is_t() ) ; + vec3_is_t * _axis = motor::shared( vec3_is_t() ) ; + type_is_t * _angle = motor::shared( type_is_t() ) ; public: variable( char const * name ) noexcept : base_t( name, motor::shared( in_t() ), motor::shared( out_t() ) ) {} variable( char const * name, value_cref_t v ) noexcept : base_t( name, - motor::shared( in_t() ), motor::shared( out_t() ) ) + motor::shared( in_t( v ) ), motor::shared( out_t( v ) ) ) { - this_t::set_value( v ) ; + this_t::propagate_value_to_sub( v ) ; } variable( this_cref_t ) = delete ; - variable( this_rref_t rhv ) noexcept : - base_t( std::move( rhv ) ), - _pos( std::move( rhv._pos ) ), _scale( std::move( rhv._scale ) ), - _axis( std::move( rhv._axis ) ), _angle( std::move( rhv._angle ) ) {} + variable( this_rref_t rhv ) noexcept : base_t( std::move( rhv ) ) + { + this_t::disconnect_and_clear() ; - virtual ~variable( void_t ) noexcept {} + _pos = motor::move( rhv._pos ) ; + _scale = motor::move( rhv._scale ) ; + _axis = motor::move( rhv._axis ) ; + _angle = motor::move( rhv._angle ) ; + } + + virtual ~variable( void_t ) noexcept + { + this_t::disconnect_and_clear() ; + } + + void_t disconnect_and_clear( void_t ) noexcept + { + if( _pos != nullptr ) _pos->disconnect() ; + if( _scale != nullptr ) _scale->disconnect() ; + if( _axis != nullptr ) _axis->disconnect() ; + if( _angle != nullptr ) _angle->disconnect() ; + + motor::release( motor::move( _pos ) ) ; + motor::release( motor::move( _scale ) ) ; + motor::release( motor::move( _axis ) ) ; + motor::release( motor::move( _angle ) ) ; + } public: @@ -75,17 +90,17 @@ namespace motor this_t::propagate_value_to_sub( v ) ; return true ; } - else if ( motor::math::vec4b_t( _pos.update(), _scale.update(), - _axis.update(), _angle.update() ).any() ) + else if ( motor::math::vec4b_t( _pos->has_changed(), _scale->has_changed(), + _axis->has_changed(), _angle->has_changed() ).any() ) { - auto const p = _pos.get_value() ; - auto const s = _scale.get_value() ; - auto const ax = _axis.get_value() ; - auto const an = _angle.get_value() ; + auto const p = _pos->get_value_and_reset() ; + auto const s = _scale->get_value_and_reset() ; + auto const ax = _axis->get_value_and_reset() ; + auto const an = _angle->get_value_and_reset() ; this_t::value_t const trafo( s, motor::math::vector_is_normalized( motor::math::vector4( ax, an ) ), p ) ; - this_t::set_value( trafo ) ; + this_t::set_value_and_exchange( trafo ) ; return true ; } @@ -93,14 +108,25 @@ namespace motor return false ; } + virtual motor::wire::inputs_t inputs( void_t ) noexcept + { + motor::string_t const name = base_t::sname() ; + + return motor::wire::inputs_t( + { + { name, base_t::get_is() }, + { name + ".position", motor::share( _pos ) }, + { name + ".scale", motor::share( _scale ) }, + { name + ".axis", motor::share( _axis ) }, + { name + ".angle", motor::share( _angle ) } + }, false ) ; + } + value_cref_t get_value( void_t ) const noexcept { return base_t::borrow_os()->get_value() ; } - - // if the transformation is updated, other - // costly functions are called. So only use - // if really required. + void_t set_value( value_cref_t v ) noexcept { auto in_ = base_t::borrow_is() ; @@ -110,54 +136,32 @@ namespace motor out_->set_value( v ) ; } - private: - - void_t propagate_value_to_sub( value_cref_t v ) noexcept + void_t set_value_and_exchange( value_cref_t v ) noexcept { - _pos.set_value( v.get_translation() ) ; - - // some cost involved! - _scale.set_value( v.get_scale() ) ; - - // some cost involved! - { - auto const orientation = v.get_orientation() ; - _axis.set_value( orientation.xyz() ) ; - _angle.set_value( orientation.w() ) ; - } + auto in_ = base_t::borrow_is() ; + auto out_ = base_t::borrow_os() ; - { - auto const r = v.get_rotation_matrix() ; - _axis.set_value( r.rotation_axis() ) ; - _angle.set_value( r.angle() ) ; - } + in_->set_value( v ) ; + out_->set_and_exchange( v ) ; } private: - virtual void_t for_each_member( for_each_funk_t f, motor::wire::any::member_info_in_t ifo ) noexcept + void_t propagate_value_to_sub( value_cref_t v ) noexcept { - { - motor::string_t const full_name = ifo.full_name + "." + _pos.name() ; - f( _pos, { ifo.level, full_name } ) ; - motor::wire::any::derived_accessor( _pos ).for_each_member( f, { ifo.level + 1, full_name } ) ; - } + _pos->set_value( v.get_translation() ) ; - { - motor::string_t const full_name = ifo.full_name + "." + _axis.name() ; - f( _axis, { ifo.level, full_name } ) ; - motor::wire::any::derived_accessor( _axis ).for_each_member( f, { ifo.level + 1, full_name } ) ; - } + // some cost involved! + _scale->set_value( v.get_scale() ) ; + // some cost involved! { - motor::string_t const full_name = ifo.full_name + "." + _angle.name() ; - f( _angle, { ifo.level, full_name } ) ; - motor::wire::any::derived_accessor( _angle ).for_each_member( f, { ifo.level + 1, full_name } ) ; + auto const orientation = v.get_orientation() ; + _axis->set_value( orientation.xyz() ) ; + _angle->set_value( orientation.w() ) ; } } - } ; - motor_typedefs( variable< motor::math::m3d::transformation< float_t > motor_comma motor::wire::simple_trait >, trafo3fv ) ; - motor_typedefs( variable< motor::math::m3d::transformation< float_t > motor_comma motor::wire::detailed_trait >, trafo3fvd ) ; + motor_typedefs( variable< motor::math::m3d::transformation< float_t > >, trafo3fv ) ; } } \ No newline at end of file diff --git a/wire/variables/vector_variables.hpp b/wire/variables/vector_variables.hpp index 7e94b68..aca288a 100644 --- a/wire/variables/vector_variables.hpp +++ b/wire/variables/vector_variables.hpp @@ -13,36 +13,54 @@ namespace motor namespace wire { template< typename T > - class variable< motor::math::vector2< T >, motor::wire::detailed_trait > : public motor::wire::any, public motor::wire::detailed_trait + class variable< motor::math::vector2< T > > : public motor::wire::any { using base_t = motor::wire::any ; - motor_this_typedefs( variable< motor::math::vector2< T > motor_comma motor::wire::detailed_trait > ) ; + motor_this_typedefs( variable< motor::math::vector2< T > > ) ; motor_typedefs( motor::math::vector2< T >, value ) ; - - using trait_t = motor::wire::detailed_trait ; + private: using in_t = motor::wire::input_slot< value_t > ; using out_t = motor::wire::output_slot< value_t > ; - using x_t = motor::wire::variable< T, trait_t > ; - using y_t = motor::wire::variable< T, trait_t > ; + using type_is_t = motor::wire::input_slot< T > ; - x_t _x = x_t( "x" ) ; - y_t _y = y_t( "y" ) ; + type_is_t * _x = motor::shared( type_is_t( T(0) ) ) ; + type_is_t * _y = motor::shared( type_is_t( T(0) ) ) ; public: variable( char const * const name ) noexcept : base_t( name, motor::shared( in_t() ), motor::shared( out_t() ) ) {} + variable( char const * const name, value_cref_t v ) noexcept : base_t( name, + motor::shared( in_t( v ) ), motor::shared( out_t( v ) ) ), + _x( motor::shared( type_is_t( v.x() ) ) ), + _y( motor::shared( type_is_t( v.y() ) ) ) {} + variable( this_cref_t ) = delete ; - variable( this_rref_t rhv ) noexcept : - base_t( std::move( rhv ) ), - _x( std::move( rhv._x ) ), _y( std::move( rhv._y ) ) {} + variable( this_rref_t rhv ) noexcept : base_t( std::move( rhv ) ) + { + this_t::disconnect_and_clear() ; + + _x = motor::move( rhv._x ) ; + _y = motor::move( rhv._y ) ; + } + + virtual ~variable( void_t ) noexcept + { + this_t::disconnect_and_clear() ; + } - virtual ~variable( void_t ) noexcept {} + void_t disconnect_and_clear( void_t ) noexcept + { + if( _x != nullptr ) _x->disconnect() ; + if( _y != nullptr ) _y->disconnect() ; + motor::release( motor::move( _x ) ) ; + motor::release( motor::move( _y ) ) ; + } public: @@ -62,17 +80,29 @@ namespace motor return true ; } else if ( motor::math::vec2b_t( - _x.update(), _y.update() ).any() ) + _x->has_changed(), _y->has_changed() ).any() ) { - value_t const v ( _x.get_value(), _y.get_value() ) ; + value_t const v ( _x->get_value_and_reset(), _y->get_value_and_reset() ) ; in_->set_value( v ) ; - *out_ = v ; + out_->set_and_exchange( v ) ; return true ; } return false ; } + virtual motor::wire::inputs_t inputs( void_t ) noexcept + { + motor::string_t const name = base_t::sname() ; + + return motor::wire::inputs_t( + { + { name, base_t::get_is() }, + { name + ".x", motor::share( _x ) }, + { name + ".y", motor::share( _y ) } + }, false ) ; + } + value_cref_t get_value( void_t ) const noexcept { return base_t::borrow_os()->get_value() ; @@ -91,54 +121,65 @@ namespace motor void_t propagate_value_to_sub( value_cref_t v ) noexcept { - _x.set_value( v.x() ) ; - _y.set_value( v.y() ) ; - } - - private: - - virtual void_t for_each_member( for_each_funk_t f, motor::wire::any::member_info_in_t ifo ) noexcept - { - f( _x, { ifo.level + 1, ifo.full_name + "." + _x.name() } ) ; - f( _y, { ifo.level + 1, ifo.full_name + "." + _y.name() } ) ; + _x->set_value( v.x() ) ; + _y->set_value( v.y() ) ; } }; template< typename T > - class variable< motor::math::vector3< T >, motor::wire::detailed_trait > : public motor::wire::any, public motor::wire::detailed_trait + class variable< motor::math::vector3< T > > : public motor::wire::any { using base_t = motor::wire::any ; - motor_this_typedefs( variable< motor::math::vector3< T > motor_comma motor::wire::detailed_trait > ) ; + motor_this_typedefs( variable< motor::math::vector3< T > > ) ; motor_typedefs( motor::math::vector3< T >, value ) ; - using trait_t = motor::wire::detailed_trait ; - private: using in_t = motor::wire::input_slot< value_t > ; using out_t = motor::wire::output_slot< value_t > ; - using x_t = motor::wire::variable< T, trait_t> ; - using y_t = motor::wire::variable< T, trait_t > ; - using z_t = motor::wire::variable< T, trait_t > ; + using type_is_t = motor::wire::input_slot< T > ; - x_t _x = x_t( "x" ) ; - y_t _y = y_t( "y" ) ; - z_t _z = z_t( "z" ) ; + type_is_t * _x = motor::shared( type_is_t( T(0) ) ) ; + type_is_t * _y = motor::shared( type_is_t( T(0) ) ) ; + type_is_t * _z = motor::shared( type_is_t( T(0) ) ) ; public: variable( char const * const name ) noexcept : base_t( name, motor::shared( in_t() ), motor::shared( out_t() ) ) {} + variable( char const * const name, value_cref_t v ) noexcept : base_t( name, + motor::shared( in_t( v ) ), motor::shared( out_t( v ) ) ), + _x( motor::shared( type_is_t( v.x() ) ) ), + _y( motor::shared( type_is_t( v.y() ) ) ), + _z( motor::shared( type_is_t( v.z() ) ) ) {} + variable( this_cref_t ) = delete ; - variable( this_rref_t rhv ) noexcept : - base_t( std::move( rhv ) ), - _x( std::move( rhv._x ) ), _y( std::move( rhv._y ) ), - _z( std::move( rhv._z ) ) {} + variable( this_rref_t rhv ) noexcept : base_t( std::move( rhv ) ) + { + this_t::disconnect_and_clear() ; + + _x = motor::move( rhv._x ) ; + _y = motor::move( rhv._y ) ; + _z = motor::move( rhv._z ) ; + } + + virtual ~variable( void_t ) noexcept + { + this_t::disconnect_and_clear() ; + } - virtual ~variable( void_t ) noexcept {} + void_t disconnect_and_clear( void_t ) noexcept + { + if ( _x != nullptr ) _x->disconnect() ; + if ( _y != nullptr ) _y->disconnect() ; + if ( _z != nullptr ) _z->disconnect() ; + motor::release( motor::move( _x ) ) ; + motor::release( motor::move( _y ) ) ; + motor::release( motor::move( _z ) ) ; + } public: @@ -158,17 +199,35 @@ namespace motor return true ; } else if ( motor::math::vec3b_t( - _x.update(), _y.update(), _z.update() ).any() ) + _x->has_changed(), _y->has_changed(), _z->has_changed() ).any() ) { - value_t const v ( _x.get_value(), _y.get_value(), _z.get_value() ) ; + value_t const v ( + _x->get_value_and_reset(), + _y->get_value_and_reset(), + _z->get_value_and_reset() ) ; + in_->set_value( v ) ; - *out_ = v ; + out_->set_and_exchange( v ) ; + return true ; } return false ; } + virtual motor::wire::inputs_t inputs( void_t ) noexcept + { + motor::string_t const name = base_t::sname() ; + + return motor::wire::inputs_t( + { + { name, base_t::get_is() }, + { name + ".x", motor::share( _x ) }, + { name + ".y", motor::share( _y ) }, + { name + ".z", motor::share( _z ) } + }, false ) ; + } + value_cref_t get_value( void_t ) const noexcept { return base_t::borrow_os()->get_value() ; @@ -187,58 +246,71 @@ namespace motor void_t propagate_value_to_sub( value_cref_t v ) noexcept { - _x.set_value( v.x() ) ; - _y.set_value( v.y() ) ; - _z.set_value( v.z() ) ; - } - - private: - - virtual void_t for_each_member( for_each_funk_t f, motor::wire::any::member_info_in_t ifo ) noexcept - { - f( _x, { ifo.level + 1, ifo.full_name + "." + _x.name() } ) ; - f( _y, { ifo.level + 1, ifo.full_name + "." + _y.name() } ) ; - f( _z, { ifo.level + 1, ifo.full_name + "." + _z.name() } ) ; + _x->set_value( v.x() ) ; + _y->set_value( v.y() ) ; + _z->set_value( v.z() ) ; } }; template< typename T > - class variable< motor::math::vector4< T >, motor::wire::detailed_trait > : public motor::wire::any, public motor::wire::detailed_trait + class variable< motor::math::vector4< T > > : public motor::wire::any { using base_t = motor::wire::any ; - motor_this_typedefs( variable< motor::math::vector4< T > motor_comma motor::wire::detailed_trait > ) ; + motor_this_typedefs( variable< motor::math::vector4< T > > ) ; motor_typedefs( motor::math::vector4< T >, value ) ; - using trait_t = motor::wire::detailed_trait ; - private: using in_t = motor::wire::input_slot< value_t > ; using out_t = motor::wire::output_slot< value_t > ; - using x_t = motor::wire::variable< T, trait_t > ; - using y_t = motor::wire::variable< T, trait_t > ; - using z_t = motor::wire::variable< T, trait_t > ; - using w_t = motor::wire::variable< T, trait_t > ; + using type_is_t = motor::wire::input_slot< T > ; - x_t _x = x_t( "x" ) ; - y_t _y = y_t( "y" ) ; - z_t _z = z_t( "z" ) ; - w_t _w = z_t( "w" ) ; + type_is_t * _x = motor::shared( type_is_t( T(0) ) ) ; + type_is_t * _y = motor::shared( type_is_t( T(0) ) ) ; + type_is_t * _z = motor::shared( type_is_t( T(0) ) ) ; + type_is_t * _w = motor::shared( type_is_t( T(0) ) ) ; public: variable( char const * const name ) noexcept : base_t( name, motor::shared( in_t() ), motor::shared( out_t() ) ) {} + variable( char const * const name, value_cref_t v ) noexcept : base_t( name, + motor::shared( in_t( v ) ), motor::shared( out_t( v ) ) ), + _x( motor::shared( type_is_t( v.x() ) ) ), + _y( motor::shared( type_is_t( v.y() ) ) ), + _z( motor::shared( type_is_t( v.z() ) ) ), + _w( motor::shared( type_is_t( v.w() ) ) ){} + variable( this_cref_t ) = delete ; - variable( this_rref_t rhv ) noexcept : - base_t( std::move( rhv ) ), - _x( std::move( rhv._x ) ), _y( std::move( rhv._y ) ), - _z( std::move( rhv._z ) ), _w( std::move( rhv._w ) ) {} + variable( this_rref_t rhv ) noexcept : base_t( std::move( rhv ) ) + { + this_t::disconnect_and_clear() ; - virtual ~variable( void_t ) noexcept {} + _x = motor::move( rhv._x ) ; + _y = motor::move( rhv._y ) ; + _z = motor::move( rhv._z ) ; + _w = motor::move( rhv._w ) ; + } + + virtual ~variable( void_t ) noexcept + { + this_t::disconnect_and_clear() ; + } + + void_t disconnect_and_clear( void_t ) noexcept + { + if ( _x != nullptr ) _x->disconnect() ; + if ( _y != nullptr ) _y->disconnect() ; + if ( _z != nullptr ) _z->disconnect() ; + if ( _w != nullptr ) _w->disconnect() ; + motor::release( motor::move( _x ) ) ; + motor::release( motor::move( _y ) ) ; + motor::release( motor::move( _z ) ) ; + motor::release( motor::move( _w ) ) ; + } public: @@ -258,17 +330,36 @@ namespace motor return true ; } else if ( motor::math::vec4b_t( - _x.update(), _y.update(), _z.update(), _w.update() ).any() ) + _x->has_changed(), _y->has_changed(), _z->has_changed(), _w->has_changed() ).any() ) { - value_t const v ( _x.get_value(), _y.get_value(), _z.get_value(), , _w.get_value() ) ; + value_t const v ( + _x->get_value_and_reset(), + _y->get_value_and_reset(), + _z->get_value_and_reset(), + _w->get_value_and_reset() ) ; + in_->set_value( v ) ; - *out_ = v ; + out_->set_and_exchange( v ) ; return true ; } return false ; } + virtual motor::wire::inputs_t inputs( void_t ) noexcept + { + motor::string_t const name = base_t::sname() ; + + return motor::wire::inputs_t( + { + { name, base_t::get_is() }, + { name + ".x", motor::share( _x ) }, + { name + ".y", motor::share( _y ) }, + { name + ".z", motor::share( _z ) }, + { name + ".w", motor::share( _w ) } + }, false ) ; + } + value_cref_t get_value( void_t ) const noexcept { return base_t::borrow_os()->get_value() ; @@ -287,54 +378,23 @@ namespace motor void_t propagate_value_to_sub( value_cref_t v ) noexcept { - _x.set_value( v.x() ) ; - _y.set_value( v.y() ) ; - _z.set_value( v.z() ) ; - _w.set_value( v.w() ) ; - } - - private: - - virtual void_t for_each_member( for_each_funk_t f, motor::wire::any::member_info_in_t ifo ) noexcept - { - f( _x, { ifo.level + 1, ifo.full_name + "." + _x.name() } ) ; - f( _y, { ifo.level + 1, ifo.full_name + "." + _y.name() } ) ; - f( _z, { ifo.level + 1, ifo.full_name + "." + _z.name() } ) ; - f( _w, { ifo.level + 1, ifo.full_name + "." + _w.name() } ) ; + _x->set_value( v.x() ) ; + _y->set_value( v.y() ) ; + _z->set_value( v.z() ) ; + _w->set_value( v.w() ) ; } }; - - template< typename T, typename trait_t > - using vec2v = motor::wire::variable< motor::math::vector2< T >, trait_t > ; - - template< typename T, typename trait_t > - using vec3v = motor::wire::variable< motor::math::vector3< T >, trait_t > ; - - template< typename T, typename trait_t> - using vec4v = motor::wire::variable< motor::math::vector4< T >, trait_t > ; - - motor_typedefs( variable< motor::math::vector2< float_t > motor_comma motor::wire::detailed_trait >, vec2fvd ) ; - motor_typedefs( variable< motor::math::vector3< float_t > motor_comma motor::wire::detailed_trait >, vec3fvd ) ; - motor_typedefs( variable< motor::math::vector4< float_t > motor_comma motor::wire::detailed_trait >, vec4fvd ) ; - - motor_typedefs( variable< motor::math::vector2< int_t > motor_comma motor::wire::detailed_trait >, vec2ivd ) ; - motor_typedefs( variable< motor::math::vector3< int_t > motor_comma motor::wire::detailed_trait >, vec3ivd ) ; - motor_typedefs( variable< motor::math::vector4< int_t > motor_comma motor::wire::detailed_trait >, vec4ivd ) ; - - motor_typedefs( variable< motor::math::vector2< uint_t > motor_comma motor::wire::detailed_trait >, vec2uivd ) ; - motor_typedefs( variable< motor::math::vector3< uint_t > motor_comma motor::wire::detailed_trait >, vec3uivd ) ; - motor_typedefs( variable< motor::math::vector4< uint_t > motor_comma motor::wire::detailed_trait >, vec4uivd ) ; - - motor_typedefs( variable< motor::math::vector2< float_t > motor_comma motor::wire::simple_trait >, vec2fv ) ; - motor_typedefs( variable< motor::math::vector3< float_t > motor_comma motor::wire::simple_trait >, vec3fv ) ; - motor_typedefs( variable< motor::math::vector4< float_t > motor_comma motor::wire::simple_trait >, vec4fv ) ; - - motor_typedefs( variable< motor::math::vector2< int_t > motor_comma motor::wire::simple_trait >, vec2iv ) ; - motor_typedefs( variable< motor::math::vector3< int_t > motor_comma motor::wire::simple_trait >, vec3iv ) ; - motor_typedefs( variable< motor::math::vector4< int_t > motor_comma motor::wire::simple_trait >, vec4iv ) ; - - motor_typedefs( variable< motor::math::vector2< uint_t > motor_comma motor::wire::simple_trait >, vec2uiv ) ; - motor_typedefs( variable< motor::math::vector3< uint_t > motor_comma motor::wire::simple_trait >, vec3uiv ) ; - motor_typedefs( variable< motor::math::vector4< uint_t > motor_comma motor::wire::simple_trait >, vec4uiv ) ; + + motor_typedefs( variable< motor::math::vector2< float_t > >, vec2fv ) ; + motor_typedefs( variable< motor::math::vector3< float_t > >, vec3fv ) ; + motor_typedefs( variable< motor::math::vector4< float_t > >, vec4fv ) ; + + motor_typedefs( variable< motor::math::vector2< int_t > >, vec2iv ) ; + motor_typedefs( variable< motor::math::vector3< int_t > >, vec3iv ) ; + motor_typedefs( variable< motor::math::vector4< int_t > >, vec4iv ) ; + + motor_typedefs( variable< motor::math::vector2< uint_t > >, vec2uiv ) ; + motor_typedefs( variable< motor::math::vector3< uint_t > >, vec3uiv ) ; + motor_typedefs( variable< motor::math::vector4< uint_t > >, vec4uiv ) ; } } \ No newline at end of file