ReadFile
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_READFILE
#define OSGDB_READFILE 1
#include <string>
#include <osg/Node>
#include <osg/Image>
#include <osg/ArgumentParser>
#include <osgDB/Export>
#include <osgDB/Registry>
namespace osgDB {
extern OSGDB_EXPORT osg::ref_ptr<osg::Object> readRefObjectFile(const std::string& filename,const Options* options);
inline osg::ref_ptr<osg::Object> readRefObjectFile(const std::string& filename)
{
return readRefObjectFile(filename, Registry::instance()->getOptions());
}
template<class T>
inline osg::ref_ptr<T> readRefFile(const std::string& filename, const Options* options)
{
osg::ref_ptr<osg::Object> object = readRefObjectFile(filename, options);
osg::ref_ptr<T> t = dynamic_cast<T*>(object.get());
return t;
}
template<class T>
inline osg::ref_ptr<T> readRefFile(const std::string& filename)
{
return readRefFile<T>(filename, Registry::instance()->getOptions());
}
extern OSGDB_EXPORT osg::ref_ptr<osg::Image> readRefImageFile(const std::string& filename,const Options* options);
inline osg::ref_ptr<osg::Image> readRefImageFile(const std::string& filename)
{
return readRefImageFile(filename,Registry::instance()->getOptions());
}
extern OSGDB_EXPORT osg::ref_ptr<osg::HeightField> readRefHeightFieldFile(const std::string& filename,const Options* options);
inline osg::ref_ptr<osg::HeightField> readRefHeightFieldFile(const std::string& filename)
{
return readRefHeightFieldFile(filename,Registry::instance()->getOptions());
}
extern OSGDB_EXPORT osg::ref_ptr<osg::Node> readRefNodeFile(const std::string& filename,const Options* options);
inline osg::ref_ptr<osg::Node> readRefNodeFile(const std::string& filename)
{
return readRefNodeFile(filename,Registry::instance()->getOptions());
}
extern OSGDB_EXPORT osg::ref_ptr<osg::Node> readRefNodeFiles(std::vector<std::string>& fileList,const Options* options);
inline osg::ref_ptr<osg::Node> readRefNodeFiles(std::vector<std::string>& fileList)
{
return readRefNodeFiles(fileList, Registry::instance()->getOptions());
}
extern OSGDB_EXPORT osg::ref_ptr<osg::Node> readRefNodeFiles(osg::ArgumentParser& parser,const Options* options);
inline osg::ref_ptr<osg::Node> readRefNodeFiles(osg::ArgumentParser& parser)
{
return readRefNodeFiles(parser,Registry::instance()->getOptions());
}
extern OSGDB_EXPORT osg::ref_ptr<osg::Shader> readRefShaderFile(const std::string& filename,const Options* options);
inline osg::ref_ptr<osg::Shader> readRefShaderFile(const std::string& filename)
{
return readRefShaderFile(filename, Registry::instance()->getOptions());
}
inline osg::ref_ptr<osg::Shader> readRefShaderFile(osg::Shader::Type type, const std::string& filename, const Options* options)
{
osg::ref_ptr<osg::Shader> shader = readRefShaderFile(filename, options);
if (shader.valid() && type != osg::Shader::UNDEFINED) shader->setType(type);
return shader;
}
inline osg::ref_ptr<osg::Shader> readRefShaderFile(osg::Shader::Type type, const std::string& filename)
{
return readRefShaderFile(type, filename, Registry::instance()->getOptions());
}
extern OSGDB_EXPORT osg::ref_ptr<osg::Shader> readRefShaderFileWithFallback(osg::Shader::Type type, const std::string& filename, const Options* options, const char* fallback);
inline osg::ref_ptr<osg::Shader> readRefShaderFileWithFallback(osg::Shader::Type type, const std::string& filename, const char* fallback)
{
return osgDB::readRefShaderFileWithFallback(type, filename, Registry::instance()->getOptions(), fallback);
}
extern OSGDB_EXPORT osg::ref_ptr<osg::Script> readRefScriptFile(const std::string& filename,const Options* options);
inline osg::ref_ptr<osg::Script> readRefScriptFile(const std::string& filename)
{
return readRefScriptFile(filename,Registry::instance()->getOptions());
}
#ifdef OSG_PROVIDE_READFILE
extern OSGDB_EXPORT osg::Object* readObjectFile(const std::string& filename,const Options* options);
inline osg::Object* readObjectFile(const std::string& filename)
{
return readObjectFile(filename, Registry::instance()->getOptions());
}
template<typename T>
inline T* readFile(const std::string& filename, const Options* options)
{
osg::ref_ptr<osg::Object> object = readRefObjectFile(filename, options);
osg::ref_ptr<T> t = dynamic_cast<T*>(object.get());
object = 0;
return t.release();
}
template<typename T>
inline T* readFile(const std::string& filename)
{
return readFile<T>(filename, Registry::instance()->getOptions());
}
extern OSGDB_EXPORT osg::Image* readImageFile(const std::string& filename,const Options* options);
inline osg::Image* readImageFile(const std::string& filename)
{
return readImageFile(filename,Registry::instance()->getOptions());
}
extern OSGDB_EXPORT osg::HeightField* readHeightFieldFile(const std::string& filename,const Options* options);
inline osg::HeightField* readHeightFieldFile(const std::string& filename)
{
return readHeightFieldFile(filename,Registry::instance()->getOptions());
}
extern OSGDB_EXPORT osg::Node* readNodeFile(const std::string& filename,const Options* options);
inline osg::Node* readNodeFile(const std::string& filename)
{
return readNodeFile(filename,Registry::instance()->getOptions());
}
extern OSGDB_EXPORT osg::Node* readNodeFiles(std::vector<std::string>& fileList,const Options* options);
inline osg::Node* readNodeFiles(std::vector<std::string>& fileList)
{
return readNodeFiles(fileList,Registry::instance()->getOptions());
}
extern OSGDB_EXPORT osg::Node* readNodeFiles(osg::ArgumentParser& parser,const Options* options);
inline osg::Node* readNodeFiles(osg::ArgumentParser& parser)
{
return readNodeFiles(parser,Registry::instance()->getOptions());
}
extern OSGDB_EXPORT osg::Shader* readShaderFile(const std::string& filename,const Options* options);
inline osg::Shader* readShaderFile(const std::string& filename)
{
return readShaderFile(filename,Registry::instance()->getOptions());
}
inline osg::Shader* readShaderFile(osg::Shader::Type type, const std::string& filename,const Options* options)
{
osg::Shader* shader = readShaderFile(filename, options);
if (shader && type != osg::Shader::UNDEFINED) shader->setType(type);
return shader;
}
inline osg::Shader* readShaderFile(osg::Shader::Type type, const std::string& filename)
{
return readShaderFile(type, filename,Registry::instance()->getOptions());
}
inline osg::Shader* readShaderFileWithFallback(osg::Shader::Type type, const std::string& filename, const Options* options, const char* fallback)
{
osg::Shader* shader = readShaderFile(filename, options);
if (shader && type != osg::Shader::UNDEFINED) shader->setType(type);
if (!shader) shader = new osg::Shader(type, fallback);
return shader;
}
inline osg::Shader* readShaderFileWithFallback(osg::Shader::Type type, const std::string& filename, const char* fallback)
{
return osgDB::readShaderFileWithFallback(type, filename, Registry::instance()->getOptions(), fallback);
}
extern OSGDB_EXPORT osg::Script* readScriptFile(const std::string& filename,const Options* options);
inline osg::Script* readScriptFile(const std::string& filename)
{
return readScriptFile(filename,Registry::instance()->getOptions());
}
#endif
}
#endif
ArgumentParser
Image
Node
osgDB::Options
Definition Options:30
osgDB::Registry::instance
static Registry * instance(bool erase=false)
osg::ArgumentParser
Definition ArgumentParser:28
osg::Object
Definition Object:61
osg::Shader::setType
bool setType(Type t)
osg::Shader::Type
Type
Definition Shader:92
osg::Shader::UNDEFINED
@ UNDEFINED
Definition Shader:99
osg::ref_ptr
Definition ref_ptr:32
osg::ref_ptr::release
T * release()
Definition ref_ptr:126
osg::ref_ptr::valid
bool valid() const
Definition ref_ptr:120
osgDB
Definition Archive:24
osgDB::readRefNodeFile
OSGDB_EXPORT osg::ref_ptr< osg::Node > readRefNodeFile(const std::string &filename, const Options *options)
osgDB::readRefObjectFile
OSGDB_EXPORT osg::ref_ptr< osg::Object > readRefObjectFile(const std::string &filename, const Options *options)
osgDB::readRefScriptFile
OSGDB_EXPORT osg::ref_ptr< osg::Script > readRefScriptFile(const std::string &filename, const Options *options)
osgDB::readRefShaderFile
OSGDB_EXPORT osg::ref_ptr< osg::Shader > readRefShaderFile(const std::string &filename, const Options *options)
osgDB::readRefImageFile
OSGDB_EXPORT osg::ref_ptr< osg::Image > readRefImageFile(const std::string &filename, const Options *options)
osgDB::readRefShaderFileWithFallback
OSGDB_EXPORT osg::ref_ptr< osg::Shader > readRefShaderFileWithFallback(osg::Shader::Type type, const std::string &filename, const Options *options, const char *fallback)
osgDB::readRefNodeFiles
OSGDB_EXPORT osg::ref_ptr< osg::Node > readRefNodeFiles(std::vector< std::string > &fileList, const Options *options)
osgDB::readRefFile
osg::ref_ptr< T > readRefFile(const std::string &filename, const Options *options)
Definition ReadFile:50
osgDB::readRefHeightFieldFile
OSGDB_EXPORT osg::ref_ptr< osg::HeightField > readRefHeightFieldFile(const std::string &filename, const Options *options)
Export
OSGDB_EXPORT
#define OSGDB_EXPORT
Definition osgDB/Export:39
Registry