VR-Forces 4.1 Class Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Behavior Models
File List
File Members
include
gdb
specMgr.h
Go to the documentation of this file.
1
/*******************************************************************************
2
** Copyright (c) 2008 MAK Technologies, Inc.
3
** All rights reserved.
4
*******************************************************************************/
5
/*******************************************************************************
6
** $RCSfile: specMgr.h,v $ $Revision: 1.17 $ $State: Exp $
7
*******************************************************************************/
8
#ifndef specMgr_H_
9
#define specMgr_H_
10
11
//
12
// \file specMgr.h
13
// \brief Contains the DtSpecificationManager class declaration and related functionality.
14
//
15
16
#include "
gdb/gdbDefines.h
"
17
#include <vlutil/vlConfig.h>
18
#include <vector>
19
#include <stdio.h>
20
21
//forward declarations
22
class
DtSpecification
;
23
24
// Make an explicit type for the specification IDs so that we can be sure
25
// we're working with the appropriate identifiers
26
typedef
unsigned
int
DtSpecificationID
;
27
28
//
29
// DtSpecificationManager manages the specifications of the loaded terrain file
30
// for the terrain database.
31
class
DT_DLL_gdb
DtSpecificationManager
32
{
33
public
:
34
35
// default constructor
36
DtSpecificationManager
();
37
38
// additional constructor with number of
39
// specifications to expect to manage
40
DtSpecificationManager
(
unsigned
int
numSpecifications);
41
42
// destructor
43
virtual
~
DtSpecificationManager
();
44
45
// copy constructor
46
DtSpecificationManager
(
const
DtSpecificationManager
& orig);
47
48
// assignment operator
49
DtSpecificationManager
& operator=(
const
DtSpecificationManager
& orig);
50
51
// accessor function
52
// If the specification manager is managing a specification with the
53
// given ID, then this function sets spec to the managed specification
54
// and returns true.
55
// If the specification is not being managed, then the function
56
// returns false
57
virtual
bool
specification(
DtSpecificationID
specID,
58
DtSpecification
& spec)
const
;
59
60
// Returns a reference to the managed specification..
61
// ASSUMES that the ID provided is valid.
62
virtual
DtSpecification
& specification(
DtSpecificationID
specID);
63
virtual
const
DtSpecification
& specification(
DtSpecificationID
specID)
const
;
64
65
// @return The specification ID that will be assigned to the next specification
66
// to be added to the manager. This is useful when planning on associating many
67
// objects with a single specification. The next ID can be gotten, and then used
68
// while the specification is still being modified.
69
//
70
// @note Users must be @b very careful in using this. If the ID is to be used, the
71
// user must ensure that no specifications are added to the manager before
72
// their intended specification is, or the nextID will @b not be the one
73
// previously given.
74
virtual
DtSpecificationID
nextID()
const
;
75
76
77
// Adds a specification to be managed.
78
// If allowDuplicates is true, then the specification manager will add the
79
// specification even if it be considered a duplicate of an existing
80
// managed specification. specID will be set to a new associated
81
// specification ID. If allowDuplicate is false, specID will be set
82
// to the ID of the first specification it finds that passes the equality
83
// criteria. If it doesn't find an equal specification, it adds it as
84
// a new specification and sets specID to the associated ID.
85
// If for some reason, it cannot add the specification at all, it returns
86
// false and leaves specID untouched.
87
virtual
bool
addSpecification(
const
DtSpecification
& specificationToAdd,
88
DtSpecificationID
& specID,
89
bool
allowDuplicates =
true
);
90
91
// Analyzes the managed specifications and removes multiple instances of
92
// the same specification. All duplicate specifications will be collapsed
93
// and mapped to one specification ID. If the manager cannot remove the
94
// duplicates for any reason, it returns false.
95
// Otherwise, it removes the duplicates and sets oldIDToNewIDMapping[OldID]
96
// to be a the new specification ID that is associated with the original
97
// ID's specification. This function guarantees that all original IDs will
98
// be valid indices into the oldIDToNewIDMapping. The caller is responsible
99
// for deleting the memory allocated by this function for
100
// oldIDToNewIDMapping. (use delete[]).
101
virtual
bool
removeDuplicates(
int
& numDuplicates,
102
int
& numEntries,
103
DtSpecificationID
* oldIDToNewIDMapping);
104
105
// \return A boolean indicating whether or not a specification like the specified
106
// one already exists in the manager. If so, the function returns true and
107
// the specID parameter is set to that specification's ID. Otherwise, false
108
// is returned.
109
//
110
// @note A specification is "like" another if the spec is a superset of the
111
// other specified specification.
112
virtual
bool
aSpecificationLike(
const
DtSpecification
& specification,
113
DtSpecificationID
& specID)
const
;
114
115
// Function to merge the contents of another specification manager
116
// with this manager. Creates copies of all the specifications in the manager to merge
117
// in this manager.
118
// \param specMgrToMerge A reference to a constant specification manager to merge in.
119
// \param specificationIDMap A reference to a pointer to a specificationID. This will
120
// be allocated by the function and returned to the user who
121
// will be responsible for deleting the memory when appropriate.
122
// This array will contain the new specificationIDs mapped by the
123
// old specification IDs. i.e. map[oldID] = newID.
124
//
125
// \return True if the merging is successful.
126
// \return False otherwise
127
virtual
bool
merge(
const
DtSpecificationManager
& specMgrToMerge,
128
DtSpecificationID
*& specificationIDMap);
129
130
// Returns the current number of specifications managed
131
virtual
unsigned
int
numberOfSpecifications()
const
;
132
133
// Determines if a given specification ID is valid. Returns true if the
134
// ID is associated with a managed specification and false if it doesn't.
135
virtual
bool
isValidID(
DtSpecificationID
specID)
const
;
136
137
// debugging aid
138
virtual
void
dump()
const
;
139
140
// dumps the specification manager's content into a text file so it can be
141
// viewed graphically using GraphViz.
142
virtual
void
dump(FILE* fp)
const
;
143
144
virtual
int
sizeInBytes()
const
;
145
146
protected
:
147
// tests the invariants of the class.
148
// Should be called first in every const public member
149
// function and both first and last in every other function
150
bool
testInvariant()
const
;
151
152
// Adds the surface and sets surfID to be the
153
// associated surfID. If it fails to add the surface - most likely
154
// a memory issue - it returns false.
155
bool
addNewSpecification(
const
DtSpecification
& specificationToAdd,
156
DtSpecificationID
& specID);
157
158
// Looks for a duplicate surface of the specified surface
159
// in the managed surfaces. If it finds one, it returns true
160
// and sets managedSurfID to the associated surfID. If not,
161
// it returns false and leaves managedSurfID untouched.
162
bool
isDuplicate(
const
DtSpecification
& specification,
163
DtSpecificationID
& managedSpecID)
const
;
164
165
// Dynamically allocated array of Specifications.
166
std::vector<DtSpecification>
mySpecifications
;
167
};
168
169
#endif
170
Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (
www.mak.com
)