Attribute.inl
Go to the documentation of this file.
1 namespace iv
2 {
3 
4 template< class T >
5 Attr< T >::Attr( ClientMarker * cm, AttributeEventProcessor * processor, bool allow_ModifyMode ) :
6  Attribute( cm, processor, allow_ModifyMode )
7 {
8 }
9 
10 template< class T >
11 T Attr< T >::Get() const
12 {
13  T result;
14  this->GetSourceValue( result );
15  return result;
16 }
17 
18 template< class T >
19 void Attr< T >::Modify( ClientMarker * modifier, T const & val )
20 {
21  if( this->Mode() != Attribute::ValueMode::ValueModify )
22  {
23  if( this->allow_ModifyMode() )
24  {
25  this->SetAttributeMode( Attribute::ValueMode::ValueModify );
26  }
27  else
28  {
29  this->owner()->warning( SRC_INFO, "Can not modify Attribute value - ValueMode is ", this->Mode(), "." );
30  return;
31  }
32  }
33 
34  this->ModifySource( val );
35 }
36 
37 template< class T >
38 std::type_index Attr< T >::Type_Impl()
39 {
40  return typeid( T );
41 }
42 
43 template< class T >
44 std::any Attr< T >::GetAny_Impl()
45 {
46  return std::any( this->Get() );
47 }
48 
49 template< class T >
50 void Attr< T >::ModifyAny_Impl( ClientMarker * modifier, std::any val )
51 {
52  if( val.type() != typeid( T ) )
53  {
54  this->owner()->warning( SRC_INFO, "Can not modify Attribute with an any value - Attribute type is ", this->Type().name(), " but value type is ", val.type().name(), "." );
55  return;
56  }
57 
58  this->Modify( modifier, std::any_cast< T >( val ) );
59 }
60 
61 }