VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
rwTemplatedList.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2013 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
10 
11 #include "readerWriter/rwList.h"
12 #include "vrfutil/iteratorBase.h"
14 
15 #include "readerWriter/rwString.h"
16 #include "readerWriter/rwInt.h"
17 #include "readerWriter/rwReal.h"
18 #include "vrfutil/rwUUID.h"
19 
26 {
27 public:
28  virtual DtReaderWriter* createPrototype(const char* name = "") const = 0;
29  virtual void removeAndDeleteAll() = 0;
30  virtual DtListItem* add(DtReaderWriter*) = 0;
31 };
32 
33 template <typename T, bool T_autoDelete>
35 {
36 public:
39 
42 
44  DtRwTemplatedListPtr(const DtString& name, DtReaderWriterRegistry* parentRegistry = NULL);
45  DtRwTemplatedListPtr(const DtSymbolString& name, DtReaderWriterRegistry* parentRegistry = NULL);
46 
50  DtReaderWriterRegistry* parentRegistry = NULL);
51 
53  DtReaderWriterRegistry* parentRegistry = NULL);
54 
57  DtReaderWriterRegistry* parentRegistry = NULL);
58 
60 
61  virtual ~DtRwTemplatedListPtr() override;
62 
63  virtual DtReaderWriter* createPrototype(const char* name = "" ) const override { return new T(name); };
64 
65  virtual DtlObjPtr getData(DtlObjPtr args, const DtReaderWriter::SearchPaths& searchPaths,
66  const DtVariableBindingsList& variableBindings) override;
67 
68  virtual DtListItem* insertItemAt(T* data, int index)
69  {
70  DtListItem* item = first();
71 
72  while (index && item)
73  {
74  --index;
75  item = item->next();
76  }
77 
78  if (item->data())
79  {
80  return DtRwList::addBefore(data, static_cast<DtReaderWriter*>(item->data()));
81  }
82  else
83  {
84  return DtRwList::add(data);
85  }
86  }
87 
90  virtual DtListItem* add(DtReaderWriter* item) override { return add(dynamic_cast<T*>(item)); };
91  virtual DtListItem* add(T* data) { return DtRwList::add(data);};
92 
95  virtual void removeAll() override;
96  void* remove(DtListItem* item);
97  void* remove(T* item);
98 
100  virtual std::set<DtString> supportedXmlTypes() const override;
101 
103  virtual void removeAndDeleteAll() override;
104 
106  virtual bool operator==(const DtRwTemplatedListPtr&) const;
107  bool operator!=(const DtRwTemplatedListPtr&) const;
108 
109  static const char* theXmlType()
110  {
111  static DtString xmlType(DtString(T::theXmlType()) + "s");
112  return xmlType.c_str();
113  }
114 
115  virtual const char* xmlType() const override
116  {
117  return theXmlType();
118  }
119 
120  //Populates list by looking add the templated list type
121  virtual void populateList(
122  boost::function<void (DtReaderWriter*)> addFunction,
123  DtEnvironmentSP env, DtEnvValueSP node,
124  const DtReaderWriter::SearchPaths& searchPaths, const DtVariableBindingsList& bindings) override;
125 
127  DtListItem* find( boost::function< bool (const T&)> predFcn) const;
128 
129  virtual DtString prettyPrint() const override;
130 
131 public:
132  virtual const char* readerWriterType() const override;
133 
134  static const char* ListReaderWriterType();
135 
136  void copyList(const DtRwTemplatedListPtr& orig);
137 
138 protected:
140 };
141 
142 namespace DtBufferSerialize
143 {
146  template <typename T, bool T_autoDelete>
148 
152  template <typename T, bool T_autoDelete>
153  char *encode(const DtRwTemplatedListPtr<T, T_autoDelete>& val, char *buffer);
154 
159  template <typename T, bool T_autoDelete>
160  const char *decode(DtRwTemplatedListPtr<T, T_autoDelete>& val, const char *buffer) ;
161 };
162 
164 {
165 public:
168 
170  DtRwTemplatedStringList(const DtString& name, DtReaderWriterRegistry* parentRegistry = NULL)
171  : DtRwTemplatedListPtr<DtRwString, true>(name, parentRegistry) {};
172  DtRwTemplatedStringList(const DtSymbolString& name, DtReaderWriterRegistry* parentRegistry = NULL)
173  : DtRwTemplatedListPtr<DtRwString, true>(name, parentRegistry) {};
174 
176  DtReaderWriterRegistry* parentRegistry = NULL)
177  : DtRwTemplatedListPtr<DtRwString, true>(name, orig, parentRegistry) {};
178 
180  DtReaderWriterRegistry* parentRegistry = NULL)
181  : DtRwTemplatedListPtr<DtRwString, true>(name, orig, parentRegistry) {};
182 
184  DtReaderWriterRegistry* parentRegistry = NULL)
185  : DtRwTemplatedListPtr<DtRwString, true>(orig, parentRegistry) {};
186 };
187 
189 {
190 public:
193 
195  DtRwTemplatedUUIDList(const DtString& name, DtReaderWriterRegistry* parentRegistry = NULL)
196  : DtRwTemplatedListPtr<DtRwUUID, true>(name, parentRegistry) {};
197  DtRwTemplatedUUIDList(const DtSymbolString& name, DtReaderWriterRegistry* parentRegistry = NULL)
198  : DtRwTemplatedListPtr<DtRwUUID, true>(name, parentRegistry) {};
199 
201  DtReaderWriterRegistry* parentRegistry = NULL)
202  : DtRwTemplatedListPtr<DtRwUUID, true>(name, orig, parentRegistry) {};
203 
205  DtReaderWriterRegistry* parentRegistry = NULL)
206  : DtRwTemplatedListPtr<DtRwUUID, true>(name, orig, parentRegistry) {};
207 
209  DtReaderWriterRegistry* parentRegistry = NULL)
210  : DtRwTemplatedListPtr<DtRwUUID, true>(orig, parentRegistry) {};
211 };
212 
214 {
215 public:
218 
220  DtRwTemplatedIntList(const DtString& name, DtReaderWriterRegistry* parentRegistry = NULL)
221  : DtRwTemplatedListPtr<DtRwInt, true>(name, parentRegistry) {};
222 
223  DtRwTemplatedIntList(const DtSymbolString& name, DtReaderWriterRegistry* parentRegistry = NULL)
224  : DtRwTemplatedListPtr<DtRwInt, true>(name, parentRegistry) {};
225 
227  DtReaderWriterRegistry* parentRegistry = NULL)
228  : DtRwTemplatedListPtr<DtRwInt, true>(name, orig, parentRegistry) {};
229 
231  DtReaderWriterRegistry* parentRegistry = NULL)
232  : DtRwTemplatedListPtr<DtRwInt, true>(name, orig, parentRegistry) {};
233 
235  DtReaderWriterRegistry* parentRegistry = NULL)
236  : DtRwTemplatedListPtr<DtRwInt, true>(orig, parentRegistry) {};
237 };
238 
240 {
241 public:
244 
246  DtRwTemplatedRealList(const DtString& name, DtReaderWriterRegistry* parentRegistry = NULL)
247  : DtRwTemplatedListPtr<DtRwReal, true>(name, parentRegistry) {};
248 
249  DtRwTemplatedRealList(const DtSymbolString& name, DtReaderWriterRegistry* parentRegistry = NULL)
250  : DtRwTemplatedListPtr<DtRwReal, true>(name, parentRegistry) {};
251 
253  DtReaderWriterRegistry* parentRegistry = NULL)
254  : DtRwTemplatedListPtr<DtRwReal, true>(name, orig, parentRegistry) {};
255 
257  DtReaderWriterRegistry* parentRegistry = NULL)
258  : DtRwTemplatedListPtr<DtRwReal, true>(name, orig, parentRegistry) {};
259 
261  DtReaderWriterRegistry* parentRegistry = NULL)
262  : DtRwTemplatedListPtr<DtRwReal, true>(orig, parentRegistry) {};
263 };
264 
265 #include "vrfutil/rwTemplatedList.inl"
Definition: rwTemplatedList.h:188
virtual DtlObjPtr getData(DtlObjPtr args, const DtReaderWriter::SearchPaths &searchPaths, const DtVariableBindingsList &variableBindings) override
This method must be overridden by a subclass. Within this method, new instances of the DtReaderWriter...
DtRwTemplatedRealList(const DtString &name, const DtRwTemplatedRealList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:252
virtual std::set< DtString > supportedXmlTypes() const override
Returns list of supported types. Default is the templated object xml type.
virtual DtRwTemplatedListPtr & operator=(const DtRwTemplatedListPtr &orig)
virtual void populateList(boost::function< void(DtReaderWriter *)> addFunction, DtEnvironmentSP env, DtEnvValueSP node, const DtReaderWriter::SearchPaths &searchPaths, const DtVariableBindingsList &bindings) override
DtRwTemplatedUUIDList(const DtSymbolString &name, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:197
DT_DLL_readerWriter int getSize(const DtString &val)
The number of bytes required to encode the value.
DtRwTemplatedUUIDList(const DtRwTemplatedUUIDList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:208
Definition: rwTemplatedList.h:213
This class allows one to collect and compare strings using an index number instead of having to do st...
Definition: symbolString.h:27
DtRwTemplatedStringList(const DtSymbolString &name, const DtRwTemplatedStringList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:179
A Readable, Writable version of DtList. This class cannot be used directly, but must be inherited to ...
Definition: rwList.h:26
DtString myXmlType
Definition: rwTemplatedList.h:139
virtual const char * xmlType() const override
Routines to archive/dearchive from an XML Environment.
Definition: rwTemplatedList.h:115
bool operator!=(const DtRwTemplatedListPtr &) const
virtual DtListItem * add(DtReaderWriter *)=0
DtRwTemplatedStringList(const DtString &name, DtReaderWriterRegistry *parentRegistry=NULL)
real constructor
Definition: rwTemplatedList.h:170
Definition: rwTemplatedList.h:239
A version of DtRwList that contains a homogeneous list of a templated RW type. The templated type spe...
Definition: rwTemplatedList.h:25
virtual void removeAndDeleteAll() override
Removes and deletes all entries in the list.
DtRwTemplatedUUIDList(const DtString &name, const DtRwTemplatedUUIDList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:200
Definition: readerWriter.h:85
Description: Readable, Writable DtString Variable substitutions are done on this object when it is re...
Definition: rwString.h:20
virtual void removeAndDeleteAll()=0
virtual DtReaderWriter * createPrototype(const char *name="") const override
Definition: rwTemplatedList.h:63
void copyList(const DtRwTemplatedListPtr &orig)
DtRwTemplatedRealList(const DtRwTemplatedRealList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:260
virtual DtListItem * addBefore(DtReaderWriter *data, const DtString &before)
Add element to the list just before the indicated item. Returns the DtListItem envelope object that c...
static const char * theXmlType()
Definition: rwTemplatedList.h:109
Definition: readerWriterRegistry.h:39
Contains the DtUUID class declaration.
DtRwTemplatedStringList(const DtSymbolString &name, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:172
DtRwTemplatedRealList()
default constructor
Definition: rwTemplatedList.h:243
uuid class
Definition: rwUUID.h:26
virtual DtListItem * add(T *data)
Definition: rwTemplatedList.h:91
static const char * ListReaderWriterType()
DtIteratorBase< T > iterator
Definition: rwTemplatedList.h:37
DtRwTemplatedIntList(const DtRwTemplatedIntList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:234
Description: DtIteratorBase is the base class for iterators used to iterate over a DtList...
Definition: iteratorBase.h:32
virtual ~DtRwTemplatedListPtr() override
DtRwTemplatedRealList(const DtString &name, DtReaderWriterRegistry *parentRegistry=NULL)
real constructor
Definition: rwTemplatedList.h:246
virtual DtListItem * add(DtReaderWriter *item) override
Define this function to hide the DtRwList version, and accept only the specific DtReaderWriter subcla...
Definition: rwTemplatedList.h:90
DtRwTemplatedIntList(const DtSymbolString &name, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:223
std::list< const DtRwVariableBindings * > DtVariableBindingsList
Definition: readerWriterRegistry.h:29
DtRwTemplatedRealList(const DtSymbolString &name, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:249
Description: Readable, Writable int.
Definition: rwInt.h:25
DtRwTemplatedStringList(const DtRwTemplatedStringList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:183
std::vector< DtFilename > SearchPaths
Definition: readerWriter.h:92
DtRwTemplatedUUIDList(const DtSymbolString &name, const DtRwTemplatedUUIDList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:204
virtual DtListItem * add(DtReaderWriter *data)
Add element to the end of the list. Returns the DtListItem envelope object that contains your new ele...
DtRwTemplatedStringList()
default constructor
Definition: rwTemplatedList.h:167
DT_DLL_readerWriter char * encode(const DtFilename &val, char *buffer)
Serializes the provided value val into buffer. buffer must have at least the number of bytes returned...
virtual DtListItem * insertItemAt(T *data, int index)
Definition: rwTemplatedList.h:68
Description: Readable, Writable DtReal (double)
Definition: rwReal.h:27
virtual DtReaderWriter * createPrototype(const char *name="") const =0
DtIteratorBase< const T > const_iterator
Definition: rwTemplatedList.h:38
Definition: rwTemplatedList.h:163
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
DtRwTemplatedListPtr()
default constructor
DtRwTemplatedIntList()
default constructor
Definition: rwTemplatedList.h:217
DtRwTemplatedRealList(const DtSymbolString &name, const DtRwTemplatedRealList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:256
DT_DLL_readerWriter const char * decode(DtString &val, const char *buffer)
Decodes a value from buffer and places the result in val of the type specified by val...
DtRwTemplatedIntList(const DtString &name, DtReaderWriterRegistry *parentRegistry=NULL)
real constructor
Definition: rwTemplatedList.h:220
DT_DLL_readerWriter std::shared_ptr< DtEnvironment > DtEnvironmentSP
Definition: readerWriter.h:30
DtRwTemplatedIntList(const DtString &name, const DtRwTemplatedIntList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:226
DtListItem * find(boost::function< bool(const T &)> predFcn) const
Finds the first item in the list for which predFcn returns true.
DtRwTemplatedUUIDList()
default constructor
Definition: rwTemplatedList.h:192
virtual DtSymbolString name() const
Accessor for name of this readable/writable object.
virtual DtString prettyPrint() const override
Routine to return a human readable form of the reader/writer variable. Not all reader/writer classes ...
virtual void removeAll() override
Removes all entries from the list. If autoDelete is true, also deletes all items. ...
DtRwTemplatedUUIDList(const DtString &name, DtReaderWriterRegistry *parentRegistry=NULL)
real constructor
Definition: rwTemplatedList.h:195
DtRwTemplatedIntList(const DtSymbolString &name, const DtRwTemplatedIntList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:230
DtRwTemplatedStringList(const DtString &name, const DtRwTemplatedStringList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:175

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)