VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
simResourceManager.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2026 MaK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
10 
11 #include "vrfutil/vrfutilDefines.h"
14 
18 class DT_DLL_vrfutil DtSimResourceManager : public DtRwTemplatedListPtr<DtSimResource, true>
19 {
20 
21 public:
22 
25 
28  parentRegistry = 0);
29 
31  parentRegistry = 0);
32 
35 
37  virtual ~DtSimResourceManager() override;
38 
46  virtual DtSimResource* addResource(const DtEntityType&, double amount, int bin = 0);
47  virtual DtSimResource* addResource(const DtSimResource&);
49 
52  virtual bool removeResource(const DtEntityType&, int bin = 0);
53 
57  virtual DtSimResource* lookupResource(const DtEntityType& resourceName, int bin = 0);
58  virtual const DtSimResource* lookupResource(const DtEntityType& resourceName, int bin = 0) const;
60 
65  virtual std::vector<DtSimResource*> lookupResources(const std::vector<DtEntityType>& types, int bin = 0);
66  virtual std::vector<const DtSimResource*> lookupResources(const std::vector<DtEntityType>& types, int bin = 0) const;
68 
71  virtual const char* readerWriterType() const override;
72 
74  virtual void clear();
75 
81  virtual void merge(const DtSimResourceManager&);
82  virtual void merge(const DtSimResourceList&);
84 
86  static const char* theXmlType();
87 
88  virtual const char* xmlType() const override
89  {
90  return theXmlType();
91  }
92 
94  virtual void restoreResources(int bin = 0);
95 
97  virtual void restoreFrom(const DtSimResourceManager&);
98 
99  virtual std::list<DtEntityType> getResourceTypes(const std::vector<DtEntityType>& types, double greaterThanAmount = 0, int bin = 0) const;
100 
101  virtual DtRwTemplatedListPtr& operator=(const DtRwTemplatedListPtr& orig) override;
103  virtual bool operator==(const DtRwTemplatedListPtr& orig) const override;
105  bool operator==(const DtSimResourceManager&) const;
106 
110  virtual std::shared_ptr<DtSimResourceList> resources(int bin = 0);
111  virtual std::shared_ptr<const DtSimResourceList> resources(int bin = 0) const;
113 
116  virtual std::vector<DtSimResource*> allResources();
117  virtual std::vector<const DtSimResource*> allResources() const;
119 
123  virtual void setKeepOriginalRWNames(bool);
124  bool keepOriginalRWNames() const
125  {
126  return myKeepOriginalRWNames;
127  }
129 
131  virtual std::vector<int> bins() const;
132 
133 public:
134  virtual void preGetSelf() override;
135  virtual void postGetSelf() override;
136  virtual void prePutSelf() override;
137  virtual void postPutSelf() override;
138 
139 protected:
140  typedef std::map<int, std::shared_ptr<DtSimResourceList>> ResourceByBinMap;
142  bool myKeepOriginalRWNames = true;
143 };
virtual DtRwTemplatedListPtr & operator=(const DtRwTemplatedListPtr &orig)
virtual void prePutSelf()
Called before either version of put self (file or environment). Default is no-op. ...
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.
The DtSimResourceManager is responsible for managing all of the resources for a given entity...
Definition: simResourceManager.h:18
static const char * theXmlType()
Definition: rwTemplatedList.h:109
Definition: readerWriterRegistry.h:39
ResourceByBinMap myResourceByBinMap
Definition: simResourceManager.h:141
virtual void preGetSelf()
Called before either version of get self (file or environment). Default is no-op. ...
class DtSimResourceList:
Definition: simResourceList.h:18
std::map< int, std::shared_ptr< DtSimResourceList > > ResourceByBinMap
Definition: simResourceManager.h:140
DtSimResource is a class which will define a SISO Enumeration to use as a resource and the quantity o...
Definition: simResource.h:32
Definition: rwTemplatedList.h:34
virtual bool operator==(const DtRwTemplatedListPtr &) const
Equivalence operators.
virtual const char * readerWriterType() const override
Used to supply a string type that this reader writer type is. This can be used in place of dynamic-ca...
#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
bool keepOriginalRWNames() const
On save the manager will change all resource names to be of type &quot;resource&lt;num&gt;&quot;. Set this flag to tr...
Definition: simResourceManager.h:124
virtual const char * xmlType() const override
Routines to archive/dearchive from an XML Environment.
Definition: simResourceManager.h:88
virtual void postPutSelf()
Called after either version of put self (file or environment). Default is no-op.

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)