102be5353SAxel Dörfler/*
202be5353SAxel DörflerOpen Tracker License
302be5353SAxel Dörfler
402be5353SAxel DörflerTerms and Conditions
502be5353SAxel Dörfler
602be5353SAxel DörflerCopyright (c) 1991-2000, Be Incorporated. All rights reserved.
702be5353SAxel Dörfler
802be5353SAxel DörflerPermission is hereby granted, free of charge, to any person obtaining a copy of
902be5353SAxel Dörflerthis software and associated documentation files (the "Software"), to deal in
1002be5353SAxel Dörflerthe Software without restriction, including without limitation the rights to
1102be5353SAxel Dörfleruse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
1202be5353SAxel Dörflerof the Software, and to permit persons to whom the Software is furnished to do
1302be5353SAxel Dörflerso, subject to the following conditions:
1402be5353SAxel Dörfler
1502be5353SAxel DörflerThe above copyright notice and this permission notice applies to all licensees
1602be5353SAxel Dörflerand shall be included in all copies or substantial portions of the Software.
1702be5353SAxel Dörfler
1802be5353SAxel DörflerTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1902be5353SAxel DörflerIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
2002be5353SAxel DörflerFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
2102be5353SAxel DörflerBE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
2202be5353SAxel DörflerAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
2302be5353SAxel DörflerWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2402be5353SAxel Dörfler
2502be5353SAxel DörflerExcept as contained in this notice, the name of Be Incorporated shall not be
2602be5353SAxel Dörflerused in advertising or otherwise to promote the sale, use or other dealings in
2702be5353SAxel Dörflerthis Software without prior written authorization from Be Incorporated.
2802be5353SAxel Dörfler
2902be5353SAxel DörflerTracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
3002be5353SAxel Dörflerof Be Incorporated in the United States and other countries. Other brand product
3102be5353SAxel Dörflernames are registered trademarks or trademarks of their respective holders.
3202be5353SAxel DörflerAll rights reserved.
3302be5353SAxel Dörfler*/
3402be5353SAxel Dörfler
3502be5353SAxel Dörfler//	PoseList is a commonly used instance of BObjectList<BPose>
3602be5353SAxel Dörfler//	Defines convenience find and iteration calls
37fdb62486SJohn Scipione#ifndef _POSE_LIST_H
38fdb62486SJohn Scipione#define _POSE_LIST_H
39fdb62486SJohn Scipione
4002be5353SAxel Dörfler
41fdb62486SJohn Scipione#include <ObjectList.h>
4202be5353SAxel Dörfler
436d01b66dSAxel Dörfler#include "Pose.h"
4402be5353SAxel Dörfler
45b05aa8b5SJohn Scipione
4602be5353SAxel Dörflerstruct node_ref;
4702be5353SAxel Dörflerstruct entry_ref;
4802be5353SAxel Dörfler
4902be5353SAxel Dörflernamespace BPrivate {
5002be5353SAxel Dörfler
5102be5353SAxel Dörflerclass Model;
5202be5353SAxel Dörfler
53fdb62486SJohn Scipione
5402be5353SAxel Dörflerclass PoseList : public BObjectList<BPose> {
5502be5353SAxel Dörflerpublic:
5602be5353SAxel Dörfler	PoseList(int32 itemsPerBlock = 20, bool owning = false)
57fdb62486SJohn Scipione		:
58fdb62486SJohn Scipione		BObjectList<BPose>(itemsPerBlock, owning)
59fdb62486SJohn Scipione	{
60fdb62486SJohn Scipione	}
6102be5353SAxel Dörfler
6202be5353SAxel Dörfler	PoseList(const PoseList &list)
63fdb62486SJohn Scipione		:
64fdb62486SJohn Scipione		BObjectList<BPose>(list)
65fdb62486SJohn Scipione	{
66fdb62486SJohn Scipione	}
6702be5353SAxel Dörfler
68b05aa8b5SJohn Scipione	BPose* FindPose(const node_ref* node, int32* index = NULL) const;
69b05aa8b5SJohn Scipione	BPose* FindPose(const entry_ref* entry, int32* index = NULL) const;
70b05aa8b5SJohn Scipione	BPose* FindPose(const Model* model, int32* index = NULL) const;
71b05aa8b5SJohn Scipione	BPose* DeepFindPose(const node_ref* node, int32* index = NULL) const;
7202be5353SAxel Dörfler		// same as FindPose, node can be a target of the actual
7302be5353SAxel Dörfler		// pose if the pose is a symlink
74e0e641c0SPhilippe Saint-Pierre	PoseList* FindAllPoses(const node_ref* node) const;
751c29b26eSIngo Weinhold
761c29b26eSIngo Weinhold	BPose* FindPoseByFileName(const char* name, int32* _index = NULL) const;
7702be5353SAxel Dörfler};
7802be5353SAxel Dörfler
79fdb62486SJohn Scipione
8002be5353SAxel Dörfler// iteration glue, add permutations as needed
8102be5353SAxel Dörfler
82b05aa8b5SJohn Scipione
8302be5353SAxel Dörflertemplate<class EachParam1>
8402be5353SAxel Dörflervoid
85a51764c5SJohn ScipioneEachPoseAndModel(PoseList* list,
86a51764c5SJohn Scipione	void (*eachFunction)(BPose*, Model*, EachParam1),
8702be5353SAxel Dörfler	EachParam1 eachParam1)
8802be5353SAxel Dörfler{
8902be5353SAxel Dörfler	for (int32 index = list->CountItems() - 1; index >= 0; index--) {
90b05aa8b5SJohn Scipione		BPose* pose = list->ItemAt(index);
91b05aa8b5SJohn Scipione		Model* model = pose->TargetModel();
92fdb62486SJohn Scipione		if (model != NULL)
9302be5353SAxel Dörfler			(eachFunction)(pose, model, eachParam1);
9402be5353SAxel Dörfler	}
9502be5353SAxel Dörfler}
9602be5353SAxel Dörfler
97b05aa8b5SJohn Scipione
9802be5353SAxel Dörflertemplate<class EachParam1>
9902be5353SAxel Dörflervoid
100a51764c5SJohn ScipioneEachPoseAndModel(PoseList* list,
101a51764c5SJohn Scipione	void (*eachFunction)(BPose*, Model*, int32, EachParam1),
102a51764c5SJohn Scipione	EachParam1 eachParam1)
10302be5353SAxel Dörfler{
10402be5353SAxel Dörfler	for (int32 index = list->CountItems() - 1; index >= 0; index--) {
105b05aa8b5SJohn Scipione		BPose* pose = list->ItemAt(index);
106b05aa8b5SJohn Scipione		Model* model = pose->TargetModel();
107fdb62486SJohn Scipione		if (model != NULL)
10802be5353SAxel Dörfler			(eachFunction)(pose, model, index, eachParam1);
10902be5353SAxel Dörfler	}
11002be5353SAxel Dörfler}
11102be5353SAxel Dörfler
112b05aa8b5SJohn Scipione
11302be5353SAxel Dörflertemplate<class EachParam1, class EachParam2>
11402be5353SAxel Dörflervoid
115a51764c5SJohn ScipioneEachPoseAndModel(PoseList* list,
116a51764c5SJohn Scipione	void (*eachFunction)(BPose*, Model*, EachParam1, EachParam2),
117a51764c5SJohn Scipione	EachParam1 eachParam1, EachParam2 eachParam2)
11802be5353SAxel Dörfler{
11902be5353SAxel Dörfler	for (int32 index = list->CountItems() - 1; index >= 0; index--) {
120b05aa8b5SJohn Scipione		BPose* pose = list->ItemAt(index);
121b05aa8b5SJohn Scipione		Model* model = pose->TargetModel();
122fdb62486SJohn Scipione		if (model != NULL)
12302be5353SAxel Dörfler			(eachFunction)(pose, model, eachParam1, eachParam2);
12402be5353SAxel Dörfler	}
12502be5353SAxel Dörfler}
12602be5353SAxel Dörfler
127fdb62486SJohn Scipione
12802be5353SAxel Dörflertemplate<class EachParam1, class EachParam2>
12902be5353SAxel Dörflervoid
130a51764c5SJohn ScipioneEachPoseAndModel(PoseList* list,
131a51764c5SJohn Scipione	void (*eachFunction)(BPose*, Model*, int32, EachParam1, EachParam2),
132a51764c5SJohn Scipione	EachParam1 eachParam1, EachParam2 eachParam2)
13302be5353SAxel Dörfler{
13402be5353SAxel Dörfler	for (int32 index = list->CountItems() - 1; index >= 0; index--) {
135b05aa8b5SJohn Scipione		BPose* pose = list->ItemAt(index);
136b05aa8b5SJohn Scipione		Model* model = pose->TargetModel();
137fdb62486SJohn Scipione		if (model != NULL)
13802be5353SAxel Dörfler			(eachFunction)(pose, model, index, eachParam1, eachParam2);
13902be5353SAxel Dörfler	}
14002be5353SAxel Dörfler}
14102be5353SAxel Dörfler
142fdb62486SJohn Scipione
14302be5353SAxel Dörflertemplate<class EachParam1>
14402be5353SAxel Dörflervoid
145a51764c5SJohn ScipioneEachPoseAndResolvedModel(PoseList* list,
146a51764c5SJohn Scipione	void (*eachFunction)(BPose*, Model*, EachParam1), EachParam1 eachParam1)
14702be5353SAxel Dörfler{
14802be5353SAxel Dörfler	for (int32 index = list->CountItems() - 1; index >= 0; index--) {
149b05aa8b5SJohn Scipione		BPose* pose = list->ItemAt(index);
150b05aa8b5SJohn Scipione		Model* model = pose->TargetModel()->ResolveIfLink();
151fdb62486SJohn Scipione		if (model != NULL)
15202be5353SAxel Dörfler			(eachFunction)(pose, model, eachParam1);
15302be5353SAxel Dörfler	}
15402be5353SAxel Dörfler}
15502be5353SAxel Dörfler
156fdb62486SJohn Scipione
15702be5353SAxel Dörflertemplate<class EachParam1>
15802be5353SAxel Dörflervoid
159a51764c5SJohn ScipioneEachPoseAndResolvedModel(PoseList* list,
160a51764c5SJohn Scipione	void (*eachFunction)(BPose*, Model*, int32 , EachParam1),
161a51764c5SJohn Scipione	EachParam1 eachParam1)
16202be5353SAxel Dörfler{
16302be5353SAxel Dörfler	for (int32 index = list->CountItems() - 1; index >= 0; index--) {
164b05aa8b5SJohn Scipione		BPose* pose = list->ItemAt(index);
165b05aa8b5SJohn Scipione		Model* model = pose->TargetModel()->ResolveIfLink();
166fdb62486SJohn Scipione		if (model != NULL)
16702be5353SAxel Dörfler			(eachFunction)(pose, model, index, eachParam1);
16802be5353SAxel Dörfler	}
16902be5353SAxel Dörfler}
17002be5353SAxel Dörfler
171fdb62486SJohn Scipione
17202be5353SAxel Dörflertemplate<class EachParam1, class EachParam2>
17302be5353SAxel Dörflervoid
174a51764c5SJohn ScipioneEachPoseAndResolvedModel(PoseList* list,
175a51764c5SJohn Scipione	void (*eachFunction)(BPose*, Model*, EachParam1, EachParam2),
176a51764c5SJohn Scipione	EachParam1 eachParam1, EachParam2 eachParam2)
17702be5353SAxel Dörfler{
17802be5353SAxel Dörfler	for (int32 index = list->CountItems() - 1; index >= 0; index--) {
179b05aa8b5SJohn Scipione		BPose* pose = list->ItemAt(index);
180b05aa8b5SJohn Scipione		Model* model = pose->TargetModel()->ResolveIfLink();
181fdb62486SJohn Scipione		if (model != NULL)
18202be5353SAxel Dörfler			(eachFunction)(pose, model, eachParam1, eachParam2);
18302be5353SAxel Dörfler	}
18402be5353SAxel Dörfler}
18502be5353SAxel Dörfler
186fdb62486SJohn Scipione
18702be5353SAxel Dörflertemplate<class EachParam1, class EachParam2>
18802be5353SAxel Dörflervoid
189a51764c5SJohn ScipioneEachPoseAndResolvedModel(PoseList* list,
190a51764c5SJohn Scipione	void (*eachFunction)(BPose*, Model*, int32, EachParam1, EachParam2),
191a51764c5SJohn Scipione	EachParam1 eachParam1, EachParam2 eachParam2)
19202be5353SAxel Dörfler{
19302be5353SAxel Dörfler	for (int32 index = list->CountItems() - 1; index >= 0; index--) {
194b05aa8b5SJohn Scipione		BPose* pose = list->ItemAt(index);
195b05aa8b5SJohn Scipione		Model* model = pose->TargetModel()->ResolveIfLink();
196fdb62486SJohn Scipione		if (model != NULL)
19702be5353SAxel Dörfler			(eachFunction)(pose, model, index, eachParam1, eachParam2);
19802be5353SAxel Dörfler	}
19902be5353SAxel Dörfler}
20002be5353SAxel Dörfler
20102be5353SAxel Dörfler} // namespace BPrivate
20202be5353SAxel Dörfler
20302be5353SAxel Dörflerusing namespace BPrivate;
20402be5353SAxel Dörfler
205fdb62486SJohn Scipione
206b05aa8b5SJohn Scipione#endif	// _POSE_LIST_H
207