#pragma once

#include <memory>
#include <vector>
#include "filedescriptor.hpp"

namespace openpower
{
namespace targeting
{

constexpr auto fsiMasterDevPath =
    "/sys/devices/platform/fsi-master/slave@00:00/raw";

constexpr auto fsiSlaveBaseDir = "/sys/devices/hub@00/";

/**
 * Represents a specific P9 processor in the system.  Used by
 * the access APIs to specify the chip to operate on.
 */
class Target
{
    public:

        /**
         * Constructor
         *
         * @param[in] - The logical position of the target
         * @param[in] - The sysfs device path
         */
        Target(size_t position, const std::string& devPath) :
            pos(position), cfamPath(devPath)
        {
        }

        Target() = delete;
        ~Target() = default;
        Target(const Target&) = default;
        Target(Target&&) = default;
        Target& operator=(Target&&) = default;

        /**
         * Returns the position
         */
        inline auto getPos() const
        {
            return pos;
        }

        /**
         * Returns the CFAM sysfs path
         */
        inline auto getCFAMPath() const
        {
            return cfamPath;
        }

        /**
         * Returns the file descriptor to use
         * for read/writeCFAM operations.
         */
        int getCFAMFD();

    private:

        /**
         * The logical position of this target
         */
        size_t pos;

        /**
         * The sysfs device path for the CFAM
         */
        const std::string cfamPath;

        /**
         * The file descriptor to use for read/writeCFAMReg
         */
        std::unique_ptr<openpower::util::FileDescriptor> cfamFD;
};


/**
 * Class that manages processor targeting for FSI operations.
 */
class Targeting
{
    public:

        /**
         * Scans sysfs to find all processors and creates Target objects
         * for them.
         * @param[in] fsiMasterDev - the sysfs device for the master
         * @param[in] fsiSlaveDirectory - the base sysfs dir for slaves
         */
        Targeting(const std::string& fsiMasterDev,
                  const std::string& fsiSlaveDir);

        Targeting() : Targeting(fsiMasterDevPath, fsiSlaveBaseDir) {}

        ~Targeting() = default;
        Targeting(const Targeting&) = default;
        Targeting(Targeting&&) = default;
        Targeting& operator=(Targeting&&) = default;

        /**
         * Returns a const iterator to the first target
         */
        inline auto begin()
        {
            return targets.cbegin();
        }

        /**
         * Returns a const iterator to the last (highest position) target.
         */
        inline auto end()
        {
            return targets.cend();
        }

        /**
         * Returns the number of targets
         */
        inline auto size()
        {
            return targets.size();
        }

    private:

        /**
         * The path to the fsi-master sysfs device to access
         */
        const std::string fsiMasterPath;

        /**
         * The path to the fsi slave sysfs base directory
         */
        const std::string fsiSlaveBasePath;

        /**
         * A container of Targets in the system
         */
        std::vector<std::unique_ptr<Target>> targets;
};

}
}
