/*
 * Copyright (c) 2008 Red Hat, Inc.
 *
 * This file is part of the Qpid async store library msgstore.so.
 *
 * 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 2.1 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 * USA
 *
 * The GNU Lesser General Public License is available in the file COPYING.
 */

#ifndef mrg_jtt_read_arg_hpp
#define mrg_jtt_read_arg_hpp

#include <string>
#include <map>

namespace mrg
{
namespace jtt
{

class read_arg
{
    public:
        enum read_mode_t { NONE, ALL, RANDOM, LAZYLOAD};
    private:
        static std::map<std::string, read_mode_t> _map;
        static std::string _description;
        static const bool init;
        static bool __init();
        read_mode_t _rm;
    public:
        inline read_arg() : _rm(NONE) {}
        inline read_arg(read_mode_t rm) : _rm(rm) {}

        inline read_mode_t val() const { return _rm; }
        inline void set_val(const read_mode_t rm) { _rm = rm; }
        void parse(const std::string& str);

        inline const std::string& str() const { return str(_rm); }
        static const std::string& str(const read_mode_t rm);
        static const std::string& descr();

        friend std::ostream& operator<<(std::ostream& os, const read_arg& ra);
        friend std::istream& operator>>(std::istream& is, read_arg& ra);
};

} // namespace jtt
} // namespace mrg

#endif // ifndef mrg_jtt_read_arg_hpp
