1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
|
/**************************************************************************\
*
* This file is part of the Coin 3D visualization library.
* Copyright (C) by Kongsberg Oil & Gas Technologies.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* ("GPL") version 2 as published by the Free Software Foundation.
* See the file LICENSE.GPL at the root directory of this source
* distribution for additional information about the GNU GPL.
*
* For using Coin with software that can not be combined with the GNU
* GPL, and for taking advantage of the additional benefits of our
* support services, please contact Kongsberg Oil & Gas Technologies
* about acquiring a Coin Professional Edition License.
*
* See http://www.coin3d.org/ for more information.
*
* Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
* http://www.sim.no/ sales@sim.no coin-support@coin3d.org
*
\**************************************************************************/
/*!
\class SoNotList SoNotification.h Inventor/misc/SoNotification.h
\brief The SoNotList class is a list of SoNotRec notification records.
\ingroup general
*/
#include <Inventor/misc/SoNotification.h>
#include <Inventor/misc/SoNotRec.h>
#include <Inventor/errors/SoDebugError.h>
#include <Inventor/nodes/SoNode.h>
#include <Inventor/SbName.h>
#include <assert.h>
#include <time.h>
/*!
Initialize list.
*/
SoNotList::SoNotList(void)
{
this->head = this->tail = NULL;
this->firstnoderec = NULL;
this->lastfield = NULL;
this->lastengine = NULL;
// this is used in SoNode::notify() to stop a notification
// when a node has already been notified.
this->stamp = SoNode::getNextNodeId();
}
/*!
Copy constructor. Does a bitwise copy of the \a nl object (no
duplication of list elements).
*/
SoNotList::SoNotList(const SoNotList * nl)
{
*this = *nl;
}
/*!
Append \a rec notification source to the list.
*/
void
SoNotList::append(SoNotRec * const rec)
{
#if COIN_DEBUG && 0 // debug
if (rec->getBase()) {
SoDebugError::postInfo("SoNotList::append", "%p - %p (base: %p %s \"%s\")",
this, rec, rec->getBase(),
rec->getBase()->getTypeId().getName().getString(),
rec->getBase()->getName().getString());
}
else {
SoDebugError::postInfo("SoNotList::append", "%p - %p (base is NULL)",
this, rec);
}
#endif // debug
// Link into list.
rec->setPrevious(this->tail);
this->tail = rec;
if (!this->head) this->head = rec;
if (!this->firstnoderec && rec->getBase() && rec->getBase()->isOfType(SoNode::getClassTypeId()))
this->firstnoderec = rec;
}
/*!
Append \a rec notification source to the list, setting \a field as
the last field having been influenced by the notification process.
*/
void
SoNotList::append(SoNotRec * const rec, SoField * const field)
{
#if COIN_DEBUG && 0 // debug
SoDebugError::postInfo("SoNotList::append", "field %p", field);
#endif // debug
assert(field);
this->lastfield = field;
this->append(rec);
}
/*!
Append \a rec notification source to the list, setting \a engineout
as the last engine output field having been influenced by the
notification process.
*/
void
SoNotList::append(SoNotRec * const rec, SoEngineOutput * const engineout)
{
assert(engineout);
this->lastengine = engineout;
this->append(rec);
}
/*!
Set the \a type of the last notification record in the list.
*/
void
SoNotList::setLastType(const SoNotRec::Type type)
{
assert(this->tail);
this->tail->setType(type);
switch (type) {
case SoNotRec::FIELD:
case SoNotRec::ENGINE:
this->firstnoderec = NULL;
default:
break;
}
}
/*!
Returns the first record in the list.
*/
SoNotRec *
SoNotList::getFirstRec(void) const
{
return this->head;
}
/*!
Returns the last record in the list.
*/
SoNotRec *
SoNotList::getLastRec(void) const
{
return this->tail;
}
/*!
Returns the first record in the list which is derived from SoBase.
*/
SoNotRec *
SoNotList::getFirstRecAtNode(void) const
{
return this->firstnoderec;
}
/*!
Returns the last field touched by notification.
*/
SoField *
SoNotList::getLastField(void) const
{
return this->lastfield;
}
/*!
Returns the last engine output field touched by notification.
*/
SoEngineOutput *
SoNotList::getLastEngineOutput(void) const
{
return this->lastengine;
}
/*!
Returns the time stamp when the notification started.
*/
uint32_t
SoNotList::getTimeStamp(void) const
{
return this->stamp;
}
/*!
Dump contents of list from tail record and backwards. Only available
if compiled with debug information on.
*/
void
SoNotList::print(FILE * const file) const
{
#if COIN_DEBUG
(void)fprintf(file, "SoNotList: %p\n", this);
const SoNotRec * ptr = this->tail;
while (ptr) {
ptr->print(file);
ptr = ptr->getPrevious();
}
const SoBase * n = this->getFirstRecAtNode()->getBase();
const SoField * f = this->getLastField();
SbName fname("");
if (n && n->isOfType(SoNode::getClassTypeId()) && f) {
(void)((SoNode *)n)->getFieldName(f, fname);
}
(void)fprintf(file, "\tfirstAtNode = %p, lastField = %p (\"%s\")\n",
this->getFirstRecAtNode(),
this->getLastField(), fname.getString());
#endif // COIN_DEBUG
}
|