Toggle navigation
ivorium
iv_components
Example project
GitHub
Main Page
Modules
Classes
Files
File List
File Members
ivorium_core
Attribute
Attributes
DirtyAttr.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
Local_AEP.hpp
"
4
#include "../Attribute.hpp"
5
6
namespace
iv
7
{
8
13
template
<
class
T >
14
class
DirtyAttr_I
:
public
Attr
< T >
15
{
16
public
:
17
DirtyAttr_I
(
ClientMarker
*,
AttributeEventProcessor
*, T
const
& initial_value = T() );
18
bool
operator<
(
DirtyAttr_I< T >
const
& right )
const
;
19
22
bool
dirty
()
const
;
23
27
bool
clear_dirty
();
28
32
void
Set
( T
const
& );
33
34
private
:
35
// Attribute_RW
36
virtual
void
GetSourceValue( T & out )
const
override
final
;
37
virtual
void
ModifySource( T
const
& )
override
final
;
38
39
private
:
40
T _value;
41
bool
_dirty;
42
};
43
46
template
<
class
T >
47
class
DirtyAttr
final :
private
Local_AEP
,
public
DirtyAttr_I
< T >
48
{
49
public
:
50
DirtyAttr
(
ClientMarker
*, T
const
& initial_value = T() );
51
~DirtyAttr
();
52
};
53
54
55
template
<
class
T >
56
struct
StringIO
<
DirtyAttr_I
< T > >
57
{
58
DirtyAttr_I< T >
Read
(
const
char
* name,
Context
const
* context )
59
{
60
return
DirtyAttr_I< T >
(
StringIO< T >
().
Read
( name, context ) );
61
}
62
63
std::string
Write
(
DirtyAttr_I< T >
const
& value,
Context
const
* context )
const
64
{
65
auto
result =
StringIO< T >
().
Write
( value.
Get
(), context );
66
if
( value.
dirty
() )
67
result +=
" (dirty)"
;
68
return
result;
69
}
70
};
71
72
}
73
74
#include "
DirtyAttr.inl
"