lucky3778 2022-06-21 11:06 采纳率: 81.8%
浏览 182
已结题

声明模板基类的成员函数显示必须对应指示基类的纯虚拟成员是什么?

img

具体出现问题代码在236行


#ifndef _ISTA_AIR_SERVICE_CLIENT_H
#define _ISTA_AIR_SERVICE_CLIENT_H
#include"myhead.h"

//public abstract  服务客户端模板抽象类基类
template<typename TServiceContract>
class IstaServiceClientBase //:public IDisposable
{
    // Token: 0x04000002 RID: 2
private:
ChannelFactory<TServiceContract> channelFactory;   //工厂

protected:
    IstaServiceClientBase(ChannelFactory<TServiceContract> channelFactory)
    {
        this->channelFactory = channelFactory;
    }
public:
    void Dispose()
    {
        this->channelFactory.Close();
    }
private:
 static void CloseChannel(TServiceContract channel)
    {
        ICommunicationObject communicationObject = channel as ICommunicationObject;
        if (communicationObject == null)
        {
            return;
        }
        if (communicationObject.State == CommunicationState.Faulted)
        {
            communicationObject.Abort();
            return;
        }
        communicationObject.Close();
    }
       
protected:
    //void CallAction(Action<TServiceContract> action)
    void CallAction(void(*action(TServiceContract)))
    {
        TServiceContract tserviceContract = default(TServiceContract);
        try
        {
            tserviceContract = this->channelFactory.CreateChannel();
            action(tserviceContract);
        }
        catch (FaultException<TServiceContract>)
        {
            throw;
        }
        catch (FaultException<FbmTransferException>)
        {
            throw;
        }
        catch (FaultException arg)
        {
            Console.WriteLine("{0}", arg);
            throw;
        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            IstaServiceClientBase<TServiceContract>.CloseChannel(tserviceContract);
        }
    }

    //TResult CallFunction<TResult>(Func<TServiceContract, TResult> func)
    template<typename TResult>
    TResult CallFunction(TResult&func(TServiceContract))
    {
        TServiceContract tserviceContract = default(TServiceContract);
        TResult result;
        try
        {
            tserviceContract = this->channelFactory.CreateChannel();
            result = func(tserviceContract);
        }
        catch (FaultException<TServiceContract>)
        {
            throw;
        }
        catch (FaultException arg)
        {
            Console.WriteLine("{0}", arg);
            throw;
        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            IstaServiceClientBase<TServiceContract>.CloseChannel(tserviceContract);
        }
        return result;
    }


    //async Task CallFunctionAsync(Func<TServiceContract, Task> func)
    Task CallFunctionAsync(Task &func(TServiceContract))
    {
        TServiceContract channel = default(TServiceContract);
        try
        {
            channel = this.channelFactory.CreateChannel();
            await func(channel);
        }
        catch (FaultException arg)
        {
            Console.WriteLine("{0}", arg);
            throw;
        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            IstaServiceClientBase<TServiceContract>.CloseChannel(channel);
        }
    }

    
    //async Task<TResult> CallFunctionAsync<TResult>(Func<TServiceContract, Task<TResult>> func)
    template<typename Tresult>
    Task<TResult> CallFunctionAsync(Task<TResult>& func(TServiceContract))
    {
        TServiceContract channel = default(TServiceContract);
        TResult result;
        try
        {
            channel = this->channelFactory.CreateChannel();
            result = await func(channel);
        }
        catch (FaultException arg)
        {
            Console.WriteLine("{0}", arg);
            throw;
        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            IstaServiceClientBase<TServiceContract>.CloseChannel(channel);
        }
        return result;
    }

    ChannelFactory<TServiceContract> get_ChannelFactory()
    {
        
            return this->channelFactory;
        
    }
};

