DotOsgWrapper
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGDB_DOTOSGWRAPPER
#define OSGDB_DOTOSGWRAPPER 1
#include <osg/ref_ptr>
#include <osg/Object>
#include <osgDB/Input>
#include <osgDB/Output>
#include <string>
#include <vector>
namespace osgDB {
class OSGDB_EXPORT DotOsgWrapper : public osg::Referenced
{
public:
typedef std::vector<std::string> Associates;
typedef bool (*ReadFunc)(osg::Object&,osgDB::Input&);
typedef bool (*WriteFunc)(const osg::Object&,osgDB::Output&);
enum ReadWriteMode
{
READ_AND_WRITE,
READ_ONLY
};
DotOsgWrapper(osg::Object* proto,
const std::string& name,
const std::string& associates,
ReadFunc readFunc,
WriteFunc writeFunc,
ReadWriteMode readWriteMode=READ_AND_WRITE);
inline const osg::Object* getPrototype() const { return _prototype.get(); }
inline const std::string& getName() const { return _name; }
inline const Associates& getAssociates() const { return _associates; }
inline ReadFunc getReadFunc() const { return _readFunc; }
inline WriteFunc getWriteFunc() const { return _writeFunc; }
inline ReadWriteMode getReadWriteMode() const { return _readWriteMode; }
protected:
DotOsgWrapper() {}
DotOsgWrapper(DotOsgWrapper&):osg::Referenced() {}
virtual ~DotOsgWrapper() {}
osg::ref_ptr<osg::Object> _prototype;
std::string _name;
Associates _associates;
ReadFunc _readFunc;
WriteFunc _writeFunc;
ReadWriteMode _readWriteMode;
};
class OSGDB_EXPORT DeprecatedDotOsgWrapperManager : public osg::Referenced
{
public:
DeprecatedDotOsgWrapperManager() {}
void addDotOsgWrapper(DotOsgWrapper* wrapper);
void removeDotOsgWrapper(DotOsgWrapper* wrapper);
osg::Object* readObjectOfType(const osg::Object& compObj,Input& fr);
osg::Object* readObjectOfType(const basic_type_wrapper &btw, Input& fr);
osg::Object* readObject(Input& fr);
osg::Image* readImage(Input& fr);
osg::Drawable* readDrawable(Input& fr);
osg::Uniform* readUniform(Input& fr);
osg::StateAttribute* readStateAttribute(Input& fr);
osg::Node* readNode(Input& fr);
osg::Shader* readShader(Input& fr);
bool writeObject(const osg::Object& obj,Output& fw);
typedef std::list<std::string> FileNames;
bool getLibraryFileNamesToTry(const std::string& name, FileNames& fileNames);
private:
virtual ~DeprecatedDotOsgWrapperManager() {}
typedef std::map< std::string, osg::ref_ptr<DotOsgWrapper> > DotOsgWrapperMap;
osg::Object* readObject(DotOsgWrapperMap& dowMap,Input& fr);
void eraseWrapper(DotOsgWrapperMap& wrappermap,DotOsgWrapper* wrapper);
DotOsgWrapperMap _objectWrapperMap;
DotOsgWrapperMap _imageWrapperMap;
DotOsgWrapperMap _drawableWrapperMap;
DotOsgWrapperMap _stateAttrWrapperMap;
DotOsgWrapperMap _uniformWrapperMap;
DotOsgWrapperMap _nodeWrapperMap;
DotOsgWrapperMap _shaderWrapperMap;
DotOsgWrapperMap _classNameWrapperMap;
};
class OSGDB_EXPORT RegisterDotOsgWrapperProxy
{
public:
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);
~RegisterDotOsgWrapperProxy();
protected:
osg::ref_ptr<DotOsgWrapper> _wrapper;
};
template<class T>
class TemplateRegisterDotOsgWrapperProxy : public RegisterDotOsgWrapperProxy, public T
{
public:
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):
RegisterDotOsgWrapperProxy(proto, name, associates, readFunc, writeFunc, readWriteMode) {}
};
#define REGISTER_DOTOSGWRAPPER(classname) \
extern "C" void dotosgwrapper_##classname(void) {} \
static osgDB::RegisterDotOsgWrapperProxy dotosgwrapper_proxy_##classname
}
#endif
Object
Output
osgDB::DeprecatedDotOsgWrapperManager::readObjectOfType
osg::Object * readObjectOfType(const osg::Object &compObj, Input &fr)
osgDB::DeprecatedDotOsgWrapperManager::getLibraryFileNamesToTry
bool getLibraryFileNamesToTry(const std::string &name, FileNames &fileNames)
osgDB::DeprecatedDotOsgWrapperManager::readDrawable
osg::Drawable * readDrawable(Input &fr)
osgDB::DeprecatedDotOsgWrapperManager::FileNames
std::list< std::string > FileNames
Definition DotOsgWrapper:105
osgDB::DeprecatedDotOsgWrapperManager::addDotOsgWrapper
void addDotOsgWrapper(DotOsgWrapper *wrapper)
osgDB::DeprecatedDotOsgWrapperManager::readStateAttribute
osg::StateAttribute * readStateAttribute(Input &fr)
osgDB::DeprecatedDotOsgWrapperManager::removeDotOsgWrapper
void removeDotOsgWrapper(DotOsgWrapper *wrapper)
osgDB::DeprecatedDotOsgWrapperManager::writeObject
bool writeObject(const osg::Object &obj, Output &fw)
osgDB::DeprecatedDotOsgWrapperManager::readImage
osg::Image * readImage(Input &fr)
osgDB::DeprecatedDotOsgWrapperManager::readUniform
osg::Uniform * readUniform(Input &fr)
osgDB::DeprecatedDotOsgWrapperManager::readObject
osg::Object * readObject(Input &fr)
osgDB::DeprecatedDotOsgWrapperManager::readObjectOfType
osg::Object * readObjectOfType(const basic_type_wrapper &btw, Input &fr)
osgDB::DeprecatedDotOsgWrapperManager::readShader
osg::Shader * readShader(Input &fr)
osgDB::DeprecatedDotOsgWrapperManager::DeprecatedDotOsgWrapperManager
DeprecatedDotOsgWrapperManager()
Definition DotOsgWrapper:87
osgDB::DeprecatedDotOsgWrapperManager::readNode
osg::Node * readNode(Input &fr)
osgDB::DotOsgWrapper
Definition DotOsgWrapper:31
osgDB::DotOsgWrapper::_name
std::string _name
Definition DotOsgWrapper:72
osgDB::DotOsgWrapper::getAssociates
const Associates & getAssociates() const
Definition DotOsgWrapper:54
osgDB::DotOsgWrapper::WriteFunc
bool(* WriteFunc)(const osg::Object &, osgDB::Output &)
Definition DotOsgWrapper:36
osgDB::DotOsgWrapper::Associates
std::vector< std::string > Associates
Definition DotOsgWrapper:34
osgDB::DotOsgWrapper::getReadFunc
ReadFunc getReadFunc() const
Definition DotOsgWrapper:55
osgDB::DotOsgWrapper::DotOsgWrapper
DotOsgWrapper(osg::Object *proto, const std::string &name, const std::string &associates, ReadFunc readFunc, WriteFunc writeFunc, ReadWriteMode readWriteMode=READ_AND_WRITE)
osgDB::DotOsgWrapper::ReadFunc
bool(* ReadFunc)(osg::Object &, osgDB::Input &)
Definition DotOsgWrapper:35
osgDB::DotOsgWrapper::_readWriteMode
ReadWriteMode _readWriteMode
Definition DotOsgWrapper:78
osgDB::DotOsgWrapper::_associates
Associates _associates
Definition DotOsgWrapper:73
osgDB::DotOsgWrapper::_writeFunc
WriteFunc _writeFunc
Definition DotOsgWrapper:76
osgDB::DotOsgWrapper::getReadWriteMode
ReadWriteMode getReadWriteMode() const
Definition DotOsgWrapper:57
osgDB::DotOsgWrapper::DotOsgWrapper
DotOsgWrapper()
protected to prevent inappropriate creation of wrappers.
Definition DotOsgWrapper:62
osgDB::DotOsgWrapper::~DotOsgWrapper
virtual ~DotOsgWrapper()
protected to prevent wrapper being created on stack.
Definition DotOsgWrapper:68
osgDB::DotOsgWrapper::_readFunc
ReadFunc _readFunc
Definition DotOsgWrapper:75
osgDB::DotOsgWrapper::getWriteFunc
WriteFunc getWriteFunc() const
Definition DotOsgWrapper:56
osgDB::DotOsgWrapper::getPrototype
const osg::Object * getPrototype() const
Definition DotOsgWrapper:52
osgDB::DotOsgWrapper::_prototype
osg::ref_ptr< osg::Object > _prototype
Definition DotOsgWrapper:70
osgDB::DotOsgWrapper::DotOsgWrapper
DotOsgWrapper(DotOsgWrapper &)
protected to prevent inappropriate creation of wrappers.
Definition DotOsgWrapper:65
osgDB::DotOsgWrapper::getName
const std::string & getName() const
Definition DotOsgWrapper:53
osgDB::DotOsgWrapper::ReadWriteMode
ReadWriteMode
Definition DotOsgWrapper:39
osgDB::DotOsgWrapper::READ_ONLY
@ READ_ONLY
Definition DotOsgWrapper:41
osgDB::DotOsgWrapper::READ_AND_WRITE
@ READ_AND_WRITE
Definition DotOsgWrapper:40
osgDB::Input
Definition osgDB/Input:264
osgDB::Output
Definition Output:29
osgDB::RegisterDotOsgWrapperProxy::~RegisterDotOsgWrapperProxy
~RegisterDotOsgWrapperProxy()
osgDB::RegisterDotOsgWrapperProxy::RegisterDotOsgWrapperProxy
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)
osgDB::RegisterDotOsgWrapperProxy::_wrapper
osg::ref_ptr< DotOsgWrapper > _wrapper
Definition DotOsgWrapper:145
osgDB::TemplateRegisterDotOsgWrapperProxy::TemplateRegisterDotOsgWrapperProxy
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
osg::Drawable
Definition Drawable:89
osg::Image
Definition Image:179
osg::Node
Definition Node:72
osg::Object
Definition Object:61
osg::Referenced
Definition Referenced:44
osg::Referenced::Referenced
Referenced()
osg::Shader
Definition Shader:89
osg::StateAttribute
Definition StateAttribute:77
osg::Uniform
Definition Uniform:414
osg::ref_ptr
Definition ref_ptr:32
osgDB
Definition Archive:24
osg
Definition AlphaFunc:19
OSGDB_EXPORT
#define OSGDB_EXPORT
Definition osgDB/Export:39
Input
ref_ptr
osgDB::basic_type_wrapper
Definition osgDB/Input:33