-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ac9a57
commit 4871aec
Showing
14 changed files
with
205 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
|
||
#pragma once | ||
|
||
|
||
#include "icomponent.h" | ||
|
||
#include "../global.h" | ||
|
||
namespace motor | ||
{ | ||
namespace scene | ||
{ | ||
class variables_component : public motor::scene::icomponent | ||
{ | ||
typedef icomponent base_t ; | ||
motor_this_typedefs( variables_component ) ; | ||
|
||
public: | ||
|
||
|
||
}; | ||
motor_typedef( variables_component ) ; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
|
||
#pragma once | ||
|
||
#include "api.h" | ||
#include "double_dispatch.h" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
#include "variable_update_visitor.h" | ||
|
||
#include "../component/variables_component.hpp" | ||
#include "../node/node.h" | ||
|
||
using namespace motor::scene ; | ||
|
||
motor_core_dd_id_init( variable_update_visitor ) ; | ||
|
||
//************************************************************************************************* | ||
variable_update_visitor::variable_update_visitor( void_t ) noexcept | ||
{ | ||
} | ||
|
||
//************************************************************************************************* | ||
variable_update_visitor::~variable_update_visitor( void_t ) noexcept | ||
{ | ||
} | ||
|
||
//************************************************************************************************* | ||
motor::scene::result variable_update_visitor::visit( motor::scene::ivisitable_ptr_t vable ) noexcept | ||
{ | ||
if( auto * n = dynamic_cast< motor::scene::node_ptr_t >( vable ); n != nullptr ) | ||
{ | ||
auto * comp = n->borrow_component< motor::scene::variables_component_t >() ; | ||
// make stuff with variables | ||
|
||
return motor::scene::result::ok ; | ||
} | ||
|
||
//variables_component_ptr_t | ||
return motor::scene::result::ok ; | ||
} | ||
|
||
//************************************************************************************************* | ||
motor::scene::result variable_update_visitor::post_visit( motor::scene::ivisitable_ptr_t, motor::scene::result const ) noexcept | ||
{ | ||
return motor::scene::result::ok ; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
#pragma once | ||
|
||
#include "ivisitor.h" | ||
|
||
namespace motor | ||
{ | ||
namespace scene | ||
{ | ||
class MOTOR_SCENE_API variable_update_visitor : public ivisitor | ||
{ | ||
motor_this_typedefs( variable_update_visitor ) ; | ||
motor_core_dd_id_fn() ; | ||
|
||
public: | ||
|
||
variable_update_visitor( void_t ) noexcept ; | ||
virtual ~variable_update_visitor( void_t ) noexcept ; | ||
|
||
public: | ||
|
||
|
||
|
||
virtual motor::scene::result visit( motor::scene::ivisitable_ptr_t ) noexcept ; | ||
virtual motor::scene::result post_visit( motor::scene::ivisitable_ptr_t, motor::scene::result const ) noexcept ; | ||
}; | ||
motor_typedef( variable_update_visitor ) ; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
|
||
#pragma once | ||
|
||
#include "../api.h" | ||
#include "../typedefs.h" | ||
#include "../variable.hpp" | ||
|
||
#include <motor/std/vector> | ||
|
||
namespace motor | ||
{ | ||
namespace wire | ||
{ | ||
class MOTOR_WIRE_API variable_set | ||
{ | ||
motor_this_typedefs( variable_set ) ; | ||
|
||
public: | ||
|
||
using pull_data_funk_t = std::function< void_t ( void_ptr_t, motor::wire::any_ptr_t ) > ; | ||
|
||
private: | ||
|
||
struct per_var_data | ||
{ | ||
pull_data_funk_t funk ; | ||
motor::wire::any_mtr_t var ; | ||
}; | ||
motor::vector< this_t::per_var_data > _variables ; | ||
|
||
public: | ||
|
||
variable_set( void_t ) noexcept {} | ||
|
||
variable_set( this_rref_t rhv ) noexcept : | ||
_variables( std::move( rhv._variables ) ){} | ||
|
||
variable_set( this_cref_t ) = delete ; | ||
|
||
~variable_set( void_t ) noexcept | ||
{ | ||
for( auto & d : _variables ) motor::release( motor::move( d.var ) ) ; | ||
} | ||
|
||
public: | ||
|
||
using for_each_variable_funk_t = std::function< void_t ( motor::wire::any_mtr_t ) > ; | ||
|
||
void_t for_each( for_each_variable_funk_t funk ) noexcept | ||
{ | ||
for( auto & d : _variables ) | ||
{ | ||
funk( d.var ) ; | ||
} | ||
} | ||
|
||
// call the pull function for each variable | ||
template< typename T > | ||
void_t pull_from_each( T * owner ) noexcept | ||
{ | ||
for( auto & d : _variables ) | ||
{ | ||
d.funk( reinterpret_cast< void_ptr_t >( owner ), d.var ) ; | ||
} | ||
} | ||
|
||
public: | ||
|
||
// add a variable which should interface with some other variable | ||
// the pull function allows to "pull" the data from the any variable | ||
// and update the other variable which is not interfaceable. | ||
void_t add_variable( pull_data_funk_t funk, motor::wire::any_mtr_safe_t v ) noexcept | ||
{ | ||
for( auto & d : _variables ) | ||
if( d.var == v ) | ||
{ | ||
motor::release( v ) ; | ||
return ; | ||
} | ||
|
||
_variables.emplace_back( this_t::per_var_data { funk, motor::move( v ) } ) ; | ||
} | ||
}; | ||
} | ||
} |