//public abstract 服务客户端模板抽象类
template<typename TServiceContract>
class IstaServiceClient :public IstaServiceClientBase<TServiceContract>, public IIstaService //, IIstaService where TServiceContract : IIstaService
{
protected:
    //子类构造顺便调用基类的有参构造
    IstaServiceClient():IstaServiceClientBase<TServiceContract>(this->CreateChannelFactory())
    {
    }

private:
static ChannelFactory<TServiceContract> CreateChannelFactory()
{
    NetNamedPipeBinding binding = new NetNamedPipeBinding
    {
        ReceiveTimeout = TimeSpan.MaxValue,
        SendTimeout = TimeSpan.MaxValue,
        MaxReceivedMessageSize = 2147483647L
    };
    EndpointAddress remoteAddress = new EndpointAddress(new Uri(string.Format(CultureInfo.InvariantCulture
        , "net.pipe://localhost/IstaServicesHost/{0}", typeof(TServiceContract).Name)), new AddressHeader[]
        {AddressHeader.CreateAddressHeader("PID", string.Empty, Process.GetCurrentProcess().Id.ToString())});
    return  ChannelFactory<TServiceContract>(binding, remoteAddress);
}


public:
    
    template<typename TResult>
    TResult IstaServiceClientBase<TServiceContract>::  CallFunction(TResult& func(TServiceContract));

    bool IsAvailable_fun(TServiceContract channel)
    {
        return channel.IsAvailable();
    }
    template<typename TResult>
    bool IsAvailable()
    {
        bool result = this->CallFunction<bool>(IsAvailable_fun);
        //try
        //{
        //    result = this->CallFunction<bool>((TServiceContract channel) = > channel.IsAvailable());
        //}
        //catch (Exception)
        //{
        //    result = false;
        //}
        return result;
    }
    
};

//template<typename TServiceContract>
class IstaAirServiceClient :public IstaServiceClient<IIstaAirService>, public IIstaAirService, public IIstaService
{

private:
    AirStartProperties fun_props;//StartAir调用的委托需要的变量
    string fun_vin7, fun_string_0, fun_lang;//TeileClearingRelevant调用的委托需要的变量
    AirSendMaintenanceEntry fun_entry;
    string fun_string_1;

public:

    //子类构造顺便调用基类的有参构造
    //IstaAirServiceClient() :IstaServiceClient<IIstaAirService>()
    //{
    //}
    
    //template<typename TServiceContract>
    //bool IstaServiceClient<IIstaAirService>::IsAvailable();
    //template<typename TResult>
    bool IstaServiceClient<IIstaAirService>::IsAvailable();
    
    
    


    //下面函数StartAir用了Lambda表达式,委托为CallFunction的参数::TResult& func(TServiceContract) 其中TResult是模板类型
    AirStartResponse StartAir_fun(IIstaAirService channel)//StartAir调用的委托方法。
    {
        return  channel.StartAir(fun_props);
    }
    template<typename TResult>
    AirStartResponse StartAir(AirStartProperties props)
    {
        this->fun_props = props;//用来给委托方法的返回值用。
        //return base.CallFunction<AirStartResponse>((IIstaAirService channel) = > channel.StartAir(props));
        return this->CallFunction<AirStartResponse>(StartAir_fun);//调用了委托方法
    }


    bool TeileClearingRelevant_fun(IIstaAirService channel)//TeileClearingRelevant调用的委托方法
    {
        return channel.TeileClearingRelevant(fun_vin7, fun_string_0, fun_lang);
    }
    template<typename TResult>
    bool TeileClearingRelevant(string vin7, string string_0, string lang)
    {
        fun_vin7 = vin7; fun_string_0 = string_0; fun_lang = lang;//给调用的委托方法返回值用。
        return this->CallFunction<bool>(TeileClearingRelevant_fun);//调用了委托方法。
    }


    AirSendMaintenanceEntryResponse SendMaintenanceEntry_fun(IIstaAirService channel)
    {
        return channel.SendMaintenanceEntry(fun_entry);
    }
    template<typename TResult>
    AirSendMaintenanceEntryResponse SendMaintenanceEntry(AirSendMaintenanceEntry entry)
    {
         fun_entry = entry;
        return this->CallFunction<AirSendMaintenanceEntryResponse>(SendMaintenanceEntry_fun);
    }
    
    AirServiceHistoryLP2Response GetServiceHistoryLP2_fun(IIstaAirService channel)
    {
        return  channel.GetServiceHistoryLP2(fun_string_1);
    }
    template<typename TResult>
    AirServiceHistoryLP2Response GetServiceHistoryLP2(string string_0)
    {
        fun_string_1 = string_0;
        return this->CallFunction<AirServiceHistoryLP2Response>(GetServiceHistoryLP2_fun);
    }
};

