#pragma once

#include <vector>
#include <string>

namespace tw::app {

/**
 * Abstract interface for server address lists.
 *
 * Implementations manage a list of "ip:port" entries, load/save them,
 * and provide a human-readable name for the UI.
 */
class ServerAddressProvider {
public:
    virtual ~ServerAddressProvider() = default;

    /** Human-readable list name, shown as the section header in the lobby. */
    virtual const char* name() const = 0;

    virtual const std::vector<std::string>& entries() const = 0;
    virtual void load() = 0;
    virtual void save() const = 0;
    virtual void add(const std::string& entry) = 0;
    virtual void remove(const std::string& entry) = 0;

    /**
     * Check whether an entry exists in the list.
     * Implemented over entries() — subclasses need not override.
     */
    bool contains(const std::string& entry) const {
        const auto& vec = entries();
        for(const auto& e : vec) {
            if(e == entry) {
                return true;
            }
        }
        return false;
    }
};

} // namespace tw::app
