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  const DtRwInt& binVariable() const
193  {
194  return myBin;
195  }
196 
198  {
199  return myBin;
200  }
201 
202  int bin() const
203  {
204  return myBin;
205  }
206 
207  virtual void setBin(int);
208 
209  virtual void clearFullAmount();
210 
211  virtual void getSelf(DtlObjPtr args, const DtReaderWriter::SearchPaths& searchPaths,
212  const DtVariableBindingsList& variableBindings) override;
213 
214  virtual DtString prettyPrint() const override;
215 
220 
221  virtual void setDisplayName(const DtString&);
222  const DtString& displayName() const
223  {
224  return myDisplayName;
225  }
227 
228 protected:
229  virtual void postGetSelf() override;
230 
231 protected:
237 
239  int myValueIsInteger = false;
240 
242 };
243 
244 inline bool DtSimResource::operator!=(const DtSimResource& orig) const
245 {
246  return !(*this == orig);
247 }
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
The DtSimResourceManager is responsible for managing all of the resources for a given entity...
Definition: simResourceManager.h:18
RwMunitionOrEntityType myResource
Definition: simResource.h:232
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:244
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:234
const DtString & displayName() const
This is only used locally in the GUI. It is not sent over the network nor saved anywhere. If creating this resource in code in the GUI and you want to display this name rather than a name based on the entity type, set this here. Set to the empty string to revert to using the name returned by the enumerations dictionary.
Definition: simResource.h:222
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:238
std::vector< DtFilename > SearchPaths
Definition: readerWriter.h:92
const DtRwInt & binVariable() const
Definition: simResource.h:192
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:235
int bin() const
Definition: simResource.h:202
DtRwInt & binVariable()
Definition: simResource.h:197
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:241
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:236
DtRwReal myCurrentAmount
Definition: simResource.h:233
#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 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)