bytedeco/javacpp

Problem with instantiating templates

Open

#478 opened on May 12, 2021

View on GitHub
 (9 comments) (0 reactions) (0 assignees)Java (620 forks)batch import
bugenhancementhelp wanted

Repository metrics

Stars
 (4,279 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Following preset code attempts to create an instance of a template:

new Info("Spinnaker::GenApi::IEnumerationT<Spinnaker::InterfaceTypeEnum>").pointerTypes("EInterfaceType").define()

Usage of the template in the generated Java code is correctly replaced with EInterfaceType. However, the there is no Java class generated to instantiate the template.

Note that template is in the namespace Spinnaker::GenApi. The template parameter is in the namespace Spinnaker. There is a separate preset for each namespace.

Simplified preset class for GenApi

@Properties(inherit = GenICam.class,
        target = "org.bytedeco.spinnaker.GenApi",
        global = "org.bytedeco.spinnaker.global.GenApi", ...)
public class GenApi implements InfoMapper { ... }

Simplified preset class for Spinnaker

@Properties(inherit = GenApi.class,
        target = "org.bytedeco.spinnaker.Spinnaker",
        global = "org.bytedeco.spinnaker.global.Spinnaker", ...)
public class Spinnaker implements InfoMapper { 
    public void map(InfoMap infoMap) {
        infoMap.put(new Info("Spinnaker::GenApi::IEnumerationT<Spinnaker::InterfaceTypeEnum>")
                           .pointerTypes("EInterfaceType").define())
...
}

Simplified C++ definition of the IEnumerationT:

namespace Spinnaker
{
    namespace GenApi
    {
        template <typename EnumT>
        interface SPINNAKER_API_ABSTRACT IEnumerationT : virtual public IEnumeration, virtual public IEnumReference
        {
          ... 
        }
    }
}

Definition of InterfaceTypeEnum:

namespace Spinnaker
{
	enum InterfaceTypeEnum	/*!< Transport layer type of the interface.*/
	{
		InterfaceType_GigEVision,	/*!< GigE Vision*/
		InterfaceType_CameraLink,	/*!< Camera Link*/
		InterfaceType_CameraLinkHS,	/*!< Camera Link High Speed*/
		InterfaceType_CoaXPress,	/*!< CoaXPress*/
		InterfaceType_USB3Vision,	/*!< USB3 Vision*/
		InterfaceType_Custom,	/*!< Custom transport layer*/
		NUMINTERFACETYPE
	}
...
}

Need to figure out some way to force the instantiation of that template.

Contributor guide