/* osgCompute - Copyright (C) 2008-2009 SVT Group
 *                                                                     
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of
 * the License, or (at your option) any later version.
 *                                                                     
 * 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
 * GNU Lesse General Public License for more details.
 *
 * The full license is in LICENSE file included with this distribution.
*/

#ifndef OSGCUDA_CONTEXT
#define OSGCUDA_CONTEXT 1

#include <osg/GL>
#include <driver_types.h>
#include <OpenThreads/Thread>
#include <osgCompute/Context>
#include <osgCuda/Export>

namespace osgCuda
{
    struct ContextMemory;

    /**
    */
    class LIBRARY_EXPORT Context : public osgCompute::Context
    {
    public:
        Context();

        virtual bool init();
        virtual void apply();

        inline const cudaDeviceProp* getDeviceProperties() const;

        virtual void clear();

    protected:
        friend class ReleaseOperation;
        virtual ~Context() { clearLocal(); }
        void clearLocal();

        cudaDeviceProp               _deviceProperties;

    private:
        // copy constructor and operator should not be called
        Context( const Context&,const osg::CopyOp&) {}
        Context &operator=(const Context&) { return *this; }
    };

    //------------------------------------------------------------------------------
    inline const cudaDeviceProp* Context::getDeviceProperties() const 
    { 
        return &_deviceProperties; 
    }
}

#endif //OSGCUDA_CONTEXT
