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