Added depends_on template and usage in RenderBin to help with static variable destruction ordering

This commit is contained in:
Robert Osfield
2009-06-05 11:48:35 +00:00
parent 647d54bda8
commit 482a18b9f2
2 changed files with 9 additions and 2 deletions

View File

@@ -31,6 +31,13 @@ namespace osg {
class DeleteHandler;
class Observer;
/** template class to help enforce static initialization order. */
template <typename T, T M()>
struct depends_on
{
depends_on() { M(); }
};
/** Base class from providing referencing counted objects.*/
class OSG_EXPORT Referenced
{

View File

@@ -26,8 +26,8 @@
using namespace osg;
using namespace osgUtil;
class RenderBinPrototypeList : public osg::Referenced, public std::map< std::string, osg::ref_ptr<RenderBin> >
class RenderBinPrototypeList : osg::depends_on<OpenThreads::Mutex*, osg::Referenced::getGlobalReferencedMutex>,
public osg::Referenced, public std::map< std::string, osg::ref_ptr<RenderBin> >
{
public:
RenderBinPrototypeList() {}