]> git.mxchange.org Git - flightgear.git/blob - src/Scenery/SceneryPager.hxx
Clear chat messages when an aircraft becomes inactive in the property tree.
[flightgear.git] / src / Scenery / SceneryPager.hxx
1 // SceneryPager.hxx -- Interface to OSG database pager
2 //
3 // Copyright (C) 2007 Tim Moore timoore@redhat.com
4 //
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.
9 //
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.
14 //
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.
18 //
19 // $Id$
20
21 #ifndef FLIGHTGEAR_SCENERYPAGERHXX
22 #include <string>
23 #include <vector>
24
25 #include <osg/FrameStamp>
26 #include <osg/Group>
27 #include <osgDB/DatabasePager>
28
29 namespace flightgear
30 {
31 class SceneryPager : public osgDB::DatabasePager
32 {
33 public:
34     SceneryPager();
35     SceneryPager(const SceneryPager& rhs);
36     void queueRequest(const std::string& fileName, osg::Group* node,
37                       float priority, osg::FrameStamp* frameStamp);
38     // This is passed a ref_ptr so that it can "take ownership" of the
39     // node to delete and decrement its refcount while holding the
40     // lock on the delete list.
41     void queueDeleteRequest(osg::ref_ptr<osg::Object>& objptr);
42     virtual void signalEndFrame();
43 protected:
44     // Queue up file requests until the end of the frame
45     struct PagerRequest
46     {
47         PagerRequest() {}
48         PagerRequest(const PagerRequest& rhs) :
49             _fileName(rhs._fileName), _group(rhs._group),
50             _priority(rhs._priority), _frameStamp(rhs._frameStamp) {}
51         PagerRequest(const std::string& fileName, osg::Group* group,
52                      float priority, osg::FrameStamp* frameStamp) :
53             _fileName(fileName), _group(group), _priority(priority),
54             _frameStamp(frameStamp) {}
55         void doRequest(SceneryPager* pager)
56         {
57             if (_group->getNumChildren() == 0)
58                 pager->requestNodeFile(_fileName, _group.get(), _priority,
59                                        _frameStamp.get());
60         }
61         std::string _fileName;
62         osg::ref_ptr<osg::Group> _group;
63         float _priority;
64         osg::ref_ptr<osg::FrameStamp> _frameStamp;
65     };
66     typedef std::vector<PagerRequest> PagerRequestList;
67     PagerRequestList _pagerRequests;
68     typedef std::vector<osg::ref_ptr<osg::Object> > DeleteRequestList;
69     DeleteRequestList _deleteRequests;
70     virtual ~SceneryPager();
71 };
72 }
73 #define FLIGHTGEAR_SCENERYPAGERHXX 1
74 #endif