VR-Forces 4.2 Class Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Behavior Models
File List
File Members
include
vrfutil
readerWriterFactory.h
Go to the documentation of this file.
1
/*******************************************************************************
2
** Copyright (c) 2007 MAK Technologies, Inc.
3
** All rights reserved.
4
*******************************************************************************/
5
8
10
11
#pragma once
12
13
#include "
vrfutil/vrfutilDefines.h
"
14
#include <map>
15
#include <vlutil/vlString.h>
16
#include "
vrfutil/bufferSerialize.h
"
17
18
19
class
DtReaderWriterRegistry
;
20
class
DtReaderWriter
;
21
33
class
DT_DLL_vrfutil
DtReaderWriterFactory
34
{
35
public
:
36
typedef
DtReaderWriter
* (*DtRWCreatorFcn)(
const
DtString
& name,
DtReaderWriterRegistry
* parentRegistry);
37
typedef
void (*DtRWCopyFcn)(
const
DtReaderWriter
* source,
DtReaderWriter
* dest);
38
typedef
int (*DtRwGetSizeFcn)(
const
DtReaderWriter
* source);
39
typedef
bool
(*DtRwCompareFcn)(
const
DtReaderWriter
* lhs,
const
DtReaderWriter
* rhs);
40
typedef
char
* (*DtRwEncodeFcn)(
const
DtReaderWriter
* source,
char
*);
41
typedef
const
char
* (*DtRwDecodeFcn)(
DtReaderWriter
* source,
const
char
*);
42
43
struct
DtRwFunctions
44
{
45
DtRWCreatorFcn
creatorFcn
;
46
DtRwCompareFcn
compareFcn
;
47
DtRWCopyFcn
copyFcn
;
48
DtRwGetSizeFcn
getSizeFcn
;
49
DtRwEncodeFcn
encodeFcn
;
50
DtRwDecodeFcn
decodeFcn
;
51
};
52
53
typedef
std::map<DtString, DtRwFunctions>
DtRwFunctionMap
;
54
55
public
:
56
DtReaderWriterFactory
();
57
61
virtual
DtReaderWriter
* createItem(
const
DtString
& type,
const
DtString
& name,
62
DtReaderWriterRegistry
* parentRegistry)
const
;
63
68
virtual
bool
copyReaderWriter(
const
DtReaderWriter
* sourceRw,
DtReaderWriter
* destRw)
const
;
69
71
virtual
bool
compareReaderWriter(
const
DtReaderWriter
* sourceRw,
const
DtReaderWriter
* destRw)
const
;
72
78
virtual
DtReaderWriter
* cloneReaderWriter(
const
DtString
& name,
79
const
DtReaderWriter
* sourceRw,
DtReaderWriterRegistry
* parentRegistry)
const
;
80
83
void
addDefaultRwCreators();
84
89
template
<
typename
T_RWType>
90
void
registerType(
const
DtString
& rwTypeString);
91
93
template
<
typename
T_RWType>
94
void
registerTypeWithoutSerialization(
const
DtString
& rwTypeString);
95
96
const
DtRwFunctionMap
& functionMap()
const
;
97
99
bool
typeRegistered(
const
DtString
& rwTypeString)
const
;
100
101
virtual
int
getSize
(
const
DtReaderWriter
*)
const
;
102
104
virtual
char
*
encode
(
const
DtReaderWriter
*,
char
*)
const
;
105
107
virtual
const
char
*
decode
(
DtReaderWriter
*,
const
char
*);
108
109
protected
:
112
template
<
typename
T_RWType>
113
static
DtReaderWriter
* createRWType(
const
DtString
& name,
DtReaderWriterRegistry
* parentRegistry);
114
116
template
<
typename
T_RWType>
117
static
void
copyRwType(
const
DtReaderWriter
* sourceRw,
DtReaderWriter
* destRw);
118
120
template
<
typename
T_RWType>
121
static
bool
compareRwType(
const
DtReaderWriter
* sourceRw,
const
DtReaderWriter
* destRw);
122
124
template
<
typename
T_RWType>
125
static
int
getRwSize(
const
DtReaderWriter
* sourceRw);
126
128
template
<
typename
T_RWType>
129
static
char
* encodeRwType(
const
DtReaderWriter
* sourceRw,
char
* buf);
130
132
template
<
typename
T_RWType>
133
static
const
char
* decodeRwType(
DtReaderWriter
* sourceRw,
const
char
* buf);
134
135
protected
:
136
DtRwFunctionMap
myRwFunctionMap
;
137
};
138
139
#define readerWriterFactory_inl_
140
#include "vrfutil/readerWriterFactory.inl"
141
#undef readerWriterFactory_inl_
142
Document ID: Generated on Sun Nov 24 19:49:21 EST 2013 from SVN revision 133924
Copyright © 2005-2013 VT MÄK. All Rights Reserved (
www.mak.com
)