Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "cl_application.h"
- #include <windows.h>
- cl_application :: cl_application()
- {
- set_object_name ( "root" );
- set_state ( 1 );
- }
- void cl_application :: bild_tree_objects ( )
- {
- ob_1.set_object_name ( "ob_1" );
- ob_1.set_parent ( this );
- ob_3.set_object_name ( "ob_3" );
- ob_3.set_parent ( this );
- ob_7.set_object_name ( "ob_7" );
- ob_7.set_parent ( this );
- ob_2.set_object_name ( "ob_2" );
- ob_2.set_parent ( & ob_3 );
- ob_4.set_object_name ( "ob_4" );
- ob_4.set_parent ( & ob_1 );
- ob_5.set_object_name ( "ob_5" );
- ob_5.set_parent ( & ob_4 );
- ob_6.set_object_name ( "ob_6" );
- ob_6.set_parent ( & ob_7 );
- ob_8.set_object_name ( "ob_8" );
- ob_8.set_parent ( & ob_7 );
- ob_9.set_object_name("ob_9");
- ob_9.set_parent(&ob_2);
- ob_10.set_object_name ("ob_10");
- ob_10.set_parent (&ob_6);
- }
- int cl_application :: exec_app ( )
- {
- show_object_state();
- return 0;
- }
- void cl_application :: show_object_state ( )
- {
- cout<<get_object("/root/ob_1/ob_4/ob_5") -> get_object_name() << endl;
- cout<<get_object("/root/ob_3/ob_2/ob_9") -> get_object_name()<<endl;
- cout<<get_object("/root/ob_7/ob_6/ob_10") -> get_object_name()<<endl;
- cout<<get_object("/root/ob_7/ob_8") -> get_object_name()<<endl;
- cout<<endl;
- show_tree (this);
- cout<< endl;
- }
- void cl_application :: show_state_next ( cl_base * ob_parent )
- {
- if ( ob_parent -> get_state ( ) == 1 ) {
- cout << "The object " << ob_parent -> get_object_name () << " is ready" << endl;
- }
- else {
- cout << "The object " << ob_parent -> get_object_name () << " is not ready" << endl;
- }
- if ( ob_parent -> children.size ( ) == 0 ) {return;}
- ob_parent -> it_child = ob_parent -> children.begin ( );
- while ( ob_parent -> it_child != ob_parent -> children.end ( ) ) {
- show_state_next ( ( * ( ob_parent -> it_child ) ) );
- ob_parent -> it_child ++;
- }
- }
- void cl_application :: rebild_objects ( )
- {
- ob_2.delete_child ( "ob_4" );
- ob_4.set_parent ( & ob_3 );
- ob_4.set_state ( 0 );
- }
- void cl_application :: show_tree_state ( )
- {
- show_tree(this);
- }
- void cl_application :: show_tree ( cl_base *ob_parent )
- {
- for (int i=0; i < get_level();i++) { cout << " ";}
- cout << ob_parent -> get_object_name () << endl;
- if ( ob_parent -> children.size() == 0 ) {return;}
- ob_parent -> it_child = ob_parent -> children.begin ( );
- change_level('+');
- while ( ob_parent -> it_child != ob_parent -> children.end ( ) )
- {
- show_tree ( ( * ( ob_parent -> it_child ) ) );
- ob_parent -> it_child ++;
- }
- change_level('-');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement