VR-Forces 5.0.1 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
libbdiobject_array_definition_template.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 2019 VT MAK
4  ** All rights reserved.
5  *********************************************************************/
6 
10 
11 #include <math.h>
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15 #include <assert.h>
16 
17 #include <libbdilog.h>
18 #include <new_strdup.h>
19 #include <bdiDataTracker.h>
20 #include <bdi_macros.h>
21 
22 #define CLASS_NAME_AS_STRING(x) xCLASS_NAME_AS_STRING(x)
23 #define xCLASS_NAME_AS_STRING(x) #x
24 
25 #ifdef LIBBDIOBJECT_ARRAY_INLINE
26 #define BDI_INLINE inline
27 #else
28 #define BDI_INLINE
29 #endif
30 
31 namespace makVrv
32 {
33  /****************************************************************************/
36  int increment)
37  :
38  data_tracker(new bdiDataTracker())
39 {
40  assert(data_tracker);
41 
42  if (initial_size < 1)
43  initial_size = 1;
44  if (increment < 1)
45  increment = 1;
46 
47  /*
48  * Allocate memory.
49  */
50  m_num_objects_allocated = initial_size;
52  if (!m_objects)
53  {
54  bdi_log_printf(BDI_LOG_ERROR,
55  "ERROR: Array out of memory trying to allocate %d objects.\n",
56  initial_size);
57  }
58 
59  /*
60  * Set newly allocated objects to NULL.
61  */
63 
64  /*
65  * Set more data members.
66  */
67  m_num_objects = 0;
68  m_own_objects = 0;
69  m_array_delete = 0;
72  m_name = new_strdup("");
73  m_increment = increment;
74 
75  data_tracker->raise_modified_all();
76 }
77 
78 
79 /****************************************************************************/
80 // virtual
83 {
84  if (m_objects)
85  {
86  if (m_own_objects)
87  {
89  {
91  while ((object = pop_back()))
92  {
93  if (m_array_delete)
94  delete[] object;
95  else
96  delete object;
97 
98  object = NULL;
99  }
100  }
101  else
102  {
103  int i;
104  int size = m_num_objects;
105  for (i = 0; i < size; i++)
106  {
107  if (m_array_delete)
108  delete[] m_objects[i];
109  else
110  delete m_objects[i];
111 
112  m_objects[i] = NULL;
113  }
114  }
115  }
116 
117  m_num_objects = 0;
118 
119  if (data_tracker)
120  data_tracker->raise_modified_all();
121 
122  delete[] m_objects;
123  m_objects = NULL;
124  }
125 
126  if (m_name)
127  delete[] m_name;
128  m_name = NULL;
129 
130  delete data_tracker;
131  data_tracker = NULL;
132 }
133 
134 
135 /****************************************************************************/
136 BDI_INLINE int
138 {
139  return insert_at_index(0, object);
140 }
141 
142 
143 /****************************************************************************/
144 BDI_INLINE int
146 {
147  /*
148  * See if we need to allocate more space.
149  */
151  return -1;
152 
153  /*
154  * Set the information for this object.
155  */
156  m_objects[m_num_objects] = object;
157  m_num_objects++;
158 
159  data_tracker->raise_modified_all();
160 
161  return 0;
162 }
163 
164 /****************************************************************************/
167 {
168  if ((index < 0) ||
169  (index > m_num_objects))
170  {
171  return NULL;
172  }
173 
174  LIBBDIOBJECT_ARRAY_TYPE* object = m_objects[index];
175  m_objects[index] = object_ptr;
176 
177  data_tracker->raise_modified_all();
178 
179  return object;
180 }
181 
182 
183 /****************************************************************************/
184 BDI_INLINE int
186 {
187  int i;
188 
189  if ((index < 0) ||
190  (index > m_num_objects))
191  {
192  return -1;
193  }
194 
195  /*
196  * Make sure we have enough memory allocated.
197  */
199  return -1;
200 
201  /*
202  * Shift all objects after the specified object right.
203  */
204  for (i = m_num_objects; i > index; i--)
205  m_objects[i] = m_objects[i - 1];
206 
207  /*
208  * Add the object at index.
209  */
210  m_objects[index] = object_ptr;
211 
212  m_num_objects += 1;
213 
214  data_tracker->raise_modified_all();
215 
216  return 0;
217 }
218 
219 
220 /****************************************************************************/
223 {
224  return remove_at_index(0);
225 }
226 
227 
228 /****************************************************************************/
231 {
232  LIBBDIOBJECT_ARRAY_TYPE* object = NULL;
233 
234  if (m_num_objects == 0)
235  return NULL;
236 
237  object = m_objects[m_num_objects - 1];
238  m_num_objects -= 1;
239 
240  data_tracker->raise_modified_all();
241 
242  return object;
243 }
244 
245 
246 /****************************************************************************/
249 {
250  LIBBDIOBJECT_ARRAY_TYPE* object = NULL;
251  int i;
252 
253  if ((index < 0) ||
254  (index >= m_num_objects))
255  {
256  return NULL;
257  }
258 
259  object = m_objects[index];
260 
261  /*
262  * Shift all objects after the specified object left.
263  */
264  for (i = index; i < (m_num_objects - 1); i++)
265  m_objects[i] = m_objects[i + 1];
266 
267  m_objects[m_num_objects - 1] = NULL;
268 
269  m_num_objects -= 1;
270 
271  data_tracker->raise_modified_all();
272 
273  return object;
274 }
275 
276 
277 /****************************************************************************/
278 BDI_INLINE int
280 {
281  LIBBDIOBJECT_ARRAY_TYPE* object = NULL;
282 
283  if ((index < 0) ||
284  (index >= m_num_objects))
285  {
286  return -1;
287  }
288 
289  object = remove_at_index(index);
290  if (!object)
291  return -1;
292 
293  if (m_array_delete)
294  delete[] object;
295  else
296  delete object;
297 
298  return 0;
299 }
300 
301 
302 /****************************************************************************/
305 {
306  int i;
307  int index = -1;
308 
309  /*
310  * Find the passed pointer in m_objects.
311  */
312  for (i = 0; (i < m_num_objects && (index == -1)); i++)
313  {
314  if (object == m_objects[i])
315  index = i;
316  }
317 
318  if (index != -1)
319  return remove_at_index(index);
320 
321  return NULL;
322 }
323 
324 
325 /****************************************************************************/
326 BDI_INLINE int
328 {
329  if (m_objects)
330  {
331  if (m_own_objects)
332  {
333  if (m_pop_back_delete)
334  {
335  LIBBDIOBJECT_ARRAY_TYPE* object;
336  while ((object = pop_back()))
337  {
338  if (m_array_delete)
339  delete[] object;
340  else
341  delete object;
342  }
343  }
344  else
345  {
346  int i;
347  int size = m_num_objects;
348  for (i = 0; i < size; i++)
349  {
350  if (m_array_delete)
351  delete[] m_objects[i];
352  else
353  delete m_objects[i];
354  }
355  }
356  }
357  if (m_num_objects != 0)
358  {
359  m_num_objects = 0;
360  data_tracker->raise_modified_all();
361  }
362  }
363 
364  return 0;
365 }
366 
367 
368 /****************************************************************************/
371 {
372 
373 #ifdef LIBBDIOBJECT_ARRAY_DISABLE_BOUNDS_CHECKING
374 
375  assert((index >= 0) && (index < m_num_objects));
376 
377 #else
378 
379  if ((index < 0) ||
380  (index >= m_num_objects))
381  {
382 #ifdef BDI_DEBUG
383  bdi_log_printf(BDI_LOG_WARN, "WARNING: Index %d out of bounds in %s; legal indices are %d to %d.\n",
384  index,
386  0,
387  m_num_objects - 1);
388 #endif
389 
390  return NULL;
391  }
392 
393 #endif
394 
395  return m_objects[index];
396 }
397 
398 
399 /****************************************************************************/
402 {
403 
404 #ifdef LIBBDIOBJECT_ARRAY_DISABLE_BOUNDS_CHECKING
405 
406  assert((index >= 0) && (index < m_num_objects));
407 
408 #else
409 
410  if ((index < 0) ||
411  (index >= m_num_objects))
412  {
413 #ifdef BDI_DEBUG
414  bdi_log_printf(BDI_LOG_WARN, "WARNING: Index %d out of bounds in %s; legal indices are %d to %d.\n",
415  index,
417  0,
418  m_num_objects - 1);
419 #endif
420 
421  return NULL;
422  }
423 
424 #endif
425 
426  return m_objects[index];
427 }
428 
429 
430 /****************************************************************************/
431 BDI_INLINE int
433 {
434  int i;
435 
436  /*
437  * Find the passed pointer in m_objects.
438  */
439  for (i = 0; i < m_num_objects; i++)
440  {
441  if (object == m_objects[i])
442  return i;
443  }
444 
445  return -1;
446 }
447 
448 
449 /****************************************************************************/
450 BDI_INLINE void
452  const LIBBDIOBJECT_ARRAY_CLASS_NAME& src) const
453 {
454  BDI_ASSERT_AND_RET_IF_NULL(indices);
455  assert(m_num_objects >= 0);
456 
457  // for small objects, do it the original way
458  if ((m_num_objects < 4) || (src.size() < 4))
459  {
460  int i;
461  for (i = 0; i < src.size(); i++)
462  {
463  indices[i] = get_index(src[i]);
464  }
465  return;
466  }
467 
468  // uses open address hashtables, see CLR pg 232
469 
470  // find the first power of two at least twice as large as m_num_objects
471  unsigned int htsize = 2;
472  while (htsize < (2 * (unsigned int)m_num_objects)) htsize <<= 1;
473  assert(htsize); /* overflow */
474 
475  unsigned int i, j;
476  int k;
477 
478  // initialize the hashtable
479  int *htvals = new int[htsize];
480  for (i = 0; i < htsize; i++)
481  {
482  htvals[i] = -1;
483  }
484 
485 #ifdef BDI_DEBUG
486  unsigned int total_search = 0;
487  unsigned int longest_search = 0;
488 #endif
489 
490  // populate the hashtable
491  for (k = 0; k < m_num_objects; k++)
492  {
493  LIBBDIOBJECT_ARRAY_TYPE* lookfor = m_objects[k];
494  unsigned int h1 = ((unsigned int)(lookfor - m_objects[0])) % htsize;
495  unsigned int h2 = (((unsigned int)(lookfor - m_objects[0])) * 2 + 1) % htsize;
496  for (i = 0; i <= htsize; i++)
497  {
498  j = (h1 + i * h2) % htsize;
499  if (htvals[j] == -1)
500  {
501  htvals[j] = k;
502  break;
503  }
504  else if (m_objects[htvals[j]] == lookfor)
505  {
506  // do not insert duplicate entry
507  break;
508  }
509  }
510  assert(i <= htsize);//overflow
511 #ifdef BDI_DEBUG
512  total_search += i;
513  if (i > longest_search)
514  {
515  longest_search = i;
516  }
517 #endif
518  }
519 
520 #ifdef BDI_DEBUG
521  bdi_log_printf(BDI_LOG_DEBUG_LV6, "libbdiobject_array::get_indices: n = %d, m = %u, total = %u, longest = %u, avg = %g\n",
522  m_num_objects, htsize, total_search, longest_search, m_num_objects ? (((double)total_search) / m_num_objects) : 0.0);
523 #endif
524 
525  // now search the hashtable
526  int nk = src.size();
527  for (k = 0; k < nk; k++)
528  {
529  LIBBDIOBJECT_ARRAY_TYPE* lookfor = src[k];
530  unsigned int h1 = ((unsigned int)(lookfor - m_objects[0])) % htsize;
531  unsigned int h2 = (((unsigned int)(lookfor - m_objects[0])) * 2 + 1) % htsize;
532  indices[k] = -1;
533  for (i = 0; i <= htsize; i++)
534  {
535  j = (h1 + i * h2) % htsize;
536  if ((m_objects[htvals[j]] == lookfor) || (htvals[j] == -1))
537  {
538  indices[k] = htvals[j];
539  break;
540  }
541  }
542  }
543 
544  delete[] htvals;
545 }
546 
547 
548 /****************************************************************************/
549 BDI_INLINE void
551  const LIBBDIOBJECT_ARRAY_CLASS_NAME& src) const
552 {
553  BDI_ASSERT_AND_RET_IF_NULL(indices);
554  assert(m_num_objects >= 0);
555 
556  // for small objects, do it the original way
557  if ((m_num_objects < 4) || (src.size() < 4))
558  {
559  int i;
560  for (i = 0; i < src.size(); i++)
561  {
562  indices[i] = (unsigned short)get_index(src[i]);
563  }
564  return;
565  }
566 
567  // uses open address hashtables, see CLR pg 232
568 
569  // find the first power of two at least twice as large as m_num_objects
570  unsigned int htsize = 2;
571  while (htsize < (2 * (unsigned int)m_num_objects)) htsize <<= 1;
572  assert(htsize); /* overflow */
573 
574  unsigned int i, j;
575  int k;
576 
577  // initialize the hashtable
578  int *htvals = new int[htsize];
579  for (i = 0; i < htsize; i++)
580  {
581  htvals[i] = -1;
582  }
583 
584 #ifdef BDI_DEBUG
585  unsigned int total_search = 0;
586  unsigned int longest_search = 0;
587 #endif
588 
589  // populate the hashtable
590  for (k = 0; k < m_num_objects; k++)
591  {
592  LIBBDIOBJECT_ARRAY_TYPE* lookfor = m_objects[k];
593  unsigned int h1 = ((unsigned int)(lookfor - m_objects[0])) % htsize;
594  unsigned int h2 = (((unsigned int)(lookfor - m_objects[0])) * 2 + 1) % htsize;
595  for (i = 0; i <= htsize; i++)
596  {
597  j = (h1 + i * h2) % htsize;
598  if (htvals[j] == -1)
599  {
600  htvals[j] = k;
601  break;
602  }
603  else if (m_objects[htvals[j]] == lookfor)
604  {
605  // do not insert duplicate entry
606  break;
607  }
608  }
609  assert(i <= htsize);//overflow
610 #ifdef BDI_DEBUG
611  total_search += i;
612  if (i > longest_search)
613  {
614  longest_search = i;
615  }
616 #endif
617  }
618 
619 #ifdef BDI_DEBUG
620  bdi_log_printf(BDI_LOG_DEBUG_LV6, "libbdiobject_array::get_indices: n = %d, m = %u, total = %u, longest = %u, avg = %g\n",
621  m_num_objects, htsize, total_search, longest_search, m_num_objects ? (((double)total_search) / m_num_objects) : 0.0);
622 #endif
623 
624  // now search the hashtable
625  int nk = src.size();
626  for (k = 0; k < nk; k++)
627  {
628  LIBBDIOBJECT_ARRAY_TYPE* lookfor = src[k];
629  unsigned int h1 = ((unsigned int)(lookfor - m_objects[0])) % htsize;
630  unsigned int h2 = (((unsigned int)(lookfor - m_objects[0])) * 2 + 1) % htsize;
631  indices[k] = (unsigned short)-1;
632  for (i = 0; i <= htsize; i++)
633  {
634  j = (h1 + i * h2) % htsize;
635  if ((m_objects[htvals[j]] == lookfor) || (htvals[j] == -1))
636  {
637  indices[k] = (unsigned short)htvals[j];
638  break;
639  }
640  }
641  }
642 
643  delete[] htvals;
644 }
645 
646 
647 /****************************************************************************/
648 BDI_INLINE int
650 {
651  if (m_num_objects_allocated == new_num_objects)
652  return 0;
653 
654  int i;
655 
656  LIBBDIOBJECT_ARRAY_TYPE** old_objects = m_objects;
657  int old_num_objects = m_num_objects;
658  int old_num_objects_allocated = m_num_objects_allocated;
659 
660  if (new_num_objects > m_num_objects_allocated)
661  {
662  // need to grow the array.
663  m_num_objects_allocated = new_num_objects;
664 
666  if (m_objects == NULL)
667  {
668  bdi_log_printf(BDI_LOG_ERROR, "ERROR: %s %d Out of memory.\n",
669  __FILE__, __LINE__);
670  return -1;
671  }
672 
673  /*
674  * Transfer old objects to new objects. Don't set m_num_objects.
675  */
676  memcpy(m_objects, old_objects, old_num_objects_allocated * sizeof(LIBBDIOBJECT_ARRAY_TYPE*));
677 
683  memset(&m_objects[old_num_objects_allocated],
684  0,
685  (m_num_objects_allocated - old_num_objects_allocated) * sizeof(LIBBDIOBJECT_ARRAY_TYPE*));
686 
687  /*
688  * Delete old objects.
689  */
690  delete[] old_objects;
691  return 0;
692  }
693 
694  /*
695  * Need to shrink the array.
696  *
697  * If m_num_objects_allocated is 0, set it to 1 to avoid
698  * a new error.
699  */
700  m_num_objects_allocated = new_num_objects;
701 
702  if (m_num_objects_allocated == 0)
703  {
705  m_num_objects = 0;
706  }
707 
709  if (m_objects == NULL)
710  {
711  bdi_log_printf(BDI_LOG_ERROR, "ERROR: %s %d Out of memory.\n",
712  __FILE__, __LINE__);
713  return -1;
714  }
715 
716  /*
717  * Transfer old objects to new objects. Use new_num_objects
718  * instead of m_num_objects_allocated in case we changed
719  * m_num_objects_allocated to 1 above.
720  */
721  memcpy(m_objects, old_objects, new_num_objects * sizeof(LIBBDIOBJECT_ARRAY_TYPE*));
722 
723  if (m_num_objects > new_num_objects)
724  m_num_objects = new_num_objects;
725 
726  /*
727  * Delete appropriate old_objects. Again, use new_num_objects.
728  */
729  if (m_own_objects)
730  {
731  for (i = new_num_objects; i < old_num_objects; i++)
732  {
733  if (m_array_delete)
734  delete[] old_objects[i];
735  else
736  delete old_objects[i];
737  }
738  }
739 
740  /*
741  * Delete old objects.
742  */
743  delete[] old_objects;
744  return 0;
745 }
746 
747 
748 /****************************************************************************/
749 BDI_INLINE int
751 {
752  /*
753  * See if we need to allocate more space.
754  */
755  if (m_num_objects_allocated < min_objects)
756  {
757  LIBBDIOBJECT_ARRAY_TYPE** old_objects = m_objects;
758  int old_num_objects_allocated = m_num_objects_allocated;
759 
760  if (m_geometric_growth)
761  {
762  //use a doubling method to grow the arrays
763  if (m_num_objects_allocated > 0)
765  else
767  }
768  else
769  {
770  /*
771  * If we need to allocate more objects, add at least
772  * m_increment more.
773  */
775  }
776  if (m_num_objects_allocated < min_objects)
777  m_num_objects_allocated = min_objects;
778 
780  if (m_objects == NULL)
781  {
782  bdi_log_printf(BDI_LOG_ERROR, "ERROR: %s %d Out of memory.\n",
783  __FILE__, __LINE__);
784  return -1;
785  }
786 
787  /*
788  * Transfer old objects to new objects.
789  */
790  if (old_num_objects_allocated > 0)
791  memcpy(m_objects,
792  old_objects,
793  old_num_objects_allocated * sizeof(LIBBDIOBJECT_ARRAY_TYPE*));
794 
795  memset(&m_objects[old_num_objects_allocated],
796  0,
797  (m_num_objects_allocated - old_num_objects_allocated) * sizeof(LIBBDIOBJECT_ARRAY_TYPE*));
798 
799  /*
800  * Delete old objects.
801  */
802  delete[] old_objects;
803  }
804 
805  return 0;
806 }
807 
808 
809 /****************************************************************************/
810 BDI_INLINE const char*
812 {
813  return m_name;
814 }
815 
816 
817 /****************************************************************************/
818 BDI_INLINE void
820 {
821  if (m_name)
822  {
823  delete[] m_name;
824  m_name = NULL;
825  }
826 
827  if (name && (strlen(name) > 0))
828  m_name = new_strdup(name);
829  else
830  m_name = new_strdup("");
831 }
832 
833 
834 #ifdef LIBBDIOBJECT_ARRAY_DEEP_COPY
835 
836 /****************************************************************************/
837 BDI_INLINE void
838 LIBBDIOBJECT_ARRAY_CLASS_NAME::deep_copy(const LIBBDIOBJECT_ARRAY_CLASS_NAME & rhs)
839 {
840  int i;
841 
842  // WARNING this code assumes that you manage the objects
843  remove_all();
844  resize_allocation(rhs.size());
845 
846  for (i = 0; i < rhs.size(); i++)
847  {
848  LIBBDIOBJECT_ARRAY_TYPE* new_object = new LIBBDIOBJECT_ARRAY_TYPE(*rhs.m_objects[i]);
849  push_back(new_object);
850  }
851 
852  data_tracker->raise_modified_all();
853 }
854 
855 #endif // LIBBDIOBJECT_ARRAY_DEEP_COPY
856 
857 
858 #ifdef LIBBDIOBJECT_ARRAY_PACKABLE
859 
860 /****************************************************************************/
861 BDI_INLINE bdiCfgEntry*
862 LIBBDIOBJECT_ARRAY_CLASS_NAME::create_cfg_entry(bdiCfgEntry *e, const char * array_name)
863 {
864  if (size() == 0)
865  return NULL;
866 
867  bdiCfgEntry* sub_ent = new bdiCfgEntry(array_name, "");
868  int i = 0;
869  for (i = 0; i < size(); i++)
870  {
871  bdiCfgEntryLine * l = new bdiCfgEntryLine("value");
872  m_objects[i]->pack_unpack(1, l);
873  sub_ent->add_line(l);
874  }
875 
876  if (e)
877  e->add_subentry(sub_ent);
878 
879  return sub_ent;
880 }
881 
882 
883 /****************************************************************************/
884 BDI_INLINE void
885 LIBBDIOBJECT_ARRAY_CLASS_NAME::parse_cfg_entry(bdiCfgEntry *e)
886 {
887  int i;
888 
889  resize_allocation(e->get_num_lines());
890 
891  for (i = 0; i < e->get_num_lines(); i++)
892  {
893  bdiCfgEntryLine * l = e->get_line(i);
894 
896  push_back(new_object);
897  new_object->pack_unpack(0, l);
898  }
899 
900  data_tracker->raise_modified_all();
901 }
902 
903 #endif // LIBBDIOBJECT_ARRAY_PACKABLE
904 
905 
906 #ifdef LIBBDIOBJECT_ARRAY_PACKABLE_SUBENTRIES
907 
908 /****************************************************************************/
909 BDI_INLINE bdiCfgEntry*
910 LIBBDIOBJECT_ARRAY_CLASS_NAME::create_cfg_entry(bdiCfgEntry *e, const char * array_name)
911 {
912  if (size() == 0)
913  return NULL;
914 
915  bdiCfgEntry* sub_ent = new bdiCfgEntry(array_name, "keys");
916  int i = 0;
917  for (i = 0; i < size(); i++)
918  {
919  bdiCfgEntry * l = new bdiCfgEntry("value", "");
920  m_objects[i]->pack_unpack(1, l);
921  sub_ent->add_subentry(l);
922  }
923 
924  if (e)
925  e->add_subentry(sub_ent);
926 
927  return sub_ent;
928 }
929 
930 
931 /****************************************************************************/
932 BDI_INLINE void
933 LIBBDIOBJECT_ARRAY_CLASS_NAME::parse_cfg_entry(bdiCfgEntry *e)
934 {
935  int i;
936 
937  resize_allocation(e->get_num_subentries());
938 
939  for (i = 0; i < e->get_num_subentries(); i++)
940  {
941  bdiCfgEntry * l = e->get_subentry(i);
942 
944  push_back(new_object);
945  new_object->pack_unpack(0, l);
946  }
947 
948  data_tracker->raise_modified_all();
949 }
950 
951 #endif // LIBBDIOBJECT_ARRAY_PACKABLE_SUBENTRIES
952 
953 /****************************************************************************/
954 BDI_INLINE size_t
956 {
957  size_t retval = 0;
958  retval += sizeof(*this);
959  if (m_name) {
960  retval += strlen(m_name) * sizeof(char);
961  }
962  retval += m_num_objects_allocated * sizeof(LIBBDIOBJECT_ARRAY_TYPE *);
963  retval += get_children_memory_usage();
964  return retval;
965 }
966 
967 /****************************************************************************/
968 BDI_INLINE size_t
970 {
971  size_t retval = 0;
972  if (m_own_objects) {
973 #ifdef LIBBDIOBJECT_GET_MEMORY_USAGE
974  int i;
975  for (i = 0; i < m_num_objects; i++)
976  {
977  retval += m_objects[i]->get_memory_usage();
978  }
979 #else
980  retval += sizeof(LIBBDIOBJECT_ARRAY_TYPE)*m_num_objects;
981 #endif
982  }
983  return retval;
984 }
985 
986 #ifdef BDI_INLINE
987 #undef BDI_INLINE
988 #endif
989 }
LIBBDIOBJECT_ARRAY_TYPE ** m_objects
Definition: libbdiobject_array_declaration_template.h:324
BDI_INLINE LIBBDIOBJECT_ARRAY_TYPE * remove(LIBBDIOBJECT_ARRAY_TYPE *object)
Definition: libbdiobject_array_definition_template.h:304
bdiDataTracker * data_tracker
Definition: libbdiobject_array_declaration_template.h:294
virtual size_t get_memory_usage()
Definition: libbdiobject_array_definition_template.h:955
#define BDI_INLINE
Definition: libbdiobject_array_definition_template.h:28
virtual size_t get_children_memory_usage()
Definition: libbdiobject_array_definition_template.h:969
int m_geometric_growth
Definition: libbdiobject_array_declaration_template.h:356
BDI_INLINE LIBBDIOBJECT_ARRAY_CLASS_NAME(int initial_size=16, int increment=16)
Definition: libbdiobject_array_definition_template.h:35
BDI_INLINE int resize_allocation(int num_objects)
Definition: libbdiobject_array_definition_template.h:649
voidpf void uLong size
Definition: ioapi.h:39
BDI_INLINE int size(void) const
Definition: libbdiobject_array_declaration_template.h:178
BDI_INLINE LIBBDIOBJECT_ARRAY_TYPE * operator[](int index) const
Definition: libbdiobject_array_definition_template.h:401
BDI_INLINE int push_back(LIBBDIOBJECT_ARRAY_TYPE *object)
Definition: libbdiobject_array_definition_template.h:145
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
BDI_INLINE LIBBDIOBJECT_ARRAY_TYPE * replace_at_index(int index, LIBBDIOBJECT_ARRAY_TYPE *object)
Definition: libbdiobject_array_definition_template.h:166
Definition: libbdiobject_array_declaration_template.h:40
int m_pop_back_delete
Definition: libbdiobject_array_declaration_template.h:341
BDI_INLINE int remove_all(void)
Definition: libbdiobject_array_definition_template.h:327
BDI_INLINE int get_index(LIBBDIOBJECT_ARRAY_TYPE *object) const
Definition: libbdiobject_array_definition_template.h:432
#define CLASS_NAME_AS_STRING(x)
Definition: libbdiobject_array_definition_template.h:22
BDI_INLINE LIBBDIOBJECT_ARRAY_TYPE * pop_back(void)
Definition: libbdiobject_array_definition_template.h:230
#define LIBBDIOBJECT_ARRAY_TYPE
Definition: DtFxCollisionObject.h:138
char * m_name
Definition: libbdiobject_array_declaration_template.h:346
int m_num_objects_allocated
Definition: libbdiobject_array_declaration_template.h:318
BDI_INLINE void set_name(const char *name)
Definition: libbdiobject_array_definition_template.h:819
BDI_INLINE const char * get_name(void) const
Definition: libbdiobject_array_definition_template.h:811
BDI_INLINE LIBBDIOBJECT_ARRAY_TYPE * remove_at_index(int index)
Definition: libbdiobject_array_definition_template.h:248
BDI_INLINE int push_front(LIBBDIOBJECT_ARRAY_TYPE *object)
Definition: libbdiobject_array_definition_template.h:137
int m_num_objects
Definition: libbdiobject_array_declaration_template.h:313
BDI_INLINE LIBBDIOBJECT_ARRAY_TYPE * get_at_index(int index) const
Definition: libbdiobject_array_definition_template.h:370
int m_own_objects
Definition: libbdiobject_array_declaration_template.h:330
BDI_INLINE void get_indices(int *indices, const LIBBDIOBJECT_ARRAY_CLASS_NAME &src) const
Definition: libbdiobject_array_definition_template.h:451
BDI_INLINE void get_ushort_indices(unsigned short *indices, const LIBBDIOBJECT_ARRAY_CLASS_NAME &src) const
Definition: libbdiobject_array_definition_template.h:550
int m_increment
Definition: libbdiobject_array_declaration_template.h:351
BDI_INLINE int insert_at_index(int index, LIBBDIOBJECT_ARRAY_TYPE *object)
Definition: libbdiobject_array_definition_template.h:185
int m_array_delete
Definition: libbdiobject_array_declaration_template.h:336
BDI_INLINE LIBBDIOBJECT_ARRAY_TYPE * pop_front(void)
Definition: libbdiobject_array_definition_template.h:222
virtual BDI_INLINE ~LIBBDIOBJECT_ARRAY_CLASS_NAME()
Definition: libbdiobject_array_definition_template.h:82
BDI_INLINE int delete_at_index(int index)
Definition: libbdiobject_array_definition_template.h:279
BDI_INLINE int check_object_allocation(int min_objects)
Definition: libbdiobject_array_definition_template.h:750

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)