OpenSceneGraph 3.6.5
DotOsgWrapper
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSGDB_DOTOSGWRAPPER
15#define OSGDB_DOTOSGWRAPPER 1
16
17#include <osg/ref_ptr>
18#include <osg/Object>
19
20#include <osgDB/Input>
21#include <osgDB/Output>
22
23#include <string>
24#include <vector>
25
26namespace osgDB {
27
28
31{
32 public:
33
34 typedef std::vector<std::string> Associates;
35 typedef bool (*ReadFunc)(osg::Object&,osgDB::Input&);
36 typedef bool (*WriteFunc)(const osg::Object&,osgDB::Output&);
37
43
45 const std::string& name,
46 const std::string& associates,
47 ReadFunc readFunc,
48 WriteFunc writeFunc,
49 ReadWriteMode readWriteMode=READ_AND_WRITE);
50
51
52 inline const osg::Object* getPrototype() const { return _prototype.get(); }
53 inline const std::string& getName() const { return _name; }
54 inline const Associates& getAssociates() const { return _associates; }
55 inline ReadFunc getReadFunc() const { return _readFunc; }
56 inline WriteFunc getWriteFunc() const { return _writeFunc; }
58
59 protected:
60
63
66
68 virtual ~DotOsgWrapper() {}
69
71
72 std::string _name;
74
77
79};
80
81
84{
85 public:
86
88
91
94
102
103 bool writeObject(const osg::Object& obj,Output& fw);
104
105 typedef std::list<std::string> FileNames;
106 bool getLibraryFileNamesToTry(const std::string& name, FileNames& fileNames);
107
108 private:
109
111
112 typedef std::map< std::string, osg::ref_ptr<DotOsgWrapper> > DotOsgWrapperMap;
113
114 osg::Object* readObject(DotOsgWrapperMap& dowMap,Input& fr);
115 void eraseWrapper(DotOsgWrapperMap& wrappermap,DotOsgWrapper* wrapper);
116
117 DotOsgWrapperMap _objectWrapperMap;
118 DotOsgWrapperMap _imageWrapperMap;
119 DotOsgWrapperMap _drawableWrapperMap;
120 DotOsgWrapperMap _stateAttrWrapperMap;
121 DotOsgWrapperMap _uniformWrapperMap;
122 DotOsgWrapperMap _nodeWrapperMap;
123 DotOsgWrapperMap _shaderWrapperMap;
124
125 DotOsgWrapperMap _classNameWrapperMap;
126
127};
128
129
132{
133 public:
134
136 const std::string& name,
137 const std::string& associates,
139 DotOsgWrapper::WriteFunc writeFunc,
141
143
144 protected:
146};
147
149template<class T>
151{
152 public:
153
155 const std::string& name,
156 const std::string& associates,
158 DotOsgWrapper::WriteFunc writeFunc,
160 RegisterDotOsgWrapperProxy(proto, name, associates, readFunc, writeFunc, readWriteMode) {}
161
162};
163
164
165#define REGISTER_DOTOSGWRAPPER(classname) \
166 extern "C" void dotosgwrapper_##classname(void) {} \
167 static osgDB::RegisterDotOsgWrapperProxy dotosgwrapper_proxy_##classname
168
169}
170
171#endif
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
The osgDB library provides support for reading and writing scene graphs, providing a plugin framework...
Definition Archive:24
Pure virtual base class for drawable geometry.
Definition Drawable:89
Image class for encapsulating the storage texture image data.
Definition Image:179
Base class for all internal nodes in the scene graph.
Definition Node:72
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Base class for providing reference counted objects.
Definition Referenced:44
osg::Shader is an application-level abstraction of an OpenGL glShader.
Definition Shader:89
Base class for state attributes.
Definition StateAttribute:77
Uniform encapsulates glUniform values.
Definition Uniform:414
deprecated.
Definition DotOsgWrapper:31
std::string _name
Definition DotOsgWrapper:72
const Associates & getAssociates() const
Definition DotOsgWrapper:54
bool(* WriteFunc)(const osg::Object &, osgDB::Output &)
Definition DotOsgWrapper:36
std::vector< std::string > Associates
Definition DotOsgWrapper:34
ReadFunc getReadFunc() const
Definition DotOsgWrapper:55
DotOsgWrapper(osg::Object *proto, const std::string &name, const std::string &associates, ReadFunc readFunc, WriteFunc writeFunc, ReadWriteMode readWriteMode=READ_AND_WRITE)
bool(* ReadFunc)(osg::Object &, osgDB::Input &)
Definition DotOsgWrapper:35
ReadWriteMode _readWriteMode
Definition DotOsgWrapper:78
Associates _associates
Definition DotOsgWrapper:73
WriteFunc _writeFunc
Definition DotOsgWrapper:76
ReadWriteMode getReadWriteMode() const
Definition DotOsgWrapper:57
DotOsgWrapper()
protected to prevent inappropriate creation of wrappers.
Definition DotOsgWrapper:62
virtual ~DotOsgWrapper()
protected to prevent wrapper being created on stack.
Definition DotOsgWrapper:68
ReadFunc _readFunc
Definition DotOsgWrapper:75
WriteFunc getWriteFunc() const
Definition DotOsgWrapper:56
const osg::Object * getPrototype() const
Definition DotOsgWrapper:52
osg::ref_ptr< osg::Object > _prototype
Definition DotOsgWrapper:70
DotOsgWrapper(DotOsgWrapper &)
protected to prevent inappropriate creation of wrappers.
Definition DotOsgWrapper:65
const std::string & getName() const
Definition DotOsgWrapper:53
ReadWriteMode
Definition DotOsgWrapper:39
@ READ_ONLY
Definition DotOsgWrapper:41
@ READ_AND_WRITE
Definition DotOsgWrapper:40
osg::Object * readObjectOfType(const osg::Object &compObj, Input &fr)
bool getLibraryFileNamesToTry(const std::string &name, FileNames &fileNames)
osg::Drawable * readDrawable(Input &fr)
std::list< std::string > FileNames
Definition DotOsgWrapper:105
void addDotOsgWrapper(DotOsgWrapper *wrapper)
osg::StateAttribute * readStateAttribute(Input &fr)
void removeDotOsgWrapper(DotOsgWrapper *wrapper)
bool writeObject(const osg::Object &obj, Output &fw)
osg::Image * readImage(Input &fr)
osg::Uniform * readUniform(Input &fr)
osg::Object * readObject(Input &fr)
osg::Object * readObjectOfType(const basic_type_wrapper &btw, Input &fr)
osg::Shader * readShader(Input &fr)
DeprecatedDotOsgWrapperManager()
Definition DotOsgWrapper:87
RegisterDotOsgWrapperProxy(osg::Object *proto, const std::string &name, const std::string &associates, DotOsgWrapper::ReadFunc readFunc, DotOsgWrapper::WriteFunc writeFunc, DotOsgWrapper::ReadWriteMode readWriteMode=DotOsgWrapper::READ_AND_WRITE)
osg::ref_ptr< DotOsgWrapper > _wrapper
Definition DotOsgWrapper:145
TemplateRegisterDotOsgWrapperProxy(osg::Object *proto, const std::string &name, const std::string &associates, DotOsgWrapper::ReadFunc readFunc, DotOsgWrapper::WriteFunc writeFunc, DotOsgWrapper::ReadWriteMode readWriteMode=DotOsgWrapper::READ_AND_WRITE)
Definition DotOsgWrapper:154
basic structure for custom runtime inheritance checking
Definition Input:33
deprecated.
Definition Input:264
deprecated.
Definition Output:29
#define OSGDB_EXPORT
Definition Export:39

osg logo
Generated at Wed Jul 23 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.