Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. #include "cl_application.h"
  2. #include <windows.h>
  3.  
  4.  
  5. cl_application :: cl_application()
  6. {
  7. set_object_name ( "root" );
  8. set_state ( 1 );
  9. }
  10. void cl_application :: bild_tree_objects ( )
  11. {
  12. ob_1.set_object_name ( "ob_1" );
  13. ob_1.set_parent ( this );
  14. ob_3.set_object_name ( "ob_3" );
  15. ob_3.set_parent ( this );
  16. ob_7.set_object_name ( "ob_7" );
  17. ob_7.set_parent ( this );
  18.  
  19. ob_2.set_object_name ( "ob_2" );
  20. ob_2.set_parent ( & ob_3 );
  21. ob_4.set_object_name ( "ob_4" );
  22. ob_4.set_parent ( & ob_1 );
  23.  
  24. ob_5.set_object_name ( "ob_5" );
  25. ob_5.set_parent ( & ob_4 );
  26. ob_6.set_object_name ( "ob_6" );
  27. ob_6.set_parent ( & ob_7 );
  28.  
  29.  
  30. ob_8.set_object_name ( "ob_8" );
  31. ob_8.set_parent ( & ob_7 );
  32.  
  33.  
  34. ob_9.set_object_name("ob_9");
  35. ob_9.set_parent(&ob_2);
  36. ob_10.set_object_name ("ob_10");
  37. ob_10.set_parent (&ob_6);
  38. }
  39. int cl_application :: exec_app ( )
  40. {
  41. show_object_state();
  42.  
  43. return 0;
  44. }
  45. void cl_application :: show_object_state ( )
  46. {
  47. cout<<get_object("/root/ob_1/ob_4/ob_5") -> get_object_name() << endl;
  48. cout<<get_object("/root/ob_3/ob_2/ob_9") -> get_object_name()<<endl;
  49. cout<<get_object("/root/ob_7/ob_6/ob_10") -> get_object_name()<<endl;
  50. cout<<get_object("/root/ob_7/ob_8") -> get_object_name()<<endl;
  51. cout<<endl;
  52. show_tree (this);
  53.  
  54. cout<< endl;
  55. }
  56. void cl_application :: show_state_next ( cl_base * ob_parent )
  57. {
  58. if ( ob_parent -> get_state ( ) == 1 ) {
  59. cout << "The object " << ob_parent -> get_object_name () << " is ready" << endl;
  60. }
  61. else {
  62. cout << "The object " << ob_parent -> get_object_name () << " is not ready" << endl;
  63. }
  64. if ( ob_parent -> children.size ( ) == 0 ) {return;}
  65.  
  66. ob_parent -> it_child = ob_parent -> children.begin ( );
  67. while ( ob_parent -> it_child != ob_parent -> children.end ( ) ) {
  68. show_state_next ( ( * ( ob_parent -> it_child ) ) );
  69. ob_parent -> it_child ++;
  70. }
  71. }
  72.  
  73. void cl_application :: rebild_objects ( )
  74. {
  75. ob_2.delete_child ( "ob_4" );
  76. ob_4.set_parent ( & ob_3 );
  77. ob_4.set_state ( 0 );
  78. }
  79.  
  80. void cl_application :: show_tree_state ( )
  81. {
  82. show_tree(this);
  83. }
  84.  
  85.  
  86. void cl_application :: show_tree ( cl_base *ob_parent )
  87. {
  88.  
  89. for (int i=0; i < get_level();i++) { cout << " ";}
  90. cout << ob_parent -> get_object_name () << endl;
  91. if ( ob_parent -> children.size() == 0 ) {return;}
  92. ob_parent -> it_child = ob_parent -> children.begin ( );
  93. change_level('+');
  94. while ( ob_parent -> it_child != ob_parent -> children.end ( ) )
  95. {
  96. show_tree ( ( * ( ob_parent -> it_child ) ) );
  97. ob_parent -> it_child ++;
  98. }
  99. change_level('-');
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement