2007-12-14 22:51:56 +00:00
|
|
|
// SceneryPager.hxx -- Interface to OSG database pager
|
|
|
|
//
|
|
|
|
// Copyright (C) 2007 Tim Moore timoore@redhat.com
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program 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 GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
#ifndef FLIGHTGEAR_SCENERYPAGERHXX
|
2009-05-16 08:16:20 +00:00
|
|
|
#define FLIGHTGEAR_SCENERYPAGERHXX 1
|
2007-12-14 22:51:56 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <osg/FrameStamp>
|
|
|
|
#include <osg/Group>
|
|
|
|
#include <osgDB/DatabasePager>
|
|
|
|
|
|
|
|
namespace flightgear
|
|
|
|
{
|
|
|
|
class SceneryPager : public osgDB::DatabasePager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SceneryPager();
|
|
|
|
SceneryPager(const SceneryPager& rhs);
|
2008-06-02 21:10:13 +00:00
|
|
|
// Unhide DatabasePager::requestNodeFile
|
|
|
|
using osgDB::DatabasePager::requestNodeFile;
|
2007-12-14 22:51:56 +00:00
|
|
|
void queueRequest(const std::string& fileName, osg::Group* node,
|
2008-05-14 22:10:07 +00:00
|
|
|
float priority, osg::FrameStamp* frameStamp,
|
2008-06-02 21:10:13 +00:00
|
|
|
osg::ref_ptr<osg::Referenced>& databaseRequest,
|
2008-05-14 22:10:07 +00:00
|
|
|
osgDB::ReaderWriter::Options* options);
|
2007-12-14 22:51:56 +00:00
|
|
|
// This is passed a ref_ptr so that it can "take ownership" of the
|
|
|
|
// node to delete and decrement its refcount while holding the
|
|
|
|
// lock on the delete list.
|
|
|
|
void queueDeleteRequest(osg::ref_ptr<osg::Object>& objptr);
|
|
|
|
virtual void signalEndFrame();
|
2014-03-13 18:18:23 +00:00
|
|
|
|
|
|
|
void clearRequests();
|
2007-12-14 22:51:56 +00:00
|
|
|
protected:
|
|
|
|
// Queue up file requests until the end of the frame
|
|
|
|
struct PagerRequest
|
|
|
|
{
|
2008-06-02 21:10:13 +00:00
|
|
|
PagerRequest() : _priority(0.0f), _databaseRequest(0) {}
|
2007-12-14 22:51:56 +00:00
|
|
|
PagerRequest(const PagerRequest& rhs) :
|
|
|
|
_fileName(rhs._fileName), _group(rhs._group),
|
2008-05-14 22:10:07 +00:00
|
|
|
_priority(rhs._priority), _frameStamp(rhs._frameStamp),
|
2008-06-02 21:10:13 +00:00
|
|
|
_options(rhs._options), _databaseRequest(rhs._databaseRequest) {}
|
2008-05-14 22:10:07 +00:00
|
|
|
|
2007-12-14 22:51:56 +00:00
|
|
|
PagerRequest(const std::string& fileName, osg::Group* group,
|
2008-05-14 22:10:07 +00:00
|
|
|
float priority, osg::FrameStamp* frameStamp,
|
2008-06-02 21:10:13 +00:00
|
|
|
osg::ref_ptr<Referenced>& databaseRequest,
|
2008-05-14 22:10:07 +00:00
|
|
|
osgDB::ReaderWriter::Options* options):
|
2007-12-14 22:51:56 +00:00
|
|
|
_fileName(fileName), _group(group), _priority(priority),
|
2008-06-02 21:10:13 +00:00
|
|
|
_frameStamp(frameStamp), _options(options),
|
|
|
|
_databaseRequest(&databaseRequest)
|
|
|
|
{}
|
2008-05-14 22:10:07 +00:00
|
|
|
|
2011-02-15 11:30:56 +00:00
|
|
|
void doRequest(SceneryPager* pager);
|
2007-12-14 22:51:56 +00:00
|
|
|
std::string _fileName;
|
|
|
|
osg::ref_ptr<osg::Group> _group;
|
|
|
|
float _priority;
|
|
|
|
osg::ref_ptr<osg::FrameStamp> _frameStamp;
|
2008-05-14 22:10:07 +00:00
|
|
|
osg::ref_ptr<osgDB::ReaderWriter::Options> _options;
|
2008-06-02 21:10:13 +00:00
|
|
|
osg::ref_ptr<osg::Referenced>* _databaseRequest;
|
2007-12-14 22:51:56 +00:00
|
|
|
};
|
|
|
|
typedef std::vector<PagerRequest> PagerRequestList;
|
|
|
|
PagerRequestList _pagerRequests;
|
|
|
|
typedef std::vector<osg::ref_ptr<osg::Object> > DeleteRequestList;
|
|
|
|
DeleteRequestList _deleteRequests;
|
|
|
|
virtual ~SceneryPager();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|