VR-Forces 4.3.1 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
};
33
34
virtual
~DtPropertyInterface
() {};
35
39
virtual
char
*
encode
(
char
*)
const
= 0;
40
42
virtual
const
char
*
decode
(
const
char
*) = 0;
43
45
virtual
void
getSize
(
int
& size)
const
= 0;
46
48
virtual
int
hlaAlignment()
const
= 0;
49
51
virtual
const
char
* propertyType()
const
= 0;
52
53
virtual
DtString
stringRep(
const
DtString
& root =
""
)
const
= 0;
54
55
int
getSize
()
const
56
{
57
int
size = 0;
58
getSize
(size);
59
60
return
size;
61
}
62
66
virtual
DtReaderWriter
* readerWriter() = 0;
67
virtual
const
DtReaderWriter
* readerWriter()
const
= 0;
69
72
virtual
bool
isSimilarProperty(
const
DtPropertyInterface
* rhs)
const
73
{
74
return
(std::string(rhs->
propertyType
()) == std::string(propertyType()));
75
}
76
88
virtual
bool
merge(
const
DtPropertyInterface
& target, MergeFlags,
89
const
DtMergePath
& path =
DtMergePath
(),
const
std::set<DtString>& ignore = std::set<DtString>()) = 0;
90
92
virtual
DtlObjPtr getData(DtlObjPtr args,
const
DtReaderWriter::SearchPaths
& searchPaths,
93
const
DtVariableBindingsList
& variableBindings) = 0;
94
96
virtual
void
reset() = 0;
97
};
98
101
template
<
typename
_RwType>
102
class
DtRwProperty
:
public
_RwType,
public
DtPropertyInterface
103
{
104
private
:
106
DtRwProperty
();
107
108
public
:
109
110
DtRwProperty
(
const
DtString
& name,
DtReaderWriterRegistry
* parentRegistry = 0);
111
DtRwProperty
(
const
DtString
& name,
const
DtRwProperty
& orig,
112
DtReaderWriterRegistry
* parentRegistry = 0);
113
DtRwProperty
&
operator=
(
const
DtRwProperty
& orig);
114
virtual
~DtRwProperty
();
115
119
virtual
char
*
encode
(
char
*)
const
;
120
122
virtual
const
char
*
decode
(
const
char
*);
123
124
virtual
DtString
stringRep
(
const
DtString
& root =
""
)
const
;
125
127
virtual
void
getSize
(
int
& size)
const
;
128
129
virtual
int
hlaAlignment
()
const
;
130
132
virtual
const
char
*
propertyType
()
const
;
133
134
virtual
DtlObjPtr
getData
(DtlObjPtr args,
const
DtReaderWriter::SearchPaths
& searchPaths,
135
const
DtVariableBindingsList
& variableBindings);
136
138
virtual
bool
merge
(
const
DtPropertyInterface
& target,
MergeFlags
,
139
const
DtMergePath
& path =
DtMergePath
(),
const
std::set<DtString>& ignore = std::set<DtString>());
140
143
virtual
DtReaderWriter
*
readerWriter
();
144
virtual
const
DtReaderWriter
*
readerWriter
()
const
;
146
149
virtual
DtPropertyInterface
*
property
();
150
virtual
const
DtPropertyInterface
*
property
()
const
;
152
154
virtual
void
recordUpdateTime
()
const
;
155
157
virtual
bool
wasUpdatedSince
(
DtTime
t)
const
;
158
159
virtual
void
reset
();
160
161
protected
:
162
163
DtClock
myClock
;
164
mutable
DtTime
myUpdateTime
;
165
166
};
167
172
template
<
typename
_RwType>
173
class
DtRwPropertyWithThreshold
:
public
DtRwProperty
<_RwType>
174
{
175
private
:
177
DtRwPropertyWithThreshold
();
178
179
public
:
180
181
DtRwPropertyWithThreshold
(
const
DtString
& name,
DtReaderWriterRegistry
* parentRegistry = 0);
182
DtRwPropertyWithThreshold
(
const
DtString
& name,
const
DtRwPropertyWithThreshold
& orig,
183
DtReaderWriterRegistry
* parentRegistry = 0);
184
DtRwPropertyWithThreshold
&
operator=
(
const
DtRwPropertyWithThreshold
& orig);
185
virtual
~DtRwPropertyWithThreshold
();
186
191
virtual
char
*
encode
(
char
*)
const
;
192
196
virtual
bool
wasUpdatedSince
(
DtTime
t)
const
;
197
199
virtual
void
enableThresholding
(
bool
enable);
200
204
virtual
void
setThreshold
(
double
percentage);
205
208
static
void
setDefaultThreshold
(
double
percentage);
209
214
virtual
void
setMaxUpdateInterval
(
DtTime
interval);
215
218
static
void
setDefaultMaxUpdateInterval
(
DtTime
interval);
219
228
virtual
void
setMaxUnchangedUpdateInterval
(
DtTime
interval);
229
232
static
void
setDefaultMaxUnchangedUpdateInterval
(
DtTime
interval);
233
234
protected
:
235
237
bool
myThresholdingEnabled
;
238
240
mutable
_RwType
myLastEncodedValue
;
241
243
mutable
DtTime
myLastEncodeTime
;
244
245
static
double
myDefaultThreshold
;
246
double
myThreshold
;
247
248
static
DtTime
myDefaultMaxUpdateInterval
;
249
DtTime
myMaxUpdateInterval
;
250
251
static
DtTime
myDefaultMaxUnchangedUpdateInterval
;
252
DtTime
myMaxUnchangedUpdateInterval
;
253
};
254
255
typedef
DtRwProperty<DtRwString>
DtRwPropertyString
;
256
typedef
DtRwPropertyWithThreshold<DtRwInt>
DtRwPropertyInt
;
257
typedef
DtRwProperty<DtRwBoolean>
DtRwPropertyBoolean
;
258
typedef
DtRwPropertyWithThreshold<DtRwReal>
DtRwPropertyReal
;
Document ID: Generated on Wed Jul 29 00:55:00 EDT 2015 from SVN revision 155257
Copyright © 2005-2015 VT MÄK. All Rights Reserved (
www.mak.com
)