VR-Forces Development_Version Class Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Behavior Models
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
include
vrfutil
propertyInterface.h
Go to the documentation of this file.
1
/*******************************************************************************
2
** Copyright (c) 2013 MAK Technologies, Inc.
3
** All rights reserved.
4
*******************************************************************************/
5
8
9
#pragma once
10
11
#include <
vrfutil/vrfutilDefines.h
>
12
#include <
vrfutil/rwBoolean.h
>
13
#include <
vrfutil/rwString.h
>
14
#include <
vrfutil/rwInt.h
>
15
#include <
vrfutil/rwReal.h
>
16
#include <
vrfutil/readerWriterFactory.h
>
17
#include <vlutil/vlTime.h>
18
19
#include <string>
20
22
class
DT_DLL_vrfutil
DtPropertyInterface
23
{
24
public
:
25
enum
MergeFlags
26
{
27
Replace = 0x00000001,
28
MinimalSimilarityCheck = 0x00000002,
29
RollUp = 0x00000004,
30
31
32
AddMissing = 0x00000008
33
};
34
35
virtual
~DtPropertyInterface
() {};
36
40
virtual
char
*
encode
(
char
*)
const
= 0;
41
43
virtual
const
char
*
decode
(
const
char
*) = 0;
44
46
virtual
void
getSize
(
int
& size)
const
= 0;
47
49
virtual
int
hlaAlignment()
const
= 0;
50
52
virtual
const
char
* propertyType()
const
= 0;
53
54
virtual
DtString
stringRep(
const
DtString
& root =
""
)
const
= 0;
55
56
int
getSize
()
const
57
{
58
int
size = 0;
59
getSize
(size);
60
61
return
size;
62
}
63
67
virtual
DtReaderWriter
* readerWriter() = 0;
68
virtual
const
DtReaderWriter
* readerWriter()
const
= 0;
70
73
virtual
bool
isSimilarProperty(
const
DtPropertyInterface
* rhs)
const
74
{
75
return
(std::string(rhs->
propertyType
()) == std::string(propertyType()));
76
}
77
89
virtual
bool
merge(
const
DtPropertyInterface
& target, MergeFlags,
90
const
DtMergePath
& path =
DtMergePath
(),
const
std::set<DtString>& ignore = std::set<DtString>()) = 0;
91
93
virtual
DtlObjPtr getData(DtlObjPtr args,
const
DtReaderWriter::SearchPaths
& searchPaths,
94
const
DtVariableBindingsList
& variableBindings) = 0;
95
97
virtual
void
reset() = 0;
98
};
99
102
template
<
typename
_RwType>
103
class
DtRwProperty
:
public
_RwType,
public
DtPropertyInterface
104
{
105
private
:
107
DtRwProperty
();
108
109
public
:
110
111
DtRwProperty
(
const
DtString
& name,
DtReaderWriterRegistry
* parentRegistry = 0);
112
DtRwProperty
(
const
DtString
& name,
const
DtRwProperty
& orig,
113
DtReaderWriterRegistry
* parentRegistry = 0);
114
DtRwProperty
&
operator=
(
const
DtRwProperty
& orig);
115
virtual
~DtRwProperty
();
116
120
virtual
char
*
encode
(
char
*)
const
;
121
123
virtual
const
char
*
decode
(
const
char
*);
124
125
virtual
DtString
stringRep
(
const
DtString
& root =
""
)
const
;
126
128
virtual
void
getSize
(
int
& size)
const
;
129
130
virtual
int
hlaAlignment
()
const
;
131
133
virtual
const
char
*
propertyType
()
const
;
134
135
virtual
DtlObjPtr
getData
(DtlObjPtr args,
const
DtReaderWriter::SearchPaths
& searchPaths,
136
const
DtVariableBindingsList
& variableBindings);
137
139
virtual
bool
merge
(
const
DtPropertyInterface
& target,
MergeFlags
,
140
const
DtMergePath
& path =
DtMergePath
(),
const
std::set<DtString>& ignore = std::set<DtString>());
141
144
virtual
DtReaderWriter
*
readerWriter
();
145
virtual
const
DtReaderWriter
*
readerWriter
()
const
;
147
150
virtual
DtPropertyInterface
*
property
();
151
virtual
const
DtPropertyInterface
*
property
()
const
;
153
155
virtual
void
recordUpdateTime
()
const
;
156
158
virtual
bool
wasUpdatedSince
(
DtTime
t)
const
;
159
160
virtual
void
reset
();
161
162
protected
:
163
164
DtClock
myClock
;
165
mutable
DtTime
myUpdateTime
;
166
167
};
168
173
template
<
typename
_RwType>
174
class
DtRwPropertyWithThreshold
:
public
DtRwProperty
<_RwType>
175
{
176
private
:
178
DtRwPropertyWithThreshold
();
179
180
public
:
181
182
DtRwPropertyWithThreshold
(
const
DtString
& name,
DtReaderWriterRegistry
* parentRegistry = 0);
183
DtRwPropertyWithThreshold
(
const
DtString
& name,
const
DtRwPropertyWithThreshold
& orig,
184
DtReaderWriterRegistry
* parentRegistry = 0);
185
DtRwPropertyWithThreshold
&
operator=
(
const
DtRwPropertyWithThreshold
& orig);
186
virtual
~DtRwPropertyWithThreshold
();
187
192
virtual
char
*
encode
(
char
*)
const
;
193
197
virtual
bool
wasUpdatedSince
(
DtTime
t)
const
;
198
200
virtual
void
enableThresholding
(
bool
enable);
201
205
virtual
void
setThreshold
(
double
percentage);
206
209
static
void
setDefaultThreshold
(
double
percentage);
210
215
virtual
void
setMaxUpdateInterval
(
DtTime
interval);
216
219
static
void
setDefaultMaxUpdateInterval
(
DtTime
interval);
220
229
virtual
void
setMaxUnchangedUpdateInterval
(
DtTime
interval);
230
233
static
void
setDefaultMaxUnchangedUpdateInterval
(
DtTime
interval);
234
235
protected
:
236
238
bool
myThresholdingEnabled
;
239
241
mutable
_RwType
myLastEncodedValue
;
242
244
mutable
DtTime
myLastEncodeTime
;
245
246
static
double
myDefaultThreshold
;
247
double
myThreshold
;
248
249
static
DtTime
myDefaultMaxUpdateInterval
;
250
DtTime
myMaxUpdateInterval
;
251
252
static
DtTime
myDefaultMaxUnchangedUpdateInterval
;
253
DtTime
myMaxUnchangedUpdateInterval
;
254
};
255
256
typedef
DtRwProperty<DtRwString>
DtRwPropertyString
;
257
typedef
DtRwPropertyWithThreshold<DtRwInt>
DtRwPropertyInt
;
258
typedef
DtRwProperty<DtRwBoolean>
DtRwPropertyBoolean
;
259
typedef
DtRwPropertyWithThreshold<DtRwReal>
DtRwPropertyReal
;
Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (
www.mak.com
)