复制操作符不在Quick Fast C ++中

时间:2017-05-22 06:03:45

标签: c++ fix-protocol

现在我正在研究复制运营商。我从网上可用的所有文档和其他材料中理解的是,Quickfast维护一个字典,UDP消息中的多个条目使用该字典来检查先前的值。

例如:让我们在下面给出的模板中说,我们可以有多个MDEntries,具体取决于NoMDEntries标记值。让我们说我们有2作为价值。 我做的是,我在第一个条目中将MDEntryType(带有复制oprerator)的值设置为1(某个随机值),但对于第二个条目,我没有放任何值。 解码消息后,两个条目的MDEntryType值应为1。

我的理解是否正确?

<template dictionary="1" id="1" name="MDIncRefreshSample_1">
 <string id="35" name="MessageType">
    <constant value="X"></constant>
 </string>     <string id="49" name="SenderCompID">
    <constant value="Client"></constant>
</string>     <string id="56" name="TargetCompID">
    <constant value="Server"></constant>
</string>     <uint32 id="34" name="MsgSeqNum"></uint32>
<uint64 id="52" name="SendingTime"></uint64>
<sequence name="MDEntries">
    <length id="268" name="NoMDEntries"></length>
    <uint32 id="279" name="MDUpdateAction">
        <copy value="1"></copy>
    </uint32>
    <string id="269" name="MDEntryType">
        <copy value="0"></copy>
    </string>
    <uint32 id="278" name="MDEntryID"></uint32>
    <uint32 id="48" name="SecurityID">
        <delta></delta>
    </uint32>
    <decimal id="270" name="MDEntryPx">
        <exponent>
            <default value="-2"></default>
        </exponent>
        <mantissa>
            <delta></delta>
        </mantissa>
    </decimal>
    <int32 id="271" name="MDEntrySize">
        <delta></delta>
    </int32>
    <string id="37" name="OrderID"></string>
    <uint32 id="273" name="MDEntryTime">
        <copy></copy>
    </uint32>
 </sequence>
 </template>

现在,当我尝试在我的代码中实现上述内容时,我无法复制第二个条目中的值。 以下是我使用的代码片段(来自testRoundTrip.cpp的帮助)

模板创建:

  <templates> 
    <template dictionary="InstrumentReferenceData" 
     name="InstrumentReferenceData" id="3">  
     <typeRef name="instrumentreferencedata"/>  
     <uInt32 name="timestamp" id="52"> <delta/>    </uInt32>  
     <uInt32 name="srcId" id="50">      <copy/>    </uInt32>   
     <uInt32 name="seqNum" id="34">      <increment value="1"/>    </uInt32> 
     <uInt32 name="isix" id="48">      <delta/>    </uInt32>  
    <string name="isin" id="455">      <delta/>    </string> 
    <string name="exchId" id="207">      <copy/>    </string>  
    <string name="instGrp" id="1151">      <copy/>    </string>
    <string name="instTypCod" id="461">      <copy/>    </string>    
    <string name="currCode" id="15">      <copy/>    </string>    
    <decimal name="ticSiz" id="969">      <delta/>    </decimal>   
    <uInt32 name="setId" id="TBD">      <copy/>    </uInt32>  
     <sequence name="MDFeedTypes">    
     <length name="noOfStreams" id="1141"/>     
     <string name="streamType" id="1022">      <copy dictionary="template" />      
    </string>   
    <string name="streamService">      <copy/>      </string>        
     <string name="inetAddr">        <delta/>      </string>       
  <uInt32 name="port" id="TBD">        <delta/>      </uInt32>        
  <uInt32 name="mktDepth" id="264" presence="optional"/>   </uInt32>       
  <uInt32 name="mdBookType" id="1021" presence="optional"/>   </uInt32>
    </sequence>
    </template>
    </templates>

