VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
simResource.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2024 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
9 
12 
13 #pragma once
14 #include <vrfutil/vrfutilDefines.h>
15 #include <vrfutil/rwEntityType.h>
17 #include <readerWriter/rwReal.h>
18 #include <readerWriter/rwInt.h>
19 #include <readerWriter/rwBoolean.h>
20 
22 
25 class DtSimResourceFactory;
26 
33 {
34 
35 public:
36 
38  {
39  public:
41  virtual ~RwMunitionOrEntityType() override;
42 
43  virtual void getSelf(DtlObjPtr args,
44  const DtReaderWriter::SearchPaths& searchPaths = SearchPaths(),
45  const DtVariableBindingsList& variableBindings = nullVariableReference()) override;
46 
47  DtEntityType& operator=(const DtEntityType& t) { return DtRwEntityType::operator=(t); };
48 
49  void setAmmunitionName(const DtString& s) { myAmmunitionName = s; };
50 
51  protected:
52  DtString myAmmunitionName;
53  };
54 
56  DtSimResource();
57 
62  DtSimResource(const DtString& resourceName, DtReaderWriterRegistry*
63  parentRegistry = NULL);
64 
66  parentRegistry = NULL);
67 
69  DtSimResource(const DtSimResource& orig);
70 
73 
74 public:
75 
77  virtual ~DtSimResource() override;
78 
82  virtual const char* readerWriterType() const override;
83 
85  static const char* theXmlType();
86 
87  virtual const char* xmlType() const override
88  {
89  return theXmlType();
90  }
91 
93  bool operator!= (const DtSimResource& orig) const;
94  bool operator== (const DtSimResource& orig) const;
95 
97  virtual void deplete(double d = 1);
98 
100  virtual bool matches(const std::vector<DtEntityType>&) const;
101 
102  virtual void setResourceType(const DtEntityType&);
103  const DtEntityType& resourceType() const
104  {
105  return myResource;
106  }
107 
108  virtual void setCurrentAmount(double amount);
109  void setAmount(double a)
110  {
111  setCurrentAmount(a);
112  }
113 
114  double currentAmount() const;
115 
116  double amount() const
117  {
118  return currentAmount();
119  }
120 
121  virtual void setValueIsInteger(bool);
122  bool valueIsInteger() const
123  {
124  return myValueIsInteger;
125  }
126 
127  virtual void setFullAmount(double amount);
128  double fullAmount() const;
129 
130  virtual void setRestore(bool);
131  bool shouldRestore() const
132  {
133  return myRestore;
134  }
135 
136  virtual void restore();
137 
138  virtual int netRepSize() const;
141  virtual const char* setFromNet(const char* contentBuffer);
142 
143  typedef void (*UpdateCallback)(DtSimResource*, void*);
144 
146  virtual void addUpdateCallback(UpdateCallback fcn, void* usrData);
147 
149  virtual void removeUpdateCallback(UpdateCallback fcn, void* usrData);
150 
152  virtual void callUpdateCallbacks();
153 
157  virtual char* setToNet(char* contentBuffer) const;
158 
160  virtual double percentageFull() const;
161 
163  {
164  return myCurrentAmount;
165  }
166 
168  {
169  return myCurrentAmount;
170  }
171 
173  {
174  return myFullAmount;
175  }
176 
178  {
179  return myFullAmount;
180  }
181 
183  {
184  return myRestore;
185  }
186 
188  {
189  return myRestore;
190  }
191 
192  int bin() const
193  {
194  return myBin;
195  }
196 
197  virtual void setBin(int);
198 
199  virtual void clearFullAmount();
200 
201  virtual void getSelf(DtlObjPtr args, const DtReaderWriter::SearchPaths& searchPaths,
202  const DtVariableBindingsList& variableBindings) override;
203 
204  virtual DtString prettyPrint() const override;
205 
208  virtual void setDisplayName(const DtString&);
209  const DtString& displayName() const
210  {
211  return myDisplayName;
212  }
213 
214 protected:
215  virtual void postGetSelf() override;
216 
217 protected:
223 
225  int myValueIsInteger = false;
226 
228 };
229 
230 inline bool DtSimResource::operator!=(const DtSimResource& orig) const
231 {
232  return !(*this == orig);
233 }
bool operator==(const DtReaderWriter &) const
Equivalence operator.
virtual const char * readerWriterType() const
Used to supply a string type that this reader writer type is. This can be used in place of dynamic-ca...
This class allows one to collect and compare strings using an index number instead of having to do st...
Definition: symbolString.h:27
virtual void postGetSelf()
Called after either version of getSelf (mtl or environment). Default is no-op.
DtRwReal & fullAmountVariable()
Definition: simResource.h:177
virtual const char * xmlType() const override
Definition: simResource.h:87
Definition: simResource.h:37
Definition: readerWriter.h:85
class DtSimResourceManager:
Definition: simResourceManager.h:19
RwMunitionOrEntityType myResource
Definition: simResource.h:218
Definition: readerWriterRegistry.h:39
virtual DtString prettyPrint() const
Routine to return a human readable form of the reader/writer variable. Not all reader/writer classes ...
void setAmmunitionName(const DtString &s)
Definition: simResource.h:49
bool operator!=(const DtSimResource &orig) const
Expects subclasses to implement isEqual method. Default returns false.
Definition: simResource.h:230
bool shouldRestore() const
Definition: simResource.h:131
DtRwEntityType & operator=(const DtRwEntityType &orig)
assignment: assigns value only
bool operator!=(const DtReaderWriter &rhs) const
Definition: readerWriter.h:121
DtRwReal myFullAmount
Definition: simResource.h:220
const DtString & displayName() const
Definition: simResource.h:209
std::list< const DtRwVariableBindings * > DtVariableBindingsList
Definition: readerWriterRegistry.h:29
void setAmount(double a)
Definition: simResource.h:109
Description: Readable, Writable int.
Definition: rwInt.h:25
DtCallbackList< DtSimResource * > myUpdateCallbacks
Definition: simResource.h:224
std::vector< DtFilename > SearchPaths
Definition: readerWriter.h:92
const DtRwReal & fullAmountVariable() const
Definition: simResource.h:172
DtRwBoolean & restoreVariable()
Definition: simResource.h:187
virtual void getSelf(DtlObjPtr args, const DtReaderWriter::SearchPaths &searchPaths=SearchPaths(), const DtVariableBindingsList &variableBindings=nullVariableReference())
Top level to read itself from an input stream. searchPath is passed down to all DtReaderWriter member...
DtRwBoolean myRestore
Definition: simResource.h:221
int bin() const
Definition: simResource.h:192
Description: Readable, Writable DtReal (double)
Definition: rwReal.h:27
File: rwEntType.h.
Definition: rwEntityType.h:26
DtRwReal & currentAmountVariable()
Definition: simResource.h:167
bool valueIsInteger() const
Definition: simResource.h:122
Description: Readable, Writable bool.
Definition: rwBoolean.h:26
DtString myDisplayName
Definition: simResource.h:227
DtEntityType & operator=(const DtEntityType &t)
Definition: simResource.h:47
DtSimResource is a class which will define a SISO Enumeration to use as a resource and the quantity o...
Definition: simResource.h:32
DtRwInt myBin
Definition: simResource.h:222
DtRwReal myCurrentAmount
Definition: simResource.h:219
#define DT_DLL_vrfutil
This file is used to determine how to build Disable inconsistent dll linkage warning Visual Studio 6...
Definition: vrfutilDefines.h:34
const DtReaderWriter & operator=(const DtReaderWriter &orig)
assignment operator
const DtEntityType & resourceType() const
Definition: simResource.h:103
static const char * theXmlType()
The type that is used when archiving to an XML stream.
const DtRwBoolean & restoreVariable() const
Definition: simResource.h:182
double amount() const
Definition: simResource.h:116
const DtRwReal & currentAmountVariable() const
Definition: simResource.h:162

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)