Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoBaseList.h
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Paul S. Strauss (MMM yyyy)
25** Modified by : Nick Thompson (MMM yyyy)
26** Modified by : David Mott (MMM yyyy)
27**=======================================================================*/
28/*=======================================================================
29 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
30 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
31 *** ***
32 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
33 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
34 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
35 *** ***
36 *** RESTRICTED RIGHTS LEGEND ***
37 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
38 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
39 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
40 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
41 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
42 *** ***
43 *** COPYRIGHT (C) 1996-2014 BY FEI S.A.S, ***
44 *** BORDEAUX, FRANCE ***
45 *** ALL RIGHTS RESERVED ***
46**=======================================================================*/
47/*=======================================================================
48** Modified by : VSG (MMM YYYY)
49**=======================================================================*/
50
51#ifndef SO_BASE_LIST_H
52#define SO_BASE_LIST_H
53
54#include <Inventor/SbPList.h>
55#include <Inventor/misc/SoBase.h>
56#include <Inventor/sensors/SoListSensor.h>
57
78class SoBaseList : public SbPList
79{
80 public:
85
89 SoBaseList(int size);
90
95
99 virtual ~SoBaseList();
100
104 void append(SoBase* ptr);
105
109 void insert(SoBase* ptr, int addBefore);
110
114 virtual void remove(int which);
115
119 virtual void truncate(int start);
120
124 void copy(const SoBaseList &l);
125
130 { copy(l) ; return *this; }
131
133 SoBase* operator [](int i) const
134 { return ( static_cast<SoBase*> ( (*static_cast<const SbPList *>(this) ) [i] ) ); }
135
139 void set(int i, SoBase *ptr);
140
146
155 void touch( int index = -1 );
156
160 void addAuditor(void *auditor, SoNotRec::Type type);
161
165 void removeAuditor(void *auditor, SoNotRec::Type type);
166
170 const SoAuditorList* getAuditors() const
171 {
172 if (m_notificationInfo)
173 return m_notificationInfo->m_auditors;
174 return NULL;
175 }
176
180 int getChangedIndex() const
181 {
182 if (m_notificationInfo)
183 return m_notificationInfo->m_changedIndex;
184 return -1;
185 }
186
191 {
192 if (m_notificationInfo)
193 return m_notificationInfo->m_changedType;
195 }
196
200 void setNotificationInfo(const int changedIndex, const SoListSensor::ChangeType changedType)
201 {
202 if (m_notificationInfo)
203 {
204 m_notificationInfo->m_changedIndex = changedIndex;
205 m_notificationInfo->m_changedType = changedType;
206 }
207 }
208
209private:
210 // Really does a truncate. Flag indicates whether to notify.
211 void truncate(int start, SbBool doNotify);
212
213private:
214 // Inner class that handle auditors notification infos.
215 class SoNotificationInfo
216 {
217 public:
218 // Constructor.
219 SoNotificationInfo();
220 // Destructor.
221 ~SoNotificationInfo();
222 // List of auditors: objects to pass notification to
223 SoAuditorList *m_auditors;
224 // changed element index
225 int m_changedIndex;
226 // type of change
227 SoListSensor::ChangeType m_changedType;
228 };
229
230 // start notification.
231 void startNotify();
232
233 bool getAddReferencesStatus() { return addRefs; }
234
235 private:
236 // If TRUE (the default), this refs and unrefs things in the list
237 bool addRefs;
238
239 // Auditor notification infos
240 SoNotificationInfo *m_notificationInfo;
241};
242
243#endif
List of generic (void *) pointers.
Definition SbPList.h:77
Base class for all nodes, paths, and engines.
Definition SoBase.h:111
Maintains a list of pointers to instances of the SoBase classes.
Definition SoBaseList.h:79
void copy(const SoBaseList &l)
Copies a list, keeping all reference counts correct.
SoBaseList(int size)
Constructor that pre-allocates storage for size pointers.
void insert(SoBase *ptr, int addBefore)
Inserts given pointer in list before pointer with given index.
void addReferences(SbBool flag)
Indicates whether to call ref() and unref() for bases in the list when adding/removing them.
int getChangedIndex() const
Get last changed index element of the list.
Definition SoBaseList.h:180
SoListSensor::ChangeType getChangedType() const
Get last changed type of the list.
Definition SoBaseList.h:190
SoBase * operator[](int i) const
Returns pointer with given index.
Definition SoBaseList.h:133
void set(int i, SoBase *ptr)
Sets an element of a list.
void touch(int index=-1)
Forces each attached SoListSensor to be notified.
SoBaseList(const SoBaseList &l)
Constructor that copies the contents of another list.
virtual void truncate(int start)
Removes all pointers after one with given index, inclusive.
virtual void remove(int which)
Removes pointer with given index.
SoBaseList()
Constructor.
const SoAuditorList * getAuditors() const
Get current auditor list.
Definition SoBaseList.h:170
virtual ~SoBaseList()
Destructor.
void setNotificationInfo(const int changedIndex, const SoListSensor::ChangeType changedType)
setup notification info for auditor mechanism.
Definition SoBaseList.h:200
SoBaseList & operator=(const SoBaseList &l)
Copies a list, keeping all reference counts correct.
Definition SoBaseList.h:129
void addAuditor(void *auditor, SoNotRec::Type type)
Add an auditor to the list.
void removeAuditor(void *auditor, SoNotRec::Type type)
Remove an auditor to the list.
void append(SoBase *ptr)
Adds a pointer to the end of the list.
ChangeType
Change type.
@ UNSPECIFIED
Unspecified change.
int SbBool
Boolean type.
Definition SbBase.h:87