dimanche 8 septembre 2019

Why i am getting unresolved external symbol error from the templated function [duplicate]

This question already has an answer here:

I am getting unresolved symbol error when i use CommandInterfaceFont object function.

This is my header file for Class SumCommandInterface

 #include <string>
 #include <iostream>
 #include <TreeModel.h>
 #include <CommandInterfaceFont.h> 

enum class PluginTypeLookUp
{
    GEOMTERY,
    TEXT,
    FUNCTION
};
class SumCommandInterface
{

private:
    std::string stdstrCommand;
    std::map < std::string, PluginTypeLookUp > lookUpPluginMap;

public:
    SumCommandInterface();  
    template<class plugin , typename fieldType>
    void setFontPluginParam( plugin* geom , std::string paramName, fieldType val );
};

This is implementation and the code here gives the error.

#include <SumCommandInterface.h>
#include <CommandInterfaceFont.h>
#include <Container.h>
#include <Geometry.h>
#include <Sum_Function.h>
#include <boost/asio.hpp>
#include <boost/algorithm/string.hpp>

SumCommandInterface::SumCommandInterface()
{
    stdstrCommand = "";
    lookUpPluginMap = {

        {"GEOMETRY" , PluginTypeLookUp::GEOMTERY},
        {"TEXT" , PluginTypeLookUp::TEXT},
        {"FUNCTION" , PluginTypeLookUp::FUNCTION},      
    };    
}

template<typename plugin, typename fieldType>
void SumCommandInterface::setFontPluginParam(plugin* geom ,  std::string paramName, fieldType val)
{
    if (geom->GetType() == "FONT")
    {
        CommandInterfaceFont commandInterface;
        commandInterface.SetValue< std::string >( geom, paramName, val); // This line gives the unresolved external error
    }
}

This is the header for Class CommandInterfaceFont

#include <string>
#include <iostream>
#include <Geometry.h>
#include <Font.h>

class SumCommandInterface;

enum class FontParam
{
    USESHADOW,
    SOFTSHADOW,
    SHADOWDIRECTION,
    SHADOWDISTANCE,
    SHADOWOPACITY,
    KERNING,
    FONTSIZE,
    TEXT,
    FONTALIGNMENT
};


class CommandInterfaceFont
{
private:
    std::map < std::string, FontParam > lookUpMap;

public:
    CommandInterfaceFont();
    friend class SumCommandInterface;   
    template <typename T > void SetValue(Geometry* geom , std::string stdstrParamName, T value);
};

This is the implementation

SumCommandInterface::SumCommandInterface()
{
    stdstrCommand = "";
    lookUpPluginMap = {

        {"GEOMETRY" , PluginTypeLookUp::GEOMTERY},
        {"TEXT" , PluginTypeLookUp::TEXT},
        {"FUNCTION" , PluginTypeLookUp::FUNCTION},      
    };
}

template<typename plugin, typename fieldType>
void SumCommandInterface::setFontPluginParam(plugin* geom ,  std::string paramName, fieldType val)
{
    if (geom->GetType() == "FONT")
    {
        CommandInterfaceFont commandInterface;
        commandInterface.SetValue< std::string >( geom, paramName, val);
    }
}

I have only pasted the code i think is relevant with the issue if recquired i would be happy to add more code.

Aucun commentaire:

Enregistrer un commentaire