VR-Forces 5.0.3 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 
25 template <typename T, bool T_autoDelete>
27 {
28 public:
31 
34 
36  DtRwTemplatedListPtr(const DtString& name, DtReaderWriterRegistry* parentRegistry = NULL);
37  DtRwTemplatedListPtr(const DtSymbolString& name, DtReaderWriterRegistry* parentRegistry = NULL);
38 
42  DtReaderWriterRegistry* parentRegistry = NULL);
43 
45  DtReaderWriterRegistry* parentRegistry = NULL);
46 
49  DtReaderWriterRegistry* parentRegistry = NULL);
50 
52 
53  virtual ~DtRwTemplatedListPtr();
54 
55  DtlObjPtr getData(DtlObjPtr args, const DtReaderWriter::SearchPaths& searchPaths,
56  const DtVariableBindingsList& variableBindings);
57 
58  virtual DtListItem* insertItemAt(T* data, int index)
59  {
60  DtListItem* item = first();
61 
62  while (index && item)
63  {
64  --index;
65  item = item->next();
66  }
67 
68  if (item->data())
69  {
70  return DtRwList::addBefore(data, static_cast<DtReaderWriter*>(item->data()));
71  }
72  else
73  {
74  return DtRwList::add(data);
75  }
76  }
77 
80  virtual DtListItem* add(T* data) {return DtRwList::add(data);};
81 
84  void removeAll();
85  void* remove(DtListItem* item);
86  void* remove(T* item);
87 
89  virtual std::set<DtString> supportedXmlTypes() const;
90 
92  void removeAndDeleteAll();
93 
95  bool operator==(const DtRwTemplatedListPtr&) const;
96  bool operator!=(const DtRwTemplatedListPtr&) const;
97 
98  static const char* theXmlType()
99  {
100  static DtString xmlType(DtString(T::theXmlType()) + "s");
101  return xmlType.c_str();
102  }
103 
104  virtual const char* xmlType() const
105  {
106  return theXmlType();
107  }
108 
109  //Populates list by looking add the templated list type
110  virtual void populateList(
111  boost::function<void (DtReaderWriter*)> addFunction,
112  DtEnvironmentSP env, DtEnvValueSP node,
113  const DtReaderWriter::SearchPaths& searchPaths, const DtVariableBindingsList& bindings);
114 
116  DtListItem* find( boost::function< bool (const T&)> predFcn) const;
117 
118  virtual DtString prettyPrint() const;
119 
120 public:
121 
122  const char* readerWriterType() const;
123 
124  static const char* ListReaderWriterType();
125 
126  void copyList(const DtRwTemplatedListPtr& orig);
127 
128 protected:
130 };
131 
132 namespace DtBufferSerialize
133 {
136  template <typename T, bool T_autoDelete>
138 
142  template <typename T, bool T_autoDelete>
143  char *encode(const DtRwTemplatedListPtr<T, T_autoDelete>& val, char *buffer);
144 
149  template <typename T, bool T_autoDelete>
150  const char *decode(DtRwTemplatedListPtr<T, T_autoDelete>& val, const char *buffer) ;
151 };
152 
154 {
155 public:
158 
160  DtRwTemplatedStringList(const DtString& name, DtReaderWriterRegistry* parentRegistry = NULL)
161  : DtRwTemplatedListPtr<DtRwString, true>(name, parentRegistry) {};
162  DtRwTemplatedStringList(const DtSymbolString& name, DtReaderWriterRegistry* parentRegistry = NULL)
163  : DtRwTemplatedListPtr<DtRwString, true>(name, parentRegistry) {};
164 
166  DtReaderWriterRegistry* parentRegistry = NULL)
167  : DtRwTemplatedListPtr<DtRwString, true>(name, orig, parentRegistry) {};
168 
170  DtReaderWriterRegistry* parentRegistry = NULL)
171  : DtRwTemplatedListPtr<DtRwString, true>(name, orig, parentRegistry) {};
172 
174  DtReaderWriterRegistry* parentRegistry = NULL)
175  : DtRwTemplatedListPtr<DtRwString, true>(orig, parentRegistry) {};
176 };
177 
179 {
180 public:
183 
185  DtRwTemplatedUUIDList(const DtString& name, DtReaderWriterRegistry* parentRegistry = NULL)
186  : DtRwTemplatedListPtr<DtRwUUID, true>(name, parentRegistry) {};
187  DtRwTemplatedUUIDList(const DtSymbolString& name, DtReaderWriterRegistry* parentRegistry = NULL)
188  : DtRwTemplatedListPtr<DtRwUUID, true>(name, parentRegistry) {};
189 
191  DtReaderWriterRegistry* parentRegistry = NULL)
192  : DtRwTemplatedListPtr<DtRwUUID, true>(name, orig, parentRegistry) {};
193 
195  DtReaderWriterRegistry* parentRegistry = NULL)
196  : DtRwTemplatedListPtr<DtRwUUID, true>(name, orig, parentRegistry) {};
197 
199  DtReaderWriterRegistry* parentRegistry = NULL)
200  : DtRwTemplatedListPtr<DtRwUUID, true>(orig, parentRegistry) {};
201 };
202 
204 {
205 public:
208 
210  DtRwTemplatedIntList(const DtString& name, DtReaderWriterRegistry* parentRegistry = NULL)
211  : DtRwTemplatedListPtr<DtRwInt, true>(name, parentRegistry) {};
212 
213  DtRwTemplatedIntList(const DtSymbolString& name, DtReaderWriterRegistry* parentRegistry = NULL)
214  : DtRwTemplatedListPtr<DtRwInt, true>(name, parentRegistry) {};
215 
217  DtReaderWriterRegistry* parentRegistry = NULL)
218  : DtRwTemplatedListPtr<DtRwInt, true>(name, orig, parentRegistry) {};
219 
221  DtReaderWriterRegistry* parentRegistry = NULL)
222  : DtRwTemplatedListPtr<DtRwInt, true>(name, orig, parentRegistry) {};
223 
225  DtReaderWriterRegistry* parentRegistry = NULL)
226  : DtRwTemplatedListPtr<DtRwInt, true>(orig, parentRegistry) {};
227 };
228 
230 {
231 public:
234 
236  DtRwTemplatedRealList(const DtString& name, DtReaderWriterRegistry* parentRegistry = NULL)
237  : DtRwTemplatedListPtr<DtRwReal, true>(name, parentRegistry) {};
238 
239  DtRwTemplatedRealList(const DtSymbolString& name, DtReaderWriterRegistry* parentRegistry = NULL)
240  : DtRwTemplatedListPtr<DtRwReal, true>(name, parentRegistry) {};
241 
243  DtReaderWriterRegistry* parentRegistry = NULL)
244  : DtRwTemplatedListPtr<DtRwReal, true>(name, orig, parentRegistry) {};
245 
247  DtReaderWriterRegistry* parentRegistry = NULL)
248  : DtRwTemplatedListPtr<DtRwReal, true>(name, orig, parentRegistry) {};
249 
251  DtReaderWriterRegistry* parentRegistry = NULL)
252  : DtRwTemplatedListPtr<DtRwReal, true>(orig, parentRegistry) {};
253 };
254 
255 #include "vrfutil/rwTemplatedList.inl"
Definition: rwTemplatedList.h:178
DtRwTemplatedRealList(const DtString &name, const DtRwTemplatedRealList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:242
DtRwTemplatedUUIDList(const DtSymbolString &name, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:187
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:198
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:203
Definition: symbolString.h:20
DtRwTemplatedStringList(const DtSymbolString &name, const DtRwTemplatedStringList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:169
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:129
bool operator!=(const DtRwTemplatedListPtr &) const
DT_DLL_readerWriter DtBoost::shared_ptr< DtEnvironment > DtEnvironmentSP
Definition: readerWriter.h:30
DtRwTemplatedStringList(const DtString &name, DtReaderWriterRegistry *parentRegistry=NULL)
real constructor
Definition: rwTemplatedList.h:160
DtRwTemplatedListPtr & operator=(const DtRwTemplatedListPtr &orig)
Definition: rwTemplatedList.h:229
DtRwTemplatedUUIDList(const DtString &name, const DtRwTemplatedUUIDList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:190
Definition: readerWriter.h:85
Description: Readable, Writable DtString Variable substitutions are done on this object when it is re...
Definition: rwString.h:20
void copyList(const DtRwTemplatedListPtr &orig)
DtRwTemplatedRealList(const DtRwTemplatedRealList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:250
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:98
Definition: readerWriterRegistry.h:39
Contains the DtUUID class declaration.
DtRwTemplatedStringList(const DtSymbolString &name, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:162
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:233
Description: Readable, Writable uuid string. Use this class in order to convert from object marking t...
Definition: rwUUID.h:431
virtual const char * xmlType() const
Routines to archive/dearchive from an XML Environment.
Definition: rwTemplatedList.h:104
virtual DtListItem * add(T *data)
Define this function to hide the DtRwList version, and accept only the specific DtReaderWriter subcla...
Definition: rwTemplatedList.h:80
static const char * ListReaderWriterType()
DtIteratorBase< T > iterator
Definition: rwTemplatedList.h:29
DtRwTemplatedIntList(const DtRwTemplatedIntList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:224
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:236
virtual std::set< DtString > supportedXmlTypes() const
Returns list of supported types. Default is the templated object xml type.
DtRwTemplatedIntList(const DtSymbolString &name, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:213
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:239
Description: Readable, Writable int.
Definition: rwInt.h:25
DtRwTemplatedStringList(const DtRwTemplatedStringList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:173
std::vector< DtFilename > SearchPaths
Definition: readerWriter.h:92
DtRwTemplatedUUIDList(const DtSymbolString &name, const DtRwTemplatedUUIDList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:194
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:157
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:58
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
DtIteratorBase< const T > const_iterator
Definition: rwTemplatedList.h:30
Definition: rwTemplatedList.h:153
A version of DtRwList that contains a homogeneous list of a templated RW type. The templated type spe...
Definition: rwTemplatedList.h:26
#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:207
DtRwTemplatedRealList(const DtSymbolString &name, const DtRwTemplatedRealList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:246
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:210
void removeAndDeleteAll()
Removes and deletes all entries in the list.
DtRwTemplatedIntList(const DtString &name, const DtRwTemplatedIntList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:216
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:182
virtual DtSymbolString name() const
Accessor for name of this readable/writable object.
DtRwTemplatedUUIDList(const DtString &name, DtReaderWriterRegistry *parentRegistry=NULL)
real constructor
Definition: rwTemplatedList.h:185
DtRwTemplatedIntList(const DtSymbolString &name, const DtRwTemplatedIntList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:220
DtRwTemplatedStringList(const DtString &name, const DtRwTemplatedStringList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
Definition: rwTemplatedList.h:165

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)