ClientMarker.cpp
Go to the documentation of this file.
1 #include "ClientMarker.hpp"
2 
3 #include "../DebugView/DebugView.hpp"
4 #include "../DebugView/TreeDebugView.hpp"
5 #include "../DebugView/ToText_TableDebugView.hpp"
6 
7 namespace iv
8 {
9 
10 //--------------------- ClientMarkerIds --------------------------------------------
11 std::unordered_map< std::string, unsigned > * ClientMarkerIds::Index;
12 
13 unsigned ClientMarkerIds::UniqueId( std::string name )
14 {
15  if( !Index )
16  Index = new std::unordered_map< std::string, unsigned >;
17  auto & index = *Index;
18 
19  return index[ name ]++;
20 }
21 
22 //--------------------- ClientMarker -----------------------------------------------
24 {
25  if( this->inst )
26  this->inst->client_unregister( this );
27 }
28 
29 std::string const & ClientMarker::name() const
30 {
31  return this->_name;
32 }
33 
34 unsigned ClientMarker::marker_id() const
35 {
36  return this->_marker_id;
37 }
38 
39 std::type_index ClientMarker::client_type() const
40 {
41  return this->_client_type;
42 }
43 
44 std::type_index ClientMarker::type() const
45 {
46  return this->_client_type;
47 }
48 
50 {
51  return this->inst;
52 }
53 
55 {
56  if( this->inh_child )
57  return this->inh_child->inheritance_root();
58  else
59  return this;
60 }
61 
63 {
64  return this->inh_child;
65 }
66 
67 std::unordered_set< ClientMarker const * > ClientMarker::inheritance_parents() const
68 {
69  return this->inh_parents;
70 }
71 
73 {
74  if( this->inh_child )
75  return this->inh_child->relation_root();
76  else if( this->own_parent )
77  return this->own_parent->relation_root();
78  else
79  return this;
80 }
81 
83 {
84  return this->own_parent;
85 }
86 
87 std::unordered_set< ClientMarker const * > ClientMarker::ownership_children() const
88 {
89  return this->own_children;
90 }
91 
93 {
94  if( this->status_printer_w )
95  this->status_printer_w( this->_client_ptr, view );
96 }
97 
99 {
100  ToText_TableDebugView table( view->context() );
101  this->print_status( &table );
102 
103  view->prefix_push( " " );
104  view->postfix_push( " " );
105  table.Write_AsLines( view, false );
106  view->postfix_pop();
107  view->prefix_pop();
108 }
109 
111 {
112  TreeDebugView tree( view->context() );
113  this->print_status_with_inherited( &tree, emphasize );
115 }
116 
118 {
119  auto style = TreeDebugView::BoxStyle::Dotted;
120  if( this == emphasize )
122 
123  //
124  view->Push( this->name_id().c_str(), style );
125 
126  // print own content
127  this->print_status( view );
128 
129  // print inherited ClientMarkers
130  for( ClientMarker const * parent : this->inheritance_parents() )
131  {
132  parent->print_status_with_inherited( (TreeDebugView*)view, emphasize );
133  }
134 
135  view->Pop();
136 }
137 
139 {
140  TreeDebugView tree( view->context() );
141  this->print_status_with_related( &tree );
143 }
144 
146 {
147  view->Push( this->name_id().c_str(), box_style );
148 
149  {
150  // print own content
151  this->print_status( view );
152 
153  // print inherited ClientMarkers
154  for( ClientMarker const * parent : this->inheritance_parents() )
155  parent->print_status_with_related( (TreeDebugView*)view, TreeDebugView::BoxStyle::Dotted );
156 
157  // print owned ClientMarkers
158  for( ClientMarker const * owned : this->ownership_children() )
159  owned->print_status_with_related( (TreeDebugView*)view, TreeDebugView::BoxStyle::Solid );
160  }
161 
162  view->Pop();
163 }
164 
165 std::string ClientMarker::name_id() const
166 {
167  return SS() << this->name() << ":" << this->marker_id() << SS::str();
168 }
169 
170 std::string ClientMarker::root_name_id() const
171 {
172  return this->inheritance_root()->name_id();
173 }
174 
176 {
177  return this->inst->client_log_enabled( this, id );
178 }
179 
180 void ClientMarker::log_process( SrcInfo const & info, LogId id, std::string const & message ) const
181 {
182  this->inst->client_log( this, info, id, message );
183 }
184 
185 }