6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
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:
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.
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.
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.
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.
35 // PoseList is a commonly used instance of BObjectList<BPose>
36 // Defines convenience find and iteration calls
41 #include <ObjectList.h>
54 class PoseList
: public BObjectList
<BPose
> {
56 PoseList(int32 itemsPerBlock
= 20, bool owning
= false)
58 BObjectList
<BPose
>(itemsPerBlock
, owning
)
62 PoseList(const PoseList
&list
)
64 BObjectList
<BPose
>(list
)
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;
76 BPose
* FindPoseByFileName(const char* name
, int32
* _index
= NULL
) const;
80 // iteration glue, add permutations as needed
83 template<class EachParam1
>
85 EachPoseAndModel(PoseList
* list
,
86 void (*eachFunction
)(BPose
*, Model
*, EachParam1
),
87 EachParam1 eachParam1
)
89 for (int32 index
= list
->CountItems() - 1; index
>= 0; index
--) {
90 BPose
* pose
= list
->ItemAt(index
);
91 Model
* model
= pose
->TargetModel();
93 (eachFunction
)(pose
, model
, eachParam1
);
98 template<class EachParam1
>
100 EachPoseAndModel(PoseList
* list
,
101 void (*eachFunction
)(BPose
*, Model
*, int32
, EachParam1
),
102 EachParam1 eachParam1
)
104 for (int32 index
= list
->CountItems() - 1; index
>= 0; index
--) {
105 BPose
* pose
= list
->ItemAt(index
);
106 Model
* model
= pose
->TargetModel();
108 (eachFunction
)(pose
, model
, index
, eachParam1
);
113 template<class EachParam1
, class EachParam2
>
115 EachPoseAndModel(PoseList
* list
,
116 void (*eachFunction
)(BPose
*, Model
*, EachParam1
, EachParam2
),
117 EachParam1 eachParam1
, EachParam2 eachParam2
)
119 for (int32 index
= list
->CountItems() - 1; index
>= 0; index
--) {
120 BPose
* pose
= list
->ItemAt(index
);
121 Model
* model
= pose
->TargetModel();
123 (eachFunction
)(pose
, model
, eachParam1
, eachParam2
);
128 template<class EachParam1
, class EachParam2
>
130 EachPoseAndModel(PoseList
* list
,
131 void (*eachFunction
)(BPose
*, Model
*, int32
, EachParam1
, EachParam2
),
132 EachParam1 eachParam1
, EachParam2 eachParam2
)
134 for (int32 index
= list
->CountItems() - 1; index
>= 0; index
--) {
135 BPose
* pose
= list
->ItemAt(index
);
136 Model
* model
= pose
->TargetModel();
138 (eachFunction
)(pose
, model
, index
, eachParam1
, eachParam2
);
143 template<class EachParam1
>
145 EachPoseAndResolvedModel(PoseList
* list
,
146 void (*eachFunction
)(BPose
*, Model
*, EachParam1
), EachParam1 eachParam1
)
148 for (int32 index
= list
->CountItems() - 1; index
>= 0; index
--) {
149 BPose
* pose
= list
->ItemAt(index
);
150 Model
* model
= pose
->TargetModel()->ResolveIfLink();
152 (eachFunction
)(pose
, model
, eachParam1
);
157 template<class EachParam1
>
159 EachPoseAndResolvedModel(PoseList
* list
,
160 void (*eachFunction
)(BPose
*, Model
*, int32
, EachParam1
),
161 EachParam1 eachParam1
)
163 for (int32 index
= list
->CountItems() - 1; index
>= 0; index
--) {
164 BPose
* pose
= list
->ItemAt(index
);
165 Model
* model
= pose
->TargetModel()->ResolveIfLink();
167 (eachFunction
)(pose
, model
, index
, eachParam1
);
172 template<class EachParam1
, class EachParam2
>
174 EachPoseAndResolvedModel(PoseList
* list
,
175 void (*eachFunction
)(BPose
*, Model
*, EachParam1
, EachParam2
),
176 EachParam1 eachParam1
, EachParam2 eachParam2
)
178 for (int32 index
= list
->CountItems() - 1; index
>= 0; index
--) {
179 BPose
* pose
= list
->ItemAt(index
);
180 Model
* model
= pose
->TargetModel()->ResolveIfLink();
182 (eachFunction
)(pose
, model
, eachParam1
, eachParam2
);
187 template<class EachParam1
, class EachParam2
>
189 EachPoseAndResolvedModel(PoseList
* list
,
190 void (*eachFunction
)(BPose
*, Model
*, int32
, EachParam1
, EachParam2
),
191 EachParam1 eachParam1
, EachParam2 eachParam2
)
193 for (int32 index
= list
->CountItems() - 1; index
>= 0; index
--) {
194 BPose
* pose
= list
->ItemAt(index
);
195 Model
* model
= pose
->TargetModel()->ResolveIfLink();
197 (eachFunction
)(pose
, model
, index
, eachParam1
, eachParam2
);
201 } // namespace BPrivate
203 using namespace BPrivate
;
206 #endif // _POSE_LIST_H