消息创建以及编码和解码:(我只在streamtype字段中输入了一次值)

 Messages::MessagePtr msg(new Messages::Message(templateRegistry->maxFieldCount()));
  msg->addField(identity_timestamp, Messages::FieldUInt32::create(1));

  msg->addField(identity_srcId, Messages::FieldUInt32::create(2));

  msg->addField(identity_seqNum, Messages::FieldUInt32::create(3));

  msg->addField(identity_isix, Messages::FieldUInt32::create(4));

  msg->addField(identity_isin, Messages::FieldAscii::create("isin"));

  msg->addField(identity_exchId, Messages::FieldAscii::create("exchId"));

  msg->addField(identity_instGrp, Messages::FieldAscii::create("instGrp"));

  msg->addField(identity_instTypCod, Messages::FieldAscii::create("instTypCod"));

  msg->addField(identity_currCode, Messages::FieldAscii::create("currCode"));

  msg->addField(identity_ticSiz, Messages::FieldDecimal::create(Decimal(123, -1)));

  msg->addField(identity_setId, Messages::FieldUInt32::create(5));

  lengthIdentity.setId("1141");
  Messages::SequencePtr sequence_MDFeedTypes(new Messages::Sequence(lengthIdentity, 2));
  Messages::FieldSetPtr entry(new Messages::FieldSet(6)); // todo Hardcoded 6?

  entry->addField(identity_streamType, Messages::FieldAscii::create("streamType"));    // Populated the value 1st time

  entry->addField(identity_streamService, Messages::FieldAscii::create("streamService"));

  entry->addField(identity_inetAddr, Messages::FieldAscii::create("inetAddr.com"));

  entry->addField(identity_port, Messages::FieldUInt32::create(2222));

  entry->addField(identity_mktDepth, Messages::FieldUInt32::create(10));



  sequence_MDFeedTypes->addEntry(Messages::FieldSetCPtr(entry));

  entry.reset(new Messages::FieldSet(6));

  entry->addField(identity_streamType, Messages::FieldAscii::create(""));     // Did not Populate the value 2nd time

  entry->addField(identity_streamService, Messages::FieldAscii::create(""));

  entry->addField(identity_inetAddr, Messages::FieldAscii::create("inetAddr.org"));

  entry->addField(identity_port, Messages::FieldUInt32::create(2224));

  entry->addField(identity_mdBookType, Messages::FieldUInt32::create(3));



  sequence_MDFeedTypes->addEntry(Messages::FieldSetCPtr(entry));

  msg->addField(identity_MDFeedTypes, Messages::FieldSequence::create(sequence_MDFeedTypes));

  Codecs::Encoder encoder(templateRegistry);
  Codecs::DataDestination destination;
  template_id_t templId = 3; // from the XML above
  encoder.encodeMessage(destination, templId, *msg);
  std::string fastString;
  destination.toString(fastString);
  std::cout<<"fastString is "<<fastString<<std::endl;

  destination.clear();

  Codecs::Decoder decoder(templateRegistry);
  Codecs::DataSourceString source(fastString);
  Codecs::SingleMessageConsumer consumer;
  Codecs::GenericMessageBuilder builder(consumer);
  decoder.decodeMessage(source, builder);

  Messages::Message & msgOut(consumer.message());

        Messages::MessageFormatter formatter(std::cout);
        formatter.formatMessage(msgOut);                                   // I have made some printing changes to print the ouptut per tag 

  validateMessage1(msgOut);


  encoder.reset();
  encoder.encodeMessage(destination, templId, msgOut);
  std::string reencoded;
  destination.toString(reencoded);

  destination.clear();

我能够对消息进行编码并成功解码,但该值不会被复制到第二个条目(streamType标记)中。 这是我的解码输出:

 1st entry:
 streamType[1022]=streamType                  
 streamService[]=streamService
 inetAddr[]=inetAddr.com
 port[TBD]= 2045


 2nd entry:
streamType[1022]=                     //value not copied
streamService[]=
 inetAddr[]=inetAddr.org
 port[TBD]= 2046

如果我们在某个地方犯了错误,请你告诉我们。我对此很新:)

我也有以下问题:

1 / 我们是否需要明确需要在fastfast中启用/禁用字典? (在FIX中,我们可以使用flag,DataDictionary = Y / N)。 同样在上面创建的模板中,我找到了这一行:

<string name="streamType" id="1022">      <copy dictionary="template" />      </string>

在使用运算符时是否需要提供字典名称以及它们如何相关?

2 /我们还需要明确提到需要PMAP位吗?

编解码器:: PresenceMap pmap(1); //我遇到过这个函数,所以我怀疑是否需要明确提及pmap。

0 个答案:

没有答案