/**
 * \file    H_NodeMap.hpp
 * \author  Silvan Murer
 * \date    26 Aug 2022
 *
 * \brief   A few helpers for NodeMap management
 */

#ifndef SRC_H_NODEMAP_HPP
#define SRC_H_NODEMAP_HPP

#include "features/Mimic_Node.hpp"
#include "features/Mimic_Boolean.hpp"
#include "features/Mimic_Category.hpp"
#include "features/Mimic_Command.hpp"
#include "features/Mimic_Enumeration.hpp"
#include "features/Mimic_Float.hpp"
#include "features/Mimic_Integer.hpp"
#include "features/Mimic_String.hpp"

#include <memory>
#include <vector>

#define GENICAM_NO_AUTO_IMPLIB
#include "GenICam.h"

namespace mimic {

class H_NodeMap {
public:
	H_NodeMap() { }
	virtual ~H_NodeMap() { }

	static std::shared_ptr<Mimic_Node> createGFNodePtr(GenApi::INode* node)
	{
		switch (node->GetPrincipalInterfaceType()) {
		case GenApi::EInterfaceType::intfIBoolean:
			return std::make_shared<Mimic_Boolean>(node);
		case GenApi::EInterfaceType::intfICategory:
			return std::make_shared<Mimic_Category>(node);
		case GenApi::EInterfaceType::intfICommand:
			return std::make_shared<Mimic_Command>(node);
		case GenApi::EInterfaceType::intfIEnumeration:
			return std::make_shared<Mimic_Enumeration>(node);
		case GenApi::EInterfaceType::intfIFloat:
			return std::make_shared<Mimic_Float>(node);
		case GenApi::EInterfaceType::intfIInteger:
			return std::make_shared<Mimic_Integer>(node);
		case GenApi::EInterfaceType::intfIString:
			return std::make_shared<Mimic_String>(node);
		case GenApi::EInterfaceType::intfIValue:
		case GenApi::EInterfaceType::intfIBase:
		case GenApi::EInterfaceType::intfIRegister:
		case GenApi::EInterfaceType::intfIEnumEntry:
		case GenApi::EInterfaceType::intfIPort:
		default:
			return std::make_shared<Mimic_Node>(node);
		}
	}

	static std::shared_ptr<Mimic_Node> createGFNodePtr(std::shared_ptr<GenApi::INodeMap> nodeMap, std::string name)
	{
		return createGFNodePtr(nodeMap->GetNode(name.c_str()));
	}

};

} /* namespace genSDK */

#endif
