/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
 * Copyright 2016 Pelican Mapping
 * http://osgearth.org
 *
 * osgEarth 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 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
#ifndef OSGEARTH_DRIVER_NOISE_OPTIONS
#define OSGEARTH_DRIVER_NOISE_OPTIONS 1

#include <osgEarth/Common>
#include <osgEarth/URI>

namespace osgEarth { namespace Noise
{
    using namespace osgEarth;

    /**
     * Options governing the terrain noise texture.
     */
    class NoiseOptions : public DriverConfigOptions // NO EXPORT; header only
    {
    public:
        /** Size of the noise texture in the U and V dimensions. Default = 1024. */
        optional<unsigned>& size() { return _size; }
        const optional<unsigned>& size() const { return _size; }

        /** Number of channels of noise to make (1-4) default = 1. */
        optional<unsigned>& numChannels() { return _numChannels; }
        const optional<unsigned>& numChannels() const { return _numChannels; }


    public:
        NoiseOptions( const ConfigOptions& opt =ConfigOptions() ) : DriverConfigOptions( opt )
        {
            setDriver( "noise" );
            _size.init( 1024u );
            _numChannels.init( 1u );
            fromConfig( _conf );
        }

        virtual ~NoiseOptions() { }

    public:
        Config getConfig() const {
            Config conf = DriverConfigOptions::getConfig();
            conf.addIfSet( "size", _size );
            conf.addIfSet( "num_channels", _numChannels );
            return conf;
        }

    protected:
        void mergeConfig( const Config& conf ) {
            DriverConfigOptions::mergeConfig( conf );
            fromConfig( conf );
        }

    private:
        void fromConfig( const Config& conf ) {
            conf.getIfSet( "size", _size );
            conf.getIfSet( "num_channels", _numChannels );
        }

        optional<unsigned> _size;
        optional<unsigned> _numChannels;
    };

} } // namespace osgEarth::Noise

#endif // OSGEARTH_DRIVER_NOISE_OPTIONS

