Mercurial > hg > Members > kono > Cerium
comparison TaskManager/Test/test_render/SceneGraphIterator.cpp @ 201:b257e27d995c
add SceneGraphIterator
author | gongo@gendarme.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Mon, 26 Jan 2009 16:46:59 +0900 |
parents | |
children | 3f4c6a75d7e0 |
comparison
equal
deleted
inserted
replaced
200:10ad99550ee8 | 201:b257e27d995c |
---|---|
1 #include "SceneGraphIterator.h" | |
2 | |
3 void | |
4 SceneGraphIterator::set(SceneGraphPtr _list) | |
5 { | |
6 list = cur = _list; | |
7 } | |
8 | |
9 /** | |
10 * 次の SceneGraph があるか返す | |
11 * | |
12 * @retval 1 next がある | |
13 * @retval 0 next がない | |
14 */ | |
15 int | |
16 SceneGraphIterator::hasNext(void) | |
17 { | |
18 return (cur->next) ? 1 : 0; | |
19 } | |
20 | |
21 /** | |
22 * 指定した名前をもつ SceneGraph が以降存在するか | |
23 * | |
24 * @param name 検索したい SceneGraph の名前 | |
25 * @retval 1 next がある | |
26 * @retval 0 next がない | |
27 */ | |
28 int | |
29 SceneGraphIterator::hasNext(const char *name) | |
30 { | |
31 SceneGraphPtr p; | |
32 | |
33 for (p = cur->next; p; p = p->next) { | |
34 if (strcmp(p->name, name) == 0) { | |
35 return 1; | |
36 } | |
37 } | |
38 | |
39 return 0; | |
40 } | |
41 | |
42 /** | |
43 * iterator を次に進める | |
44 */ | |
45 void | |
46 SceneGraphIterator::next(void) | |
47 { | |
48 cur = cur->next; | |
49 } | |
50 | |
51 /** | |
52 * iterator を指定した名前を持つ SceneGraph まで進める | |
53 * SceneGraph が無い場合、NULL にする | |
54 */ | |
55 void | |
56 SceneGraphIterator::next(const char *name) | |
57 { | |
58 SceneGraphPtr p; | |
59 | |
60 for (p = cur->next; p; p = p->next) { | |
61 if (strcmp(p->name, name) == 0) { | |
62 break; | |
63 } | |
64 } | |
65 | |
66 cur = p; | |
67 } | |
68 | |
69 /** | |
70 * 参照中の SceneGraph を削除する | |
71 */ | |
72 void | |
73 SceneGraphIterator::remove(void) | |
74 { | |
75 cur->remove(); | |
76 } | |
77 | |
78 /** | |
79 * 参照中の SceneGraph を返す | |
80 * | |
81 * @return current SceneGraph | |
82 */ | |
83 SceneGraphPtr | |
84 SceneGraphIterator::get(void) | |
85 { | |
86 return cur; | |
87 } |