2002-07-17 04:07:32 +08:00
|
|
|
//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
|
2001-10-04 23:12:57 +08:00
|
|
|
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
|
|
|
//as published by the Free Software Foundation.
|
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
#ifndef OSGDB_DOTOSGWRAPPER
|
|
|
|
#define OSGDB_DOTOSGWRAPPER 1
|
|
|
|
|
|
|
|
#include <osg/ref_ptr>
|
|
|
|
#include <osg/Object>
|
|
|
|
|
|
|
|
#include <osgDB/Input>
|
|
|
|
#include <osgDB/Output>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
//#include <stdlib.h>
|
|
|
|
|
|
|
|
namespace osgDB {
|
|
|
|
|
|
|
|
|
2001-09-28 20:36:40 +08:00
|
|
|
/** Wrapper class for specifying read and write functions for extending
|
2001-09-20 05:08:56 +08:00
|
|
|
* the .osg file format. */
|
|
|
|
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:
|
|
|
|
|
|
|
|
/// protected to prevent inappropriate creation of wrappers.
|
|
|
|
DotOsgWrapper() {}
|
|
|
|
|
|
|
|
/// protected to prevent inappropriate creation of wrappers.
|
|
|
|
DotOsgWrapper(DotOsgWrapper&):osg::Referenced() {}
|
|
|
|
|
|
|
|
/// protected to prevent wrapper being created on stack.
|
|
|
|
virtual ~DotOsgWrapper() {}
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Object> _prototype;
|
|
|
|
|
|
|
|
std::string _name;
|
|
|
|
Associates _associates;
|
|
|
|
|
|
|
|
ReadFunc _readFunc;
|
|
|
|
WriteFunc _writeFunc;
|
|
|
|
|
|
|
|
ReadWriteMode _readWriteMode;
|
|
|
|
};
|
|
|
|
|
2002-02-03 20:33:41 +08:00
|
|
|
}
|
2001-09-20 05:08:56 +08:00
|
|
|
|
|
|
|
#endif
|