Skip to content
Snippets Groups Projects
OperationThread 6.73 KiB
/* -*-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 OSG_OPERATIONTHREAD
#define OSG_OPERATIONTHREAD 1

#include <osg/observer_ptr>
#include <osg/Object>

#include <OpenThreads/Thread>
#include <OpenThreads/Barrier>
#include <OpenThreads/Condition>
#include <OpenThreads/Block>

#include <list>
#include <set>

namespace osg {

class RefBlock : virtual public osg::Referenced, public OpenThreads::Block
{
    public:

        RefBlock():
            osg::Referenced(true) {}

};

class RefBlockCount : virtual public osg::Referenced, public OpenThreads::BlockCount
{
    public:

        RefBlockCount(unsigned blockCount):
            osg::Referenced(true),
            OpenThreads::BlockCount(blockCount) {}

};

/** Base class for implementing graphics operations.*/
class Operation : virtual public Referenced
{
    public:

        Operation(const std::string& name, bool keep):
            osg::Referenced(true),
            _name(name),
            _keep(keep) {}


        /** Set the human readable name of the operation.*/
        void setName(const std::string& name) { _name = name; }

        /** Get the human readable name of the operation.*/
        const std::string& getName() const { return _name; }

        /** Set whether the operation should be kept once its been applied.*/ 
        void setKeep(bool keep) { _keep = keep; }

        /** Get whether the operation should be kept once its been applied.*/ 
        bool getKeep() const { return _keep; }