1 // SceneryPager.hxx -- Interface to OSG database pager
3 // Copyright (C) 2007 Tim Moore timoore@redhat.com
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of the
8 // License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef FLIGHTGEAR_SCENERYPAGERHXX
25 #include <osg/FrameStamp>
27 #include <osgDB/DatabasePager>
31 class SceneryPager : public osgDB::DatabasePager
35 SceneryPager(const SceneryPager& rhs);
37 // reimplement to add readerWriterOptions from SGPagedLOD
38 virtual void requestNodeFile(const std::string& fileName,osg::Group* group,
39 float priority, const osg::FrameStamp* framestamp);
41 void queueRequest(const std::string& fileName, osg::Group* node,
42 float priority, osg::FrameStamp* frameStamp);
43 // This is passed a ref_ptr so that it can "take ownership" of the
44 // node to delete and decrement its refcount while holding the
45 // lock on the delete list.
46 void queueDeleteRequest(osg::ref_ptr<osg::Object>& objptr);
47 virtual void signalEndFrame();
49 // Queue up file requests until the end of the frame
53 PagerRequest(const PagerRequest& rhs) :
54 _fileName(rhs._fileName), _group(rhs._group),
55 _priority(rhs._priority), _frameStamp(rhs._frameStamp) {}
56 PagerRequest(const std::string& fileName, osg::Group* group,
57 float priority, osg::FrameStamp* frameStamp) :
58 _fileName(fileName), _group(group), _priority(priority),
59 _frameStamp(frameStamp) {}
60 void doRequest(SceneryPager* pager)
62 if (_group->getNumChildren() == 0)
63 pager->requestNodeFile(_fileName, _group.get(), _priority,
66 std::string _fileName;
67 osg::ref_ptr<osg::Group> _group;
69 osg::ref_ptr<osg::FrameStamp> _frameStamp;
71 typedef std::vector<PagerRequest> PagerRequestList;
72 PagerRequestList _pagerRequests;
73 typedef std::vector<osg::ref_ptr<osg::Object> > DeleteRequestList;
74 DeleteRequestList _deleteRequests;
75 virtual ~SceneryPager();
78 #define FLIGHTGEAR_SCENERYPAGERHXX 1