#ifndef DEVICE_H
#define DEVICE_H

#include <string>
#include <vector>
#include <memory>
#include <sstream>
#include <user/deviceAttachmentSpec.h>
#include <deviceManager/deviceRole.h>
#include <spinscale/co/coQutex.h>

namespace smo {
namespace device {

class Device
{
public:
	explicit Device(const std::string& identifier)
	: deviceIdentifier(identifier),
	  qutex("Device-" + identifier)
	{}

	std::string stringify() const
	{
		std::ostringstream os;
		os << "Device Identifier: " << deviceIdentifier
		   << ", Device Roles: " << deviceRoles.size() << std::endl;
		for (size_t roleIndex = 0; roleIndex < deviceRoles.size(); ++roleIndex)
		{
			os << "  "
				<< deviceRoles[roleIndex]->deviceAttachmentSpec->stringify();
			if (roleIndex + 1 < deviceRoles.size()) {
				os << "\n";
			}
		}
		return os.str();
	}

public:
	std::string deviceIdentifier;
	std::vector<std::shared_ptr<DeviceRole>> deviceRoles;
	sscl::co::CoQutex qutex;
};

} // namespace device
} // namespace smo

#endif // DEVICE_H
