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();
62 
63  virtual DtReaderWriter* createPrototype(const char* name = "" ) const override { return new T(name); };
64 
65  DtlObjPtr getData(DtlObjPtr args, const DtReaderWriter::SearchPaths& searchPaths,
66  const DtVariableBindingsList& variableBindings);
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  void removeAll();
96  void* remove(DtListItem* item);
97  void* remove(T* item);
98 
100  virtual std::set<DtString> supportedXmlTypes() const;
101 
103  void removeAndDeleteAll() override;
104 
106  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
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);
125 
127  DtListItem* find( boost::function< bool (const T&)> predFcn) const;
128 
129  virtual DtString prettyPrint() const;
130 
131 public:
132 
133  const char* readerWriterType() const;
134 
135  static const char* ListReaderWriterType();
136 
137  void copyList(const DtRwTemplatedListPtr& orig);
138 
139 protected:
141 };
142 
143 namespace DtBufferSerialize
144 {
147  template <typename T, bool T_autoDelete>
149 
153  template <typename T, bool T_autoDelete>
154  char *encode(const DtRwTemplatedListPtr<T, T_autoDelete>& val, char *buffer);
155 
160  template <typename T, bool T_autoDelete>
161  const char *decode(DtRwTemplatedListPtr<T, T_autoDelete>& val, const char *buffer) ;
162 };
163 
165 {
166 public:
169 
171  DtRwTemplatedStringList(const DtString& name, DtReaderWriterRegistry* parentRegistry = NULL)
172  : DtRwTemplatedListPtr<DtRwString, true>(name, parentRegistry) {};
173  DtRwTemplatedStringList(const DtSymbolString& name, DtReaderWriterRegistry* parentRegistry = NULL)
174  : DtRwTemplatedListPtr<DtRwString, true>(name, parentRegistry) {};
175 
177  DtReaderWriterRegistry* parentRegistry = NULL)
178  : DtRwTemplatedListPtr<DtRwString, true>(name, orig, parentRegistry) {};
179 
181  DtReaderWriterRegistry* parentRegistry = NULL)
182  : DtRwTemplatedListPtr<DtRwString, true>(name, orig, parentRegistry) {};
183 
185  DtReaderWriterRegistry* parentRegistry = NULL)
186  : DtRwTemplatedListPtr<DtRwString, true>(orig, parentRegistry) {};
187 };
188 
190 {
191 public:
194 
196  DtRwTemplatedUUIDList(const DtString& name, DtReaderWriterRegistry* parentRegistry = NULL)
197  : DtRwTemplatedListPtr<DtRwUUID, true>(name, parentRegistry) {};
198  DtRwTemplatedUUIDList(const DtSymbolString& name, DtReaderWriterRegistry* parentRegistry = NULL)
199  : DtRwTemplatedListPtr<DtRwUUID, true>(name, parentRegistry) {};
200 
202  DtReaderWriterRegistry* parentRegistry = NULL)
203  : DtRwTemplatedListPtr<DtRwUUID, true>(name, orig, parentRegistry) {};
204 
206  DtReaderWriterRegistry* parentRegistry = NULL)
207  : DtRwTemplatedListPtr<DtRwUUID, true>(name, orig, parentRegistry) {};
208 
210  DtReaderWriterRegistry* parentRegistry = NULL)
211  : DtRwTemplatedListPtr<DtRwUUID, true>(orig, parentRegistry) {};
212 };
213 
215 {
216 public:
219 
221  DtRwTemplatedIntList(const DtString& name, DtReaderWriterRegistry* parentRegistry = NULL)
222  : DtRwTemplatedListPtr<DtRwInt, true>(name, parentRegistry) {};
223 
224  DtRwTemplatedIntList(const DtSymbolString& name, DtReaderWriterRegistry* parentRegistry = NULL)
225  : DtRwTemplatedListPtr<DtRwInt, true>(name, parentRegistry) {};
226 
228  DtReaderWriterRegistry* parentRegistry = NULL)
229  : DtRwTemplatedListPtr<DtRwInt, true>(name, orig, parentRegistry) {};
230 
232  DtReaderWriterRegistry* parentRegistry = NULL)
233  : DtRwTemplatedListPtr<DtRwInt, true>(name, orig, parentRegistry) {};
234 
236  DtReaderWriterRegistry* parentRegistry = NULL)
237  : DtRwTemplatedListPtr<DtRwInt, true>(orig, parentRegistry) {};
238 };
239 
241 {
242 public:
245 
247  DtRwTemplatedRealList(const DtString& name, DtReaderWriterRegistry* parentRegistry = NULL)
248  : DtRwTemplatedListPtr<DtRwReal, true>(name, parentRegistry) {};
249 
250  DtRwTemplatedRealList(const DtSymbolString& name, DtReaderWriterRegistry* parentRegistry = NULL)
251  : DtRwTemplatedListPtr<DtRwReal, true>(name, parentRegistry) {};
252 
254  DtReaderWriterRegistry* parentRegistry = NULL)
255  : DtRwTemplatedListPtr<DtRwReal, true>(name, orig, parentRegistry) {};
256 
258  DtReaderWriterRegistry* parentRegistry = NULL)
259  : DtRwTemplatedListPtr<DtRwReal, true>(name, orig, parentRegistry) {};
260 
262  DtReaderWriterRegistry* parentRegistry = NULL)
263  : DtRwTemplatedListPtr<DtRwReal, true>(orig, parentRegistry) {};
264 };
265 
266 #include "vrfutil/rwTemplatedList.inl"
Definition: rwTemplatedList.h:189
DtRwTemplatedRealList(const DtString &name, const DtRwTemplatedRealList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:253
DtRwTemplatedUUIDList(const DtSymbolString &name, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:198
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:209
bool operator==(const DtRwTemplatedListPtr &) const
Equivalence operators.
virtual void populateList(boost::function< void(DtReaderWriter *)> addFunction, DtEnvironmentSP env, DtEnvValueSP node, const DtReaderWriter::SearchPaths &searchPaths, const DtVariableBindingsList &bindings)
Definition: rwTemplatedList.h:214
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:180
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:140
bool operator!=(const DtRwTemplatedListPtr &) const
virtual DtListItem * add(DtReaderWriter *)=0
DT_DLL_readerWriter DtBoost::shared_ptr< DtEnvironment > DtEnvironmentSP
Definition: readerWriter.h:30
DtRwTemplatedStringList(const DtString &name, DtReaderWriterRegistry *parentRegistry=NULL)
real constructor
Definition: rwTemplatedList.h:171
DtRwTemplatedListPtr & operator=(const DtRwTemplatedListPtr &orig)
Definition: rwTemplatedList.h:240
A version of DtRwList that contains a homogeneous list of a templated RW type. The templated type spe...
Definition: rwTemplatedList.h:25
DtRwTemplatedUUIDList(const DtString &name, const DtRwTemplatedUUIDList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:201
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:261
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:173
virtual DtString prettyPrint() const
Routine to return a human readable form of the reader/writer variable. Not all reader/writer classes ...
DtRwTemplatedRealList()
default constructor
Definition: rwTemplatedList.h:244
uuid class
Definition: rwUUID.h:26
virtual const char * xmlType() const
Routines to archive/dearchive from an XML Environment.
Definition: rwTemplatedList.h:115
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:235
Description: DtIteratorBase is the base class for iterators used to iterate over a DtList...
Definition: iteratorBase.h:32
DtRwTemplatedRealList(const DtString &name, DtReaderWriterRegistry *parentRegistry=NULL)
real constructor
Definition: rwTemplatedList.h:247
virtual std::set< DtString > supportedXmlTypes() const
Returns list of supported types. Default is the templated object xml type.
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
void removeAndDeleteAll() override
Removes and deletes all entries in the list.
DtRwTemplatedIntList(const DtSymbolString &name, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:224
std::list< const DtRwVariableBindings * > DtVariableBindingsList
Definition: readerWriterRegistry.h:29
DtlObjPtr getData(DtlObjPtr args, const DtReaderWriter::SearchPaths &searchPaths, const DtVariableBindingsList &variableBindings)
This method must be overridden by a subclass. Within this method, new instances of the DtReaderWriter...
DtRwTemplatedRealList(const DtSymbolString &name, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:250
Description: Readable, Writable int.
Definition: rwInt.h:25
DtRwTemplatedStringList(const DtRwTemplatedStringList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:184
std::vector< DtFilename > SearchPaths
Definition: readerWriter.h:92
DtRwTemplatedUUIDList(const DtSymbolString &name, const DtRwTemplatedUUIDList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:205
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:168
virtual ~DtRwTemplatedListPtr()
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
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...
void removeAll()
Removes all entries from the list. If autoDelete is true, also deletes all items. ...
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:164
Definition: rwTemplatedList.h:34
#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:218
DtRwTemplatedRealList(const DtSymbolString &name, const DtRwTemplatedRealList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:257
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:221
DtRwTemplatedIntList(const DtString &name, const DtRwTemplatedIntList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:227
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:193
virtual DtSymbolString name() const
Accessor for name of this readable/writable object.
DtRwTemplatedUUIDList(const DtString &name, DtReaderWriterRegistry *parentRegistry=NULL)
real constructor
Definition: rwTemplatedList.h:196
DtRwTemplatedIntList(const DtSymbolString &name, const DtRwTemplatedIntList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:231
DtRwTemplatedStringList(const DtString &name, const DtRwTemplatedStringList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:176

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)