ClientMarker.inl
Go to the documentation of this file.
1 namespace iv
2 {
3 
4 template< class ClientType >
5 ClientMarker::ClientMarker( Instance * inst, ClientType * client, const char * name ) :
6  inst( inst ),
7  _name( name ),
8  _client_ptr( reinterpret_cast< void * >( client ) ),
9  _client_type( typeid( ClientType ) ),
10  _marker_id( ClientMarkerIds::UniqueId( name ) ),
11  status_printer_w( nullptr ),
12  inh_child( nullptr ),
13  own_parent( nullptr )
14 {
15  // register to instance
16  this->inst->client_register( this );
17 }
18 
19 template< class ClientType >
20 ClientMarker::ClientMarker( Instance * inst, ClientType * client, const char * name, Status ) :
21  inst( inst ),
22  _name( name ),
23  _client_ptr( reinterpret_cast< void * >( client ) ),
24  _client_type( typeid( ClientType ) ),
25  _marker_id( ClientMarkerIds::UniqueId( name ) ),
26  status_printer_w( &ClientMarker::StatusPrinterWImpl< ClientType > ),
27  inh_child( nullptr ),
28  own_parent( nullptr )
29 {
30  // register to instance
31  this->inst->client_register( this );
32 }
33 
34 template< class ClientType >
35 void ClientMarker::StatusPrinterWImpl( void * client_ptr, TableDebugView * view )
36 {
37  ClientType * client_ptr_T = reinterpret_cast< ClientType * >( client_ptr );
38  client_ptr_T->status( view );
39 }
40 
41 template< class TypedClient >
42 TypedClient * ClientMarker::client() const
43 {
44  if( this->_client_type == typeid( TypedClient ) )
45  return reinterpret_cast< TypedClient * >( this->_client_ptr );
46  else
47  return nullptr;
48 }
49 
50 template< class ... Rest >
51 void ClientMarker::inherits( ClientMarker & parent, Rest & ... rest )
52 {
53  if( parent.instance() != this->instance() )
54  {
55  this->warning( SRC_INFO, "ClientMarkers from different instances can not inherit each other." );
56  return;
57  }
58 
59  this->inh_parents.insert( &parent );
60  parent.inh_child = this;
61  this->inherits( rest... );
62 }
63 
64 template< class ... Rest >
65 void ClientMarker::owns( ClientMarker & parent, Rest & ... rest )
66 {
67  if( parent.instance() != this->instance() )
68  {
69  this->warning( SRC_INFO, "ClientMarkers from different instances can not inherit each other." );
70  return;
71  }
72 
73  this->own_children.insert( &parent );
74  parent.own_parent = this;
75  this->owns( rest... );
76 }
77 
78 }