Open Inventor Reference
SoSearchAction.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37
38/*
39 * Copyright (C) 1990,91 Silicon Graphics, Inc.
40 *
41 _______________________________________________________________________
42 ______________ S I L I C O N G R A P H I C S I N C . ____________
43 |
44 | $Revision: 1.1.1.1 $
45 |
46 | Description:
47 | Defines the SoSearchAction class
48 |
49 | Author(s) : Paul S. Strauss
50 |
51 ______________ S I L I C O N G R A P H I C S I N C . ____________
52 _______________________________________________________________________
53 */
54
55#ifndef _SO_SEARCH_ACTION_
56#define _SO_SEARCH_ACTION_
57
60
61
64
85
87
89
90 public:
91
93 enum LookFor {
94 NODE = 0x01,
95 TYPE = 0x02,
96 NAME = 0x04
97 };
98
100 enum Interest {
103 ALL
104 };
105
108
111
115 void reset();
116
121 void setFind(int what) { lookingFor = what; }
124 int getFind() { return lookingFor; }
125
127 SoNode * getNode() const { return node; }
129 void setNode(SoNode *n);
130
134 SoType getType(bool &derivedIsOk) const
135 { derivedIsOk = derivedOk; return type; }
139 void setType(SoType t, bool derivedIsOk = TRUE);
140
142 const SbName & getName() const { return name; }
144 void setName(const SbName &n);
145
147 Interest getInterest() const { return interest; }
149 void setInterest(Interest i) { interest = i; }
150
152 bool isSearchingAll() const { return searchingAll; }
158 void setSearchingAll(bool flag) { searchingAll = flag; }
159
162 SoPath * getPath() const { return retPath; }
163
165 SoPathList & getPaths() { return retPaths; }
166
167 SoEXTENDER public:
170 bool isFound() const { return hasTerminated(); }
171
173 void addPath(SoPath *path);
174
175 SoINTERNAL public:
176 static void initClass();
177
181 static bool duringSearchAll;
182
183 protected:
185 virtual void beginTraversal(SoNode *node);
186
187 private:
188
189 SoType type;
190 bool derivedOk;
191 SoNode *node;
192 SbName name;
193 int lookingFor;
194 Interest interest;
195 bool searchingAll;
197 SoPath *retPath;
198 SoPathList retPaths;
199};
200
201#endif /* _SO_SEARCH_ACTION_ */
#define SoEXTENDER
Provide inline template functions for abs, swap, min, max, and clamp.
Definition SbBasic.h:154
#define TRUE
Definition SbBasic.h:76
#define SoINTERNAL
Definition SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition SbSystem.h:77
#define SO_ACTION_HEADER(className)
Macros to be called within the class definition header for an action subclass:
Definition SoSubAction.h:87
Character string stored in a hash table.
Definition SbString.h:264
Abstract base class for all actions.
Definition SoAction.h:179
bool hasTerminated() const
Returns TRUE if the traversal has reached a termination condition.
Definition SoAction.h:287
void setTerminated(bool flag)
Allows subclass instance to indicate that traversal has reached a termination condition.
Definition SoAction.h:353
Abstract base class for all database nodes.
Definition SoNode.h:103
Maintains a list of pointers to paths.
Definition SoLists.h:212
Path that points to a list of hierarchical nodes.
Definition SoPath.h:109
Searches for nodes in a scene graph.
void setFind(int what)
Sets what to look for; what is a bitmask of LookFor enum values.
virtual ~SoSearchAction()
Destructor.
int getFind()
Returns what to look for.
SoType getType(bool &derivedIsOk) const
Gets the node type to search for.
void setSearchingAll(bool flag)
Sets/returns whether searching uses regular traversal or whether it traverses every single node.
static bool duringSearchAll
This flag is used by the SoSwitch node, which must return a different result from its 'affectsState' ...
SoSearchAction()
Constructor.
void setFound()
Sets/returns whether action has found all desired nodes.
bool isFound() const
Interest
Enum that defines which paths to return:
@ FIRST
Return only the first path found.
@ LAST
Return only the last path found.
LookFor
Enum that defines the search criterion:
bool isSearchingAll() const
SoPathList & getPaths()
Returns resulting path list. This should be used if the interest is ALL.
void setType(SoType t, bool derivedIsOk=TRUE)
Sets the node type to search for.
SoPath * getPath() const
Returns resulting path, or NULL if no path was found.
const SbName & getName() const
Sets/returns the name of the node to search for.
void setInterest(Interest i)
Sets/returns which paths to return. Default is FIRST.
void reset()
Resets options back to default values; clears list of returned paths.
void setName(const SbName &n)
Sets/returns the name of the node to search for.
void setNode(SoNode *n)
Sets the node to search for.
static void initClass()
virtual void beginTraversal(SoNode *node)
Initiates action on graph.
SoNode * getNode() const
Returns the node to search for.
void addPath(SoPath *path)
Sets found path or adds to list of found paths (depending on interest)
Interest getInterest() const
Sets/returns which paths to return. Default is FIRST.
SoType has no virtual functions to keep it small...
Definition SoType.h:103