VR-Forces 4.2 Class Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Behavior Models
File List
File Members
examples
extendStateRepository
derivedSRUserExt.h
Go to the documentation of this file.
1
/*******************************************************************************
2
** Copyright (c) 2005 MAK Technologies, Inc.
3
** All rights reserved.
4
*******************************************************************************/
5
/*******************************************************************************
6
** $RCSfile: derivedSRUserExt.h,v $ $Revision: 1.4 $ $State: Exp $
7
*******************************************************************************/
8
9
#ifndef DerivedSRUserExtension_H_
10
#define DerivedSRUserExtension_H_
11
12
#include "
vrfobjparam/vrfSRUserExt.h
"
13
#include "
vrfutil/rwString.h
"
14
15
//class DerivedSRUserExtension:
16
//
17
//Instances of DerivedSRUserExtension are an example of an extension to
18
//a base state repository class. It provides a way to extend an entity's state
19
//information independent at a lower level in the state repository hierarchy.
20
//All entities in VR-Forces have at a minimum a DtVrfObjectStateRepsitory, which
21
//can be extended in this way. By extending a state repository through the
22
//DtVrfStateRepostioryUserExtension class, you don't have to extend multiple
23
//leaf-level state repository classes to add the same kind of extension
24
//to different kinds of entities (e.g. ground vehicles and air entities, both
25
//of which have different derived state repository classes).
26
//
27
//A state repository extension object (DtVrfStateRepositoryUserExtension) can be
28
//initialized from a parameter database, and then saved/restored as part of an
29
//entity's state in an order of battle file.
30
//
31
//This example of a user-defined state repository extensions class contains a
32
//single new data member, myTag (a new kind of identifier). The myTag member
33
//variable is a readable, writeable string (DtRwString). myTag is registered
34
//with the name "my-tag" in this class' constructor.
35
//
36
//The class returns a new type string "my-state-repository-user-extension".
37
//This is the key that gets registered with the factory so VR-Forces will
38
//know how to create an instance of this class when it encounters it in
39
//a parameter database file. The configuration of an instance of this type of
40
//state repository extension in a parameter database file (an .ope file) would
41
//look something like this:
42
//
43
//(state-repository-extension-type "my-state-repository-user-extension")
44
//(user-extension
45
// (my-tag "some-useful-info")
46
//)
47
//
48
//At runtime, you can access the state repository extension through the
49
//entity's state repository member, e.g.
50
//
51
//DtVrfObject* entity;
52
//DerivedSRUserExtension* userSRExtension =
53
//dynamic_cast<DerivedSRUserExtension*>(entity->vrfState()->userExtension());
54
55
class
DerivedSRUserExtension
:
public
DtVrfStateRepositoryUserExtension
56
{
57
public
:
58
59
//constructor
60
DerivedSRUserExtension
(
DtVrfObjectStateRepository
*
stateRepository
,
61
const
DtString
& rwName = DtString::nullString(),
62
DtReaderWriterRegistry
* parentRegistry = 0);
63
64
//copy constructor
65
DerivedSRUserExtension
(
DtVrfObjectStateRepository
* stateRepository,
66
const
DerivedSRUserExtension
& orig,
67
const
DtString
& rwName = DtString::nullString(),
68
DtReaderWriterRegistry
* parentRegistry = 0);
69
70
//assignment
71
const
DerivedSRUserExtension
&
operator=
(
72
const
DerivedSRUserExtension
& orig);
73
74
//destructor
75
virtual
~DerivedSRUserExtension
();
76
77
//Note you must implement the clone function in derived classes to ensure
78
//that this data is initialized from the parameter database correctly.
79
virtual
DtVrfStateRepositoryUserExtension
*
clone
(
80
DtVrfObjectStateRepository
* stateRepository,
81
const
DtString
&
name
,
82
DtReaderWriterRegistry
* parentRegistry = NULL)
const
;
83
84
//Type of extension object to create. Existing type(s) are defined in
85
//derivedSRUserExtTypes.h. Our new class returns the string
86
//"my-state-repository-user-extension". This is the string that must be
87
//registered with the factory that creates these objects, and specified in
88
//in the parameter database file when we want one of these classes instantiated.
89
virtual
DtString
type
()
const
;
90
91
//Called after object has been created by the DtVrfObjectStateRepository class.
92
virtual
void
init
();
93
94
//Specific user data extensions. In this case, its a readable writeable string
95
//with the DtReaderWriter name 'my-tag'.
96
virtual
void
setTag
(
const
DtString
&
tag
);
97
virtual
const
DtString
&
tag
()
const
;
98
99
//Returns newly created instance of this class.
100
static
DtVrfStateRepositoryUserExtension
*
create
(
101
DtVrfObjectStateRepository
* stateRepository,
102
const
DtString
& rwName = DtString::nullString(),
103
DtReaderWriterRegistry
* parentRegistry = 0);
104
105
protected
:
106
107
DtRwString
myTag
;
108
};
109
110
#endif
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
)