Coin Logo http://www.sim.no
http://www.coin3d.org

SoBase.h
1#ifndef COIN_SOBASE_H
2#define COIN_SOBASE_H
3
4/**************************************************************************\
5 *
6 * This file is part of the Coin 3D visualization library.
7 * Copyright (C) 1998-2007 by Systems in Motion. All rights reserved.
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * ("GPL") version 2 as published by the Free Software Foundation.
12 * See the file LICENSE.GPL at the root directory of this source
13 * distribution for additional information about the GNU GPL.
14 *
15 * For using Coin with software that can not be combined with the GNU
16 * GPL, and for taking advantage of the additional benefits of our
17 * support services, please contact Systems in Motion about acquiring
18 * a Coin Professional Edition License.
19 *
20 * See http://www.coin3d.org/ for more information.
21 *
22 * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
23 * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24 *
25\**************************************************************************/
26
27#include <Inventor/SoType.h>
28#include <Inventor/lists/SoAuditorList.h>
29#include <Inventor/C/base/rbptree.h>
30
31// *************************************************************************
32
33class SbDict;
34class SbString;
35class SoBaseList;
36class SoInput;
37class SoOutput;
38
39// *************************************************************************
40
41class COIN_DLL_API SoBase {
42
43public:
44 static void initClass(void);
45
46 void ref(void) const;
47 void unref(void) const;
48 void unrefNoDelete(void) const;
49 int32_t getRefCount(void) const;
50
51 void touch(void);
52
53 virtual SoType getTypeId(void) const = 0;
54 SbBool isOfType(SoType type) const;
55 static SoType getClassTypeId(void);
56
57 virtual SbName getName(void) const;
58 virtual void setName(const SbName & newname);
59
60 static void addName(SoBase * const base, const char * const name);
61 static void removeName(SoBase * const base, const char * const name);
62
63 virtual void startNotify(void);
64 virtual void notify(SoNotList * l);
65
66 void addAuditor(void * const auditor, const SoNotRec::Type type);
67 void removeAuditor(void * const auditor, const SoNotRec::Type type);
68 const SoAuditorList & getAuditors(void) const;
69
70 virtual void addWriteReference(SoOutput * out, SbBool isfromfield = FALSE);
71 SbBool shouldWrite(void);
72
73 static void incrementCurrentWriteCounter(void);
74 static void decrementCurrentWriteCounter(void);
75
76 static SoBase * getNamedBase(const SbName & name, SoType type);
77 static int getNamedBases(const SbName & name, SoBaseList & baselist,
78 SoType type);
79
80 static SbBool read(SoInput * in, SoBase *& base, SoType expectedtype);
81 static void setInstancePrefix(const SbString & c);
82
83 static void setTraceRefs(SbBool trace);
84 static SbBool getTraceRefs(void);
85
86 static SbBool connectRoute(SoInput * in,
87 const SbName & fromnodename, const SbName & fromfieldname,
88 const SbName & tonodename, const SbName & tofieldname);
89
90 void assertAlive(void) const;
91 static SbBool readRoute(SoInput * in);
92
93protected:
94 // Note: these are bitflags.
95 enum BaseFlags { IS_ENGINE = 0x01, IS_GROUP = 0x02 };
96
97 SoBase(void);
98 virtual ~SoBase();
99
100 virtual void destroy(void);
101
102 SbBool hasMultipleWriteRefs(void) const;
103 SbBool writeHeader(SoOutput * out, SbBool isgroup, SbBool isengine) const;
104 void writeFooter(SoOutput * out) const;
105 virtual const char * getFileFormatName(void) const;
106
107 virtual SbBool readInstance(SoInput * in, unsigned short flags) = 0;
108
109 static uint32_t getCurrentWriteCounter(void);
110 static void staticDataLock(void);
111 static void staticDataUnlock(void);
112
113private:
114 static SbBool readReference(SoInput * in, SoBase *& base);
115 static SbBool readBase(SoInput * in, SbName & classname, SoBase *& base);
116 static SbBool readBaseInstance(SoInput * in, const SbName & classname,
117 const SbName & refname, SoBase *& base);
118
119 static SoBase * createInstance(SoInput * in, const SbName & classname);
120 static void flushInput(SoInput * in);
121
122 static void cleanClass(void);
123
124// OBSOLETE! Just kept around for Coin 2.x ABI compatibility.
125 static void freeLists(unsigned long, void * value);
126
127 static SoType classTypeId;
128
129 struct {
130 int32_t referencecount : 27;
131 unsigned int ingraph : 1;
132 unsigned int alive : 4;
133 // The number of bits should sum up to 32, so we don't allocate
134 // more than one machine word on a 32-bit platform.
135 } objdata;
136
137 void doNotify(SoNotList * l, const void * auditor, const SoNotRec::Type type);
138 static void rbptree_notify_cb(void * auditor, void * type, void * closure);
139 cc_rbptree auditortree;
140
141 // OBSOLETE! Just kept around for Coin 2.x ABI compatibility.
142 static SbDict * name2obj;
143 static SbDict * obj2name;
144
145 static SbString * refwriteprefix;
146
147 static SbBool tracerefs;
148 static uint32_t writecounter;
149};
150
151#endif // !COIN_SOBASE_H
The SbDict class organizes a dictionary of keys and values.
Definition SbDict.h:47
The SbName class stores strings by reference.
Definition SbName.h:31
The SbString class is a string class with convenience functions for string operations.
Definition SbString.h:42
The SoAuditorList class is used to keep track of auditors for certain object classes.
Definition SoAuditorList.h:43
The SoBaseList class is a container for pointers to SoBase derived objects.
Definition SoBaseList.h:32
The SoBase class is the top-level superclass for a number of class-hierarchies.
Definition SoBase.h:41
BaseFlags
Definition SoBase.h:95
virtual SbBool readInstance(SoInput *in, unsigned short flags)=0
virtual SoType getTypeId(void) const =0
The SoInput class is an abstraction of file import functionality.
Definition SoInput.h:55
The SoNotList class is a list of SoNotRec notification records.
Definition SoNotification.h:34
Type
Definition SoNotRec.h:35
The SoOutput class is an abstraction of an output stream.
Definition SoOutput.h:42
The SoType class is the basis for the run-time type system in Coin.
Definition SoType.h:50

Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.

Generated on Wed Jul 17 2024 for Coin by Doxygen. 1.12.0