//-----------------namespace BMW.ISPI.IstaServices.Contract.AIR------------//
// 
//航空发送维修入口响应
class AirSendMaintenanceEntryResponse
{
public:
    AirSendMaintenanceEntryResponse()
    {
        this->Success = false;
        this->Errors =  list<string>();
        this->MaintenanceId = {};
    }
    string MaintenanceId;// { get; set; }
    
    bool Success;// { get; set; }

    list<string> Errors;// { get; set; }
};

//--------------------namespace BMW.ISPI.IstaServices.Contract.AIR.Data------------------//

//航空动态牵引力控制系统
class AirDtc
{
public:
    bool IsCombined;//{ get; set; }
    bool IsVirtual;// { get; set; }
    bool  IsRelevant;// { get; set; }
    long double Id;// { get; set; }
    long  No;// { get; set; }
};

//航空经销商数据
class AirDealerData 
{
public:
    string DealerAddress;// { get; set; }
    string DealerCity;// { get; set; }
    string DealerCountry;// { get; set; }
    string DealerPostCode;// { get; set; }
    string DealerEMail;// { get; set; }
    string DealerName;// { get; set; }
    string DealerPhone;// { get; set; }
    string DistributionPartnerNumber; // 分销商数量{ get; set; }
    string OutletNumber;// { get; set; }
    string OutletNumber;// { get; set; }
};

//航空服务历史LP2响应
class AirServiceHistoryLP2Response
{
public:
    int Fehlergrund;// { get; set; }
    bool Status;// { get; set; }
    vector<string>SgbdName;// { get; set; }
    vector<byte> WartungsTag;// { get; set; }
    vector< byte>WartungsMonat;// { get; set; }
    vector<unsigned int> WartungsJahr;// { get; set; }
    vector<byte> KorrekturZaehler;// { get; set; }
    vector<unsigned long> KmStand;// { get; set; }
    vector<byte> FlagBmwHaendler;// { get; set; }
    vector<string> HaendlerNummer;// { get; set; }
    vector<byte> WartungsStatus;// { get; set; }
    vector<byte> AnzahlWartungsEintraege;// { get; set; }
    map<string, byte> WartungsText;// { get; set; }
    map<string, byte> StatusWartungsPos;// { get; set; }
    map<string, long> RestDistanz;// { get; set; }
    map<string, unsigned int> RestZeit;// { get; set; }
    int ServiceEntrySize;
};

//航空汽车数据
class AirVehicleData
{
public:
    long double Gwsz;// { get; set; }
    string VIN7;// { get; set; }
    string VIN10Prefix;// { get; set; }
};

//航空发送维修入口
class AirSendMaintenanceEntry
{

public:
    AirDealerData DealerData;// { get; set; }
    AirVehicleData VehicleData;// { get; set; }
    string IstaCaseId;// { get; set; }
};

//航空开始属性
class AirStartProperties 
{
    // Token: 0x06000B3D RID: 2877 RVA: 0x000077F4 File Offset: 0x000059F4
public:
    AirStartProperties()
    {
        this->PreRepTaskIds = list<string>();
    }

    string PreRepId;// { get; set; }
    list<string> PreRepTaskIds;// { get; }
    string Language;// { get; set; }
    string Vin;// { get; set; }
    bool VehicleDiagnostic;// { get; set; }
    list<AirDtc> Faultcodes;// { get; set; }
    list<bool> RelevanceToFaultcodes;// { get; set; }
    list<AirPerceivedSymptom> PerceivedSymptoms;// { get; set; }
    set<string> DiagnosticCodes;// { get; set; }
    string NavigationTarget;//{ get; set; }
};

//航空感知症状
class AirPerceivedSymptom
{
public:
    string VfcType;// { get; set; }
    string VfcNr;// { get; set; }
    string ParentNodeIdentifier;// { get; set; }
};

//航空开始反应
class AirStartResponse
{
public:
    int Fehlergrund;// { get; set; }
};

#endif // !_ISTA_AIR_SERVICE_CLIENT_H


  • 写回答

2条回答 默认 最新

  • yun6853992 2022-06-21 11:51
    关注

    提示很明确,我只是没看懂你这个
    这已经在class类中了,你为什么前面还要带一堆的类名加::

    img

    这里子类想重新实现基类的函数???

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 7月6日
  • 已采纳回答 6月28日
  • 创建了问题 6月21日

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题