/*
 * This file is autogenerated with bcop:
 * The Compiz option code generator
 *
 * 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 General Public License for more details.
 *
 */


#include <core/core.h>

#include "session_options.h"

SessionOptions::SessionOptions (bool init /* = true */) :
    mOptions (SessionOptions::OptionNum),
    mNotify (SessionOptions::OptionNum)
{
    if (init)
        initOptions ();
}

void
SessionOptions::initOptions ()
{

    // save_legacy
    mOptions[SessionOptions::SaveLegacy].setName ("save_legacy", CompOption::TypeBool);
    mOptions[SessionOptions::SaveLegacy].value().set(false);

    // ignore_match
    mOptions[SessionOptions::IgnoreMatch].setName ("ignore_match", CompOption::TypeMatch);
    mOptions[SessionOptions::IgnoreMatch].value().set(CompMatch (""));
    mOptions[SessionOptions::IgnoreMatch].value().match ().update ();

}

SessionOptions::~SessionOptions ()
{
}


CompOption::Vector &
SessionOptions::getOptions ()
{
    return mOptions;
}

bool
SessionOptions::setOption (const CompString &name, CompOption::Value &value)
{
    CompOption   *o;
    unsigned int index;

    o = CompOption::findOption (mOptions, name, &index);

    if (!o)
        return false;

    switch (index)
    {
        case SessionOptions::SaveLegacy:
            if (o->set (value))
            {
                if (!mNotify[SessionOptions::SaveLegacy].empty ())
                    mNotify[SessionOptions::SaveLegacy] (o, SessionOptions::SaveLegacy);
                return true;
            }
            break;
        case SessionOptions::IgnoreMatch:
            if (o->set (value))
            {
                if (!mNotify[SessionOptions::IgnoreMatch].empty ())
                    mNotify[SessionOptions::IgnoreMatch] (o, SessionOptions::IgnoreMatch);
                return true;
            }
            break;
        default:
            break;
    }
    return false;

}

