1/* 2Open Tracker License 3 4Terms and Conditions 5 6Copyright (c) 1991-2000, Be Incorporated. All rights reserved. 7 8Permission is hereby granted, free of charge, to any person obtaining a copy of 9this software and associated documentation files (the "Software"), to deal in 10the Software without restriction, including without limitation the rights to 11use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12of the Software, and to permit persons to whom the Software is furnished to do 13so, subject to the following conditions: 14 15The above copyright notice and this permission notice applies to all licensees 16and shall be included in all copies or substantial portions of the Software. 17 18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY, 20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 22AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION 23WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 25Except as contained in this notice, the name of Be Incorporated shall not be 26used in advertising or otherwise to promote the sale, use or other dealings in 27this Software without prior written authorization from Be Incorporated. 28 29Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks 30of Be Incorporated in the United States and other countries. Other brand product 31names are registered trademarks or trademarks of their respective holders. 32All rights reserved. 33*/ 34 35// PoseList is a commonly used instance of BObjectList<BPose> 36// Defines convenience find and iteration calls 37#ifndef _POSE_LIST_H 38#define _POSE_LIST_H 39 40 41#include <ObjectList.h> 42 43#include "Pose.h" 44 45 46struct node_ref; 47struct entry_ref; 48 49namespace BPrivate { 50 51class Model; 52 53 54class PoseList : public BObjectList<BPose> { 55public: 56 PoseList(int32 itemsPerBlock = 20, bool owning = false) 57 : 58 BObjectList<BPose>(itemsPerBlock, owning) 59 { 60 } 61 62 PoseList(const PoseList &list) 63 : 64 BObjectList<BPose>(list) 65 { 66 } 67 68 BPose* FindPose(const node_ref* node, int32* index = NULL) const; 69 BPose* FindPose(const entry_ref* entry, int32* index = NULL) const; 70 BPose* FindPose(const Model* model, int32* index = NULL) const; 71 BPose* DeepFindPose(const node_ref* node, int32* index = NULL) const; 72 // same as FindPose, node can be a target of the actual 73 // pose if the pose is a symlink 74 PoseList* FindAllPoses(const node_ref* node) const; 75 76 BPose* FindPoseByFileName(const char* name, int32* _index = NULL) const; 77}; 78 79 80// iteration glue, add permutations as needed 81 82 83template<class EachParam1> 84void 85EachPoseAndModel(PoseList* list, 86 void (*eachFunction)(BPose*, Model*, EachParam1), 87 EachParam1 eachParam1) 88{ 89 for (int32 index = list->CountItems() - 1; index >= 0; index--) { 90 BPose* pose = list->ItemAt(index); 91 Model* model = pose->TargetModel(); 92 if (model != NULL) 93 (eachFunction)(pose, model, eachParam1); 94 } 95} 96 97 98template<class EachParam1> 99void 100EachPoseAndModel(PoseList* list, 101 void (*eachFunction)(BPose*, Model*, int32, EachParam1), 102 EachParam1 eachParam1) 103{ 104 for (int32 index = list->CountItems() - 1; index >= 0; index--) { 105 BPose* pose = list->ItemAt(index); 106 Model* model = pose->TargetModel(); 107 if (model != NULL) 108 (eachFunction)(pose, model, index, eachParam1); 109 } 110} 111 112 113template<class EachParam1, class EachParam2> 114void 115EachPoseAndModel(PoseList* list, 116 void (*eachFunction)(BPose*, Model*, EachParam1, EachParam2), 117 EachParam1 eachParam1, EachParam2 eachParam2) 118{ 119 for (int32 index = list->CountItems() - 1; index >= 0; index--) { 120 BPose* pose = list->ItemAt(index); 121 Model* model = pose->TargetModel(); 122 if (model != NULL) 123 (eachFunction)(pose, model, eachParam1, eachParam2); 124 } 125} 126 127 128template<class EachParam1, class EachParam2> 129void 130EachPoseAndModel(PoseList* list, 131 void (*eachFunction)(BPose*, Model*, int32, EachParam1, EachParam2), 132 EachParam1 eachParam1, EachParam2 eachParam2) 133{ 134 for (int32 index = list->CountItems() - 1; index >= 0; index--) { 135 BPose* pose = list->ItemAt(index); 136 Model* model = pose->TargetModel(); 137 if (model != NULL) 138 (eachFunction)(pose, model, index, eachParam1, eachParam2); 139 } 140} 141 142 143template<class EachParam1> 144void 145EachPoseAndResolvedModel(PoseList* list, 146 void (*eachFunction)(BPose*, Model*, EachParam1), EachParam1 eachParam1) 147{ 148 for (int32 index = list->CountItems() - 1; index >= 0; index--) { 149 BPose* pose = list->ItemAt(index); 150 Model* model = pose->TargetModel()->ResolveIfLink(); 151 if (model != NULL) 152 (eachFunction)(pose, model, eachParam1); 153 } 154} 155 156 157template<class EachParam1> 158void 159EachPoseAndResolvedModel(PoseList* list, 160 void (*eachFunction)(BPose*, Model*, int32 , EachParam1), 161 EachParam1 eachParam1) 162{ 163 for (int32 index = list->CountItems() - 1; index >= 0; index--) { 164 BPose* pose = list->ItemAt(index); 165 Model* model = pose->TargetModel()->ResolveIfLink(); 166 if (model != NULL) 167 (eachFunction)(pose, model, index, eachParam1); 168 } 169} 170 171 172template<class EachParam1, class EachParam2> 173void 174EachPoseAndResolvedModel(PoseList* list, 175 void (*eachFunction)(BPose*, Model*, EachParam1, EachParam2), 176 EachParam1 eachParam1, EachParam2 eachParam2) 177{ 178 for (int32 index = list->CountItems() - 1; index >= 0; index--) { 179 BPose* pose = list->ItemAt(index); 180 Model* model = pose->TargetModel()->ResolveIfLink(); 181 if (model != NULL) 182 (eachFunction)(pose, model, eachParam1, eachParam2); 183 } 184} 185 186 187template<class EachParam1, class EachParam2> 188void 189EachPoseAndResolvedModel(PoseList* list, 190 void (*eachFunction)(BPose*, Model*, int32, EachParam1, EachParam2), 191 EachParam1 eachParam1, EachParam2 eachParam2) 192{ 193 for (int32 index = list->CountItems() - 1; index >= 0; index--) { 194 BPose* pose = list->ItemAt(index); 195 Model* model = pose->TargetModel()->ResolveIfLink(); 196 if (model != NULL) 197 (eachFunction)(pose, model, index, eachParam1, eachParam2); 198 } 199} 200 201} // namespace BPrivate 202 203using namespace BPrivate; 204 205 206#endif // _POSE_LIST_H 207