Torque3D Documentation / _generateds / simObjectList.h

simObjectList.h

Engine/source/console/simObjectList.h

More...

Classes:

class

A vector of SimObjects.

Detailed Description

 1
 2//-----------------------------------------------------------------------------
 3// Copyright (c) 2012 GarageGames, LLC
 4//
 5// Permission is hereby granted, free of charge, to any person obtaining a copy
 6// of this software and associated documentation files (the "Software"), to
 7// deal in the Software without restriction, including without limitation the
 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 9// sell copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21// IN THE SOFTWARE.
22//-----------------------------------------------------------------------------
23
24#ifndef _SIMOBJECTLIST_H_
25#define _SIMOBJECTLIST_H_
26
27#ifndef _TVECTOR_H_
28#include "core/util/tVector.h"
29#endif
30#ifndef _TALGORITHM_H_
31#include "core/tAlgorithm.h"
32#endif
33#ifndef _TORQUE_STRING_H_
34#include "core/util/str.h"
35#endif
36
37// Forward Refs
38class SimObject;
39
40/// A vector of SimObjects.
41///
42/// As this inherits from VectorPtr, it has the full range of vector methods.
43class SimObjectList : public VectorPtr<SimObject*>
44{
45   /// The script callback function for the active sort.
46   /// @see scriptSort
47   static String smSortScriptCallbackFn;
48
49   /// The script callback comparision callback.
50   /// @see scriptSort
51   static S32 QSORT_CALLBACK _callbackSort(const void* a,const void* b);
52
53   /// The SimObjectId comparision sort callback.
54   /// @see sortId
55   static S32 QSORT_CALLBACK _compareId( const void *a, const void *b );
56   
57public:
58
59   bool pushBack(SimObject*);       ///< Add the SimObject* to the end of the list, unless it's already in the list.
60   bool pushBackForce(SimObject*);  ///< Add the SimObject* to the end of the list, moving it there if it's already present in the list.
61   bool pushFront(SimObject*);      ///< Add the SimObject* to the start of the list.
62   bool remove(SimObject*);         ///< Remove the SimObject* from the list; may disrupt order of the list.
63
64   SimObject* at(S32 index) const {  if(index >= 0 && index < size()) return (*this)[index]; return NULL; }
65   
66   /// Remove the SimObject* from the list; guaranteed to preserve list order.
67   bool removeStable(SimObject* pObject);
68
69   /// Performs a simple sort by SimObjectId.
70   void sortId();
71   
72   /// Performs a sort of the objects in the set using a script
73   /// callback function to do the comparision.
74   /// @see SimSet::scriptSort
75   void scriptSort( const String &scriptCallback );
76};
77
78#endif // _SIMOBJECTLIST_H_
79