| 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) by Kongsberg Oil & Gas Technologies.
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 Kongsberg Oil & Gas Technologies
18 * about acquiring a Coin Professional Edition License.
19 *
20 * See http://www.coin3d.org/ for more information.
21 *
22 * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, 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 class SbString;
32 class SoBaseList;
33 class SoInput;
34 class SoOutput;
35
36 class COIN_DLL_API SoBase {
37 public:
38 static void initClass(void);
39
40 void ref(void) const;
41 void unref(void) const;
42 void unrefNoDelete(void) const;
43 int32_t getRefCount(void) const;
44
45 void touch(void);
46
47 virtual SoType getTypeId(void) const = 0;
48 SbBool isOfType(SoType type) const;
49 static SoType getClassTypeId(void);
50
51 virtual SbName getName(void) const;
52 virtual void setName(const SbName & newname);
53
54 static void addName(SoBase * const base, const char * const name);
55 static void removeName(SoBase * const base, const char * const name);
56
57 virtual void startNotify(void);
58 virtual void notify(SoNotList * l);
59
60 void addAuditor(void * const auditor, const SoNotRec::Type type);
61 void removeAuditor(void * const auditor, const SoNotRec::Type type);
62 const SoAuditorList & getAuditors(void) const;
63
64 virtual void addWriteReference(SoOutput * out, SbBool isfromfield = FALSE);
65 SbBool shouldWrite(void);
66
67 static void incrementCurrentWriteCounter(void);
68 static void decrementCurrentWriteCounter(void);
69
70 static SoBase * getNamedBase(const SbName & name, SoType type);
71 static int getNamedBases(const SbName & name, SoBaseList & baselist,
72 SoType type);
73
74 static SbBool read(SoInput * input, SoBase *& base, SoType expectedtype);
75 static void setInstancePrefix(const SbString & c);
76
77 static void setTraceRefs(SbBool trace);
78 static SbBool getTraceRefs(void);
79
80 static SbBool connectRoute(SoInput * input,
81 const SbName & fromnodename, const SbName & fromfieldname,
82 const SbName & tonodename, const SbName & tofieldname);
83
84 void assertAlive(void) const;
85 static SbBool readRoute(SoInput * input);
86
87 protected:
88 // Note: these are bitflags.
89 enum BaseFlags { IS_ENGINE = 0x01, IS_GROUP = 0x02 };
90
91 SoBase(void);
92 virtual ~SoBase();
93
94 virtual void destroy(void);
95
96 SbBool hasMultipleWriteRefs(void) const;
97 SbBool writeHeader(SoOutput * out, SbBool isgroup, SbBool isengine) const;
98 void writeFooter(SoOutput * out) const;
99 virtual const char * getFileFormatName(void) const;
100
101 virtual SbBool readInstance(SoInput * input, unsigned short flags) = 0;
102
103 static uint32_t getCurrentWriteCounter(void);
104 static void staticDataLock(void);
105 static void staticDataUnlock(void);
106
107 private:
108 static void cleanClass(void);
109
110 static SoType classTypeId;
111
112 struct {
113 mutable int referencecount : 28;
114 mutable unsigned int alive : 4;
115 } objdata;
116
117 void doNotify(SoNotList * l, const void * auditor, const SoNotRec::Type type);
118 cc_rbptree auditortree;
119
120 class PImpl;
121 friend class PImpl; // MSVC6
122 };
123
124 // support for boost::intrusive_ptr<SoBase>
125 inline void intrusive_ptr_add_ref(SoBase * obj) { obj->ref(); }
126 inline void intrusive_ptr_release(SoBase * obj) { obj->unref(); }
127
128 #endif // !COIN_SOBASE_H
SoBase
The SoBase class is the top-level superclass for a number of class-hierarchies.SoBase provides the ba...
Definition: SoBase.h:36
SoBase::unref
void unref(void) const
Definition: SoBase.cpp:509
SoOutput
The SoOutput class is an abstraction of an output stream.SoOutput offers the ability to write basic t...
Definition: SoOutput.h:42
SoBaseList
The SoBaseList class is a container for pointers to SoBase derived objects.The additional capability ...
Definition: SoBaseList.h:32
SoAuditorList
The SoAuditorList class is used to keep track of auditors for certain object classes.This class is mainly for internal use (from SoBase) and it should not be necessary to be familiar with it for "ordinary" Coin use.
Definition: SoAuditorList.h:43
SoBase::BaseFlags
BaseFlags
Definition: SoBase.h:89
SoInput
The SoInput class is an abstraction of file import functionality.This class takes care of most of the...
Definition: SoInput.h:52
SbString
The SbString class is a string class with convenience functions for string operations.This is the class used for storing and working with character strings. It automatically takes care of supporting all the "bookkeeping" tasks usually associated with working with character strings, like memory allocation and deallocation etc.
Definition: SbString.h:42
SoNotList
The SoNotList class is a list of SoNotRec notification records.
Definition: SoNotification.h:34
SoType
The SoType class is the basis for the run-time type system in Coin.Many of the classes in the Coin li...
Definition: SoType.h:50
SbName
The SbName class stores strings by reference.The class is used by Coin for storing keywords...
Definition: SbName.h:31
SoBase::ref
void ref(void) const
Definition: SoBase.cpp:459
SoNotRec::Type
Type
Definition: SoNotRec.h:35